aboutsummaryrefslogtreecommitdiffstats
path: root/core/test/state_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/test/state_test.go
parent146ed32cf841151b826eafd7d6ade188c56865bf (diff)
downloaddexon-consensus-6d1c1aeea0d3e75d10cbb2712c68b4c422ba8ba6.tar
dexon-consensus-6d1c1aeea0d3e75d10cbb2712c68b4c422ba8ba6.tar.gz
dexon-consensus-6d1c1aeea0d3e75d10cbb2712c68b4c422ba8ba6.tar.bz2
dexon-consensus-6d1c1aeea0d3e75d10cbb2712c68b4c422ba8ba6.tar.lz
dexon-consensus-6d1c1aeea0d3e75d10cbb2712c68b4c422ba8ba6.tar.xz
dexon-consensus-6d1c1aeea0d3e75d10cbb2712c68b4c422ba8ba6.tar.zst
dexon-consensus-6d1c1aeea0d3e75d10cbb2712c68b4c422ba8ba6.zip
utils: move authenticator to utils package (#378)
Diffstat (limited to 'core/test/state_test.go')
-rw-r--r--core/test/state_test.go32
1 files changed, 12 insertions, 20 deletions
diff --git a/core/test/state_test.go b/core/test/state_test.go
index c05d41b..ad3d1c4 100644
--- a/core/test/state_test.go
+++ b/core/test/state_test.go
@@ -28,6 +28,7 @@ import (
"github.com/dexon-foundation/dexon-consensus/core/crypto/ecdsa"
"github.com/dexon-foundation/dexon-consensus/core/types"
typesDKG "github.com/dexon-foundation/dexon-consensus/core/types/dkg"
+ "github.com/dexon-foundation/dexon-consensus/core/utils"
"github.com/stretchr/testify/suite"
)
@@ -55,12 +56,9 @@ func (s *StateTestSuite) newDKGMasterPublicKey(
func (s *StateTestSuite) newDKGComplaint(round uint64) *typesDKG.Complaint {
prvKey, err := ecdsa.NewPrivateKey()
s.Require().NoError(err)
- pubKey := prvKey.PublicKey()
- nodeID := types.NewNodeID(pubKey)
- // TODO(mission): sign it, and it doesn't make sense to complaint self.
- return &typesDKG.Complaint{
- ProposerID: nodeID,
- Round: round,
+ nodeID := types.NewNodeID(prvKey.PublicKey())
+ comp := &typesDKG.Complaint{
+ Round: round,
PrivateShare: typesDKG.PrivateShare{
ProposerID: nodeID,
ReceiverID: nodeID,
@@ -68,29 +66,23 @@ func (s *StateTestSuite) newDKGComplaint(round uint64) *typesDKG.Complaint {
PrivateShare: *dkg.NewPrivateKey(),
},
}
+ s.Require().NoError(utils.NewSigner(prvKey).SignDKGComplaint(comp))
+ return comp
}
func (s *StateTestSuite) newDKGMPKReady(round uint64) *typesDKG.MPKReady {
prvKey, err := ecdsa.NewPrivateKey()
s.Require().NoError(err)
- pubKey := prvKey.PublicKey()
- nodeID := types.NewNodeID(pubKey)
- // TODO(mission): sign it.
- return &typesDKG.MPKReady{
- ProposerID: nodeID,
- Round: round,
- }
+ ready := &typesDKG.MPKReady{Round: round}
+ s.Require().NoError(utils.NewSigner(prvKey).SignDKGMPKReady(ready))
+ return ready
}
func (s *StateTestSuite) newDKGFinal(round uint64) *typesDKG.Finalize {
prvKey, err := ecdsa.NewPrivateKey()
s.Require().NoError(err)
- pubKey := prvKey.PublicKey()
- nodeID := types.NewNodeID(pubKey)
- // TODO(mission): sign it.
- return &typesDKG.Finalize{
- ProposerID: nodeID,
- Round: round,
- }
+ final := &typesDKG.Finalize{Round: round}
+ s.Require().NoError(utils.NewSigner(prvKey).SignDKGFinalize(final))
+ return final
}
func (s *StateTestSuite) compareNodes(node1, node2 []crypto.PublicKey) bool {