Rebase, test fix
This commit is contained in:
parent
90d88114d9
commit
166711742e
|
@ -94,11 +94,13 @@ func (k Keeper) setCandidate(ctx sdk.Context, candidate Candidate) {
|
|||
|
||||
// update the list ordered by voting power
|
||||
if oldFound {
|
||||
// retain the old validator height, even though stake has changed
|
||||
candidate.ValidatorHeight = oldCandidate.ValidatorHeight
|
||||
store.Delete(GetValidatorKey(address, oldCandidate.Assets, oldCandidate.ValidatorHeight, k.cdc))
|
||||
}
|
||||
|
||||
} else {
|
||||
// update the validator block height
|
||||
candidate.ValidatorHeight = ctx.BlockHeight()
|
||||
}
|
||||
|
||||
// update the candidate record
|
||||
bz, err = k.cdc.MarshalBinary(candidate)
|
||||
|
|
|
@ -254,7 +254,7 @@ func TestGetValidators(t *testing.T) {
|
|||
assert.Equal(t, candidates[4].Address, validators[0].Address, "%v", validators)
|
||||
assert.Equal(t, candidates[3].Address, validators[1].Address, "%v", validators)
|
||||
assert.Equal(t, int64(0), validators[0].Height, "%v", validators)
|
||||
assert.Equal(t, int64(10), validators[1].Height, "%v", validators)
|
||||
assert.Equal(t, int64(0), validators[1].Height, "%v", validators)
|
||||
|
||||
// no change in voting power - no change in sort
|
||||
ctx = ctx.WithBlockHeight(20)
|
||||
|
@ -274,8 +274,8 @@ func TestGetValidators(t *testing.T) {
|
|||
keeper.setCandidate(ctx, candidates[4])
|
||||
validators = keeper.GetValidators(ctx)
|
||||
require.Equal(t, len(validators), n, "%v", validators)
|
||||
assert.Equal(t, candidates[3].Address, validators[0].Address, "%v", validators)
|
||||
assert.Equal(t, candidates[4].Address, validators[1].Address, "%v", validators)
|
||||
assert.Equal(t, candidates[4].Address, validators[0].Address, "%v", validators)
|
||||
assert.Equal(t, candidates[3].Address, validators[1].Address, "%v", validators)
|
||||
|
||||
// reset assets / heights
|
||||
candidates[3].Assets = sdk.NewRat(300)
|
||||
|
|
Loading…
Reference in New Issue