aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorHaoping Ku <haoping.ku@dexon.org>2018-07-24 18:35:32 +0800
committerGitHub <noreply@github.com>2018-07-24 18:35:32 +0800
commit39bcb39dd5d93401c21b374cbd1e1818b76d6891 (patch)
treedba957003d1d1c7bb79cebcc5063a7ba765a0eba /core
parent2108b92131fff21c8e2b7e5b85a77e3f693dadd9 (diff)
downloaddexon-consensus-39bcb39dd5d93401c21b374cbd1e1818b76d6891.tar
dexon-consensus-39bcb39dd5d93401c21b374cbd1e1818b76d6891.tar.gz
dexon-consensus-39bcb39dd5d93401c21b374cbd1e1818b76d6891.tar.bz2
dexon-consensus-39bcb39dd5d93401c21b374cbd1e1818b76d6891.tar.lz
dexon-consensus-39bcb39dd5d93401c21b374cbd1e1818b76d6891.tar.xz
dexon-consensus-39bcb39dd5d93401c21b374cbd1e1818b76d6891.tar.zst
dexon-consensus-39bcb39dd5d93401c21b374cbd1e1818b76d6891.zip
Fix blocklattice_test.go's ordering check (#15)
Outputs of total ordering are sorted by hash value in blocklattice.go, but was checked orderly in test, which the order might change due to random hash. Added common.Hashes.
Diffstat (limited to 'core')
-rw-r--r--core/blocklattice_test.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/core/blocklattice_test.go b/core/blocklattice_test.go
index f43d645..be332db 100644
--- a/core/blocklattice_test.go
+++ b/core/blocklattice_test.go
@@ -18,6 +18,7 @@
package core
import (
+ "sort"
"testing"
"github.com/stretchr/testify/suite"
@@ -480,8 +481,11 @@ func (s *BlockLatticeTest) TesttotalOrdering() {
s.app.Clear()
lattice.ProcessBlock(b13, true)
s.Require().Equal(2, len(s.app.Outputs))
- s.Require().Equal(b21.Hash, s.app.Outputs[0].Hash)
- s.Require().Equal(b11.Hash, s.app.Outputs[1].Hash)
+ expected := common.Hashes{b21.Hash, b11.Hash}
+ sort.Sort(expected)
+ got := common.Hashes{s.app.Outputs[0].Hash, s.app.Outputs[1].Hash}
+ sort.Sort(got)
+ s.Require().Equal(expected, got)
s.Require().Equal(false, s.app.Early)
s.Require().Equal(1, len(lattice.candidateSet))