mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-28 04:01:40 +00:00
abci: VoteInfo, ValidatorUpdate. See ADR-018
This commit is contained in:
@ -41,26 +41,26 @@ func TestABCIValidators(t *testing.T) {
|
||||
VotingPower: 10,
|
||||
}
|
||||
|
||||
abciVal := TM2PB.Validator(tmVal)
|
||||
tmVals, err := PB2TM.Validators([]abci.Validator{abciVal})
|
||||
abciVal := TM2PB.ValidatorUpdate(tmVal)
|
||||
tmVals, err := PB2TM.ValidatorUpdates([]abci.ValidatorUpdate{abciVal})
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, tmValExpected, tmVals[0])
|
||||
|
||||
abciVals := TM2PB.Validators(NewValidatorSet(tmVals))
|
||||
assert.Equal(t, []abci.Validator{abciVal}, abciVals)
|
||||
abciVals := TM2PB.ValidatorUpdates(NewValidatorSet(tmVals))
|
||||
assert.Equal(t, []abci.ValidatorUpdate{abciVal}, abciVals)
|
||||
|
||||
// val with address
|
||||
tmVal.Address = pkEd.Address()
|
||||
|
||||
abciVal = TM2PB.Validator(tmVal)
|
||||
tmVals, err = PB2TM.Validators([]abci.Validator{abciVal})
|
||||
abciVal = TM2PB.ValidatorUpdate(tmVal)
|
||||
tmVals, err = PB2TM.ValidatorUpdates([]abci.ValidatorUpdate{abciVal})
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, tmValExpected, tmVals[0])
|
||||
|
||||
// val with incorrect address
|
||||
abciVal = TM2PB.Validator(tmVal)
|
||||
abciVal.Address = []byte("incorrect!")
|
||||
tmVals, err = PB2TM.Validators([]abci.Validator{abciVal})
|
||||
// val with incorrect pubkey daya
|
||||
abciVal = TM2PB.ValidatorUpdate(tmVal)
|
||||
abciVal.PubKey.Data = []byte("incorrect!")
|
||||
tmVals, err = PB2TM.ValidatorUpdates([]abci.ValidatorUpdate{abciVal})
|
||||
assert.NotNil(t, err)
|
||||
assert.Nil(t, tmVals)
|
||||
}
|
||||
@ -104,9 +104,6 @@ func TestABCIEvidence(t *testing.T) {
|
||||
)
|
||||
|
||||
assert.Equal(t, "duplicate/vote", abciEv.Type)
|
||||
|
||||
// test we do not send pubkeys
|
||||
assert.Empty(t, abciEv.Validator.PubKey)
|
||||
}
|
||||
|
||||
type pubKeyEddie struct{}
|
||||
@ -119,17 +116,17 @@ func (pubKeyEddie) Equals(crypto.PubKey) bool { return false }
|
||||
func TestABCIValidatorFromPubKeyAndPower(t *testing.T) {
|
||||
pubkey := ed25519.GenPrivKey().PubKey()
|
||||
|
||||
abciVal := TM2PB.ValidatorFromPubKeyAndPower(pubkey, 10)
|
||||
abciVal := TM2PB.NewValidatorUpdate(pubkey, 10)
|
||||
assert.Equal(t, int64(10), abciVal.Power)
|
||||
|
||||
assert.Panics(t, func() { TM2PB.ValidatorFromPubKeyAndPower(nil, 10) })
|
||||
assert.Panics(t, func() { TM2PB.ValidatorFromPubKeyAndPower(pubKeyEddie{}, 10) })
|
||||
assert.Panics(t, func() { TM2PB.NewValidatorUpdate(nil, 10) })
|
||||
assert.Panics(t, func() { TM2PB.NewValidatorUpdate(pubKeyEddie{}, 10) })
|
||||
}
|
||||
|
||||
func TestABCIValidatorWithoutPubKey(t *testing.T) {
|
||||
pkEd := ed25519.GenPrivKey().PubKey()
|
||||
|
||||
abciVal := TM2PB.ValidatorWithoutPubKey(&Validator{
|
||||
abciVal := TM2PB.Validator(&Validator{
|
||||
Address: pkEd.Address(),
|
||||
PubKey: pkEd,
|
||||
VotingPower: 10,
|
||||
|
Reference in New Issue
Block a user