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