abci: VoteInfo, ValidatorUpdate. See ADR-018

This commit is contained in:
Ethan Buchman
2018-08-16 13:19:13 -04:00
parent f26b83f15f
commit e3f54ece2f
18 changed files with 706 additions and 452 deletions
+9 -9
View File
@@ -86,7 +86,7 @@ func TestBeginBlockValidators(t *testing.T) {
// -> app receives a list of validators with a bool indicating if they signed
ctr := 0
for i, v := range app.Validators {
for i, v := range app.CommitVotes {
if ctr < len(tc.expectedAbsentValidators) &&
tc.expectedAbsentValidators[ctr] == i {
@@ -160,7 +160,7 @@ func TestUpdateValidators(t *testing.T) {
name string
currentSet *types.ValidatorSet
abciUpdates []abci.Validator
abciUpdates []abci.ValidatorUpdate
resultingSet *types.ValidatorSet
shouldErr bool
@@ -169,7 +169,7 @@ func TestUpdateValidators(t *testing.T) {
"adding a validator is OK",
types.NewValidatorSet([]*types.Validator{val1}),
[]abci.Validator{{Address: []byte{}, PubKey: types.TM2PB.PubKey(pubkey2), Power: 20}},
[]abci.ValidatorUpdate{{PubKey: types.TM2PB.PubKey(pubkey2), Power: 20}},
types.NewValidatorSet([]*types.Validator{val1, val2}),
false,
@@ -178,7 +178,7 @@ func TestUpdateValidators(t *testing.T) {
"updating a validator is OK",
types.NewValidatorSet([]*types.Validator{val1}),
[]abci.Validator{{Address: []byte{}, PubKey: types.TM2PB.PubKey(pubkey1), Power: 20}},
[]abci.ValidatorUpdate{{PubKey: types.TM2PB.PubKey(pubkey1), Power: 20}},
types.NewValidatorSet([]*types.Validator{types.NewValidator(pubkey1, 20)}),
false,
@@ -187,7 +187,7 @@ func TestUpdateValidators(t *testing.T) {
"removing a validator is OK",
types.NewValidatorSet([]*types.Validator{val1, val2}),
[]abci.Validator{{Address: []byte{}, PubKey: types.TM2PB.PubKey(pubkey2), Power: 0}},
[]abci.ValidatorUpdate{{PubKey: types.TM2PB.PubKey(pubkey2), Power: 0}},
types.NewValidatorSet([]*types.Validator{val1}),
false,
@@ -197,7 +197,7 @@ func TestUpdateValidators(t *testing.T) {
"removing a non-existing validator results in error",
types.NewValidatorSet([]*types.Validator{val1}),
[]abci.Validator{{Address: []byte{}, PubKey: types.TM2PB.PubKey(pubkey2), Power: 0}},
[]abci.ValidatorUpdate{{PubKey: types.TM2PB.PubKey(pubkey2), Power: 0}},
types.NewValidatorSet([]*types.Validator{val1}),
true,
@@ -207,7 +207,7 @@ func TestUpdateValidators(t *testing.T) {
"adding a validator with negative power results in error",
types.NewValidatorSet([]*types.Validator{val1}),
[]abci.Validator{{Address: []byte{}, PubKey: types.TM2PB.PubKey(pubkey2), Power: -100}},
[]abci.ValidatorUpdate{{PubKey: types.TM2PB.PubKey(pubkey2), Power: -100}},
types.NewValidatorSet([]*types.Validator{val1}),
true,
@@ -335,7 +335,7 @@ func makeBlock(state State, height int64) *types.Block {
type testApp struct {
abci.BaseApplication
Validators []abci.SigningValidator
CommitVotes []abci.VoteInfo
ByzantineValidators []abci.Evidence
ValidatorUpdates []abci.Validator
}
@@ -347,7 +347,7 @@ func (app *testApp) Info(req abci.RequestInfo) (resInfo abci.ResponseInfo) {
}
func (app *testApp) BeginBlock(req abci.RequestBeginBlock) abci.ResponseBeginBlock {
app.Validators = req.LastCommitInfo.Validators
app.CommitVotes = req.LastCommitInfo.CommitVotes
app.ByzantineValidators = req.ByzantineValidators
return abci.ResponseBeginBlock{}
}