aboutsummaryrefslogtreecommitdiffstats
path: root/core/lattice_test.go
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2018-12-22 12:54:03 +0800
committerGitHub <noreply@github.com>2018-12-22 12:54:03 +0800
commit6d1c1aeea0d3e75d10cbb2712c68b4c422ba8ba6 (patch)
tree1895248f011a356fcd2a28c03dbda9d93fd46fd8 /core/lattice_test.go
parent146ed32cf841151b826eafd7d6ade188c56865bf (diff)
downloaddexon-consensus-6d1c1aeea0d3e75d10cbb2712c68b4c422ba8ba6.tar.gz
dexon-consensus-6d1c1aeea0d3e75d10cbb2712c68b4c422ba8ba6.tar.zst
dexon-consensus-6d1c1aeea0d3e75d10cbb2712c68b4c422ba8ba6.zip
utils: move authenticator to utils package (#378)
Diffstat (limited to 'core/lattice_test.go')
-rw-r--r--core/lattice_test.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/core/lattice_test.go b/core/lattice_test.go
index 0c9b018..99723d6 100644
--- a/core/lattice_test.go
+++ b/core/lattice_test.go
@@ -27,6 +27,7 @@ import (
"github.com/dexon-foundation/dexon-consensus/core/db"
"github.com/dexon-foundation/dexon-consensus/core/test"
"github.com/dexon-foundation/dexon-consensus/core/types"
+ "github.com/dexon-foundation/dexon-consensus/core/utils"
"github.com/stretchr/testify/suite"
)
@@ -126,7 +127,7 @@ func (s *LatticeTestSuite) newTestLatticeMgr(
dMoment,
0,
cfg,
- NewAuthenticator(prvKey),
+ utils.NewSigner(prvKey),
app,
app,
dbInst,
@@ -224,7 +225,7 @@ func (s *LatticeTestSuite) TestSanityCheck() {
MinBlockInterval: 0,
}
lattice = s.newTestLatticeMgr(&cfg, time.Now().UTC()).lattice
- auth = lattice.authModule // Steal auth module from lattice, :(
+ signer = lattice.signer // Steal signer module from lattice, :(
req = s.Require()
err error
)
@@ -233,11 +234,12 @@ func (s *LatticeTestSuite) TestSanityCheck() {
Position: types.Position{ChainID: 0},
Timestamp: time.Now().UTC(),
}
- req.NoError(auth.SignBlock(b))
+ req.NoError(signer.SignBlock(b))
req.NoError(lattice.SanityCheck(b))
// A block with incorrect signature should not pass sanity check.
- b.Signature, err = auth.prvKey.Sign(common.NewRandomHash())
+ otherPrvKey, err := ecdsa.NewPrivateKey()
req.NoError(err)
+ b.Signature, err = otherPrvKey.Sign(common.NewRandomHash())
req.Equal(lattice.SanityCheck(b), ErrIncorrectSignature)
// A block with un-sorted acks should not pass sanity check.
b.Acks = common.NewSortedHashes(common.Hashes{
@@ -248,7 +250,7 @@ func (s *LatticeTestSuite) TestSanityCheck() {
common.NewRandomHash(),
})
b.Acks[0], b.Acks[1] = b.Acks[1], b.Acks[0]
- req.NoError(auth.SignBlock(b))
+ req.NoError(signer.SignBlock(b))
req.Equal(lattice.SanityCheck(b), ErrAcksNotSorted)
// A block with incorrect hash should not pass sanity check.
b.Hash = common.NewRandomHash()