aboutsummaryrefslogtreecommitdiffstats
path: root/core/agreement_test.go
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2018-09-20 09:09:37 +0800
committerGitHub <noreply@github.com>2018-09-20 09:09:37 +0800
commit421d72b2d796195178104a0eb1dedf319ba8664c (patch)
treef32f15c167989905494eca1891c3240b80dac1d6 /core/agreement_test.go
parent37f117d35c6617e1944d45e001e03813a6a278ed (diff)
downloaddexon-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.tar
dexon-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.tar.gz
dexon-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.tar.bz2
dexon-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.tar.lz
dexon-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.tar.xz
dexon-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.tar.zst
dexon-consensus-421d72b2d796195178104a0eb1dedf319ba8664c.zip
Rename validator* to node* (#120)
Diffstat (limited to 'core/agreement_test.go')
-rw-r--r--core/agreement_test.go32
1 files changed, 16 insertions, 16 deletions
diff --git a/core/agreement_test.go b/core/agreement_test.go
index 4f6ec5b..b344dd9 100644
--- a/core/agreement_test.go
+++ b/core/agreement_test.go
@@ -57,8 +57,8 @@ func (s *AgreementTestSuite) proposeBlock(
type AgreementTestSuite struct {
suite.Suite
- ID types.ValidatorID
- prvKey map[types.ValidatorID]crypto.PrivateKey
+ ID types.NodeID
+ prvKey map[types.NodeID]crypto.PrivateKey
voteChan chan *types.Vote
blockChan chan common.Hash
confirmChan chan common.Hash
@@ -69,8 +69,8 @@ type AgreementTestSuite struct {
func (s *AgreementTestSuite) SetupTest() {
prvKey, err := eth.NewPrivateKey()
s.Require().Nil(err)
- s.ID = types.NewValidatorID(prvKey.PublicKey())
- s.prvKey = map[types.ValidatorID]crypto.PrivateKey{
+ s.ID = types.NewNodeID(prvKey.PublicKey())
+ s.prvKey = map[types.NodeID]crypto.PrivateKey{
s.ID: prvKey,
}
s.voteChan = make(chan *types.Vote, 100)
@@ -79,25 +79,25 @@ func (s *AgreementTestSuite) SetupTest() {
s.block = make(map[common.Hash]*types.Block)
}
-func (s *AgreementTestSuite) newAgreement(numValidator int) *agreement {
+func (s *AgreementTestSuite) newAgreement(numNotarySet int) *agreement {
leader := newGenesisLeaderSelector("🖖👽", eth.SigToPub)
agreementIdx := len(s.agreement)
blockProposer := func() *types.Block {
return s.proposeBlock(agreementIdx)
}
- validators := make(types.ValidatorIDs, numValidator-1)
- for i := range validators {
+ notarySet := make(types.NodeIDs, numNotarySet-1)
+ for i := range notarySet {
prvKey, err := eth.NewPrivateKey()
s.Require().Nil(err)
- validators[i] = types.NewValidatorID(prvKey.PublicKey())
- s.prvKey[validators[i]] = prvKey
+ notarySet[i] = types.NewNodeID(prvKey.PublicKey())
+ s.prvKey[notarySet[i]] = prvKey
}
- validators = append(validators, s.ID)
+ notarySet = append(notarySet, s.ID)
agreement := newAgreement(
s.ID,
&agreementTestReceiver{s},
- validators,
+ notarySet,
leader,
eth.SigToPub,
blockProposer,
@@ -116,7 +116,7 @@ func (s *AgreementTestSuite) prepareVote(vote *types.Vote) {
}
func (s *AgreementTestSuite) copyVote(
- vote *types.Vote, proposer types.ValidatorID) *types.Vote {
+ vote *types.Vote, proposer types.NodeID) *types.Vote {
v := vote.Clone()
v.ProposerID = proposer
s.prepareVote(v)
@@ -138,8 +138,8 @@ func (s *AgreementTestSuite) TestSimpleConfirm() {
s.Require().Len(s.voteChan, 1)
vote := <-s.voteChan
s.Equal(types.VoteAck, vote.Type)
- for vID := range s.prvKey {
- v := s.copyVote(vote, vID)
+ for nID := range s.prvKey {
+ v := s.copyVote(vote, nID)
s.Require().NoError(a.processVote(v))
}
a.nextState()
@@ -147,8 +147,8 @@ func (s *AgreementTestSuite) TestSimpleConfirm() {
s.Require().Len(s.voteChan, 1)
vote = <-s.voteChan
s.Equal(types.VoteConfirm, vote.Type)
- for vID := range s.prvKey {
- v := s.copyVote(vote, vID)
+ for nID := range s.prvKey {
+ v := s.copyVote(vote, nID)
s.Require().NoError(a.processVote(v))
}
// We have enough of Confirm-Votes.