Fix genesis bond intra-tx counter bug
This commit is contained in:
parent
55ef898db8
commit
79aeb2b4b9
|
@ -59,3 +59,4 @@ BUG FIXES
|
|||
* \#1804 Fixes gen-tx genesis generation logic temporarily until upstream updates
|
||||
* \#1799 Fix `gaiad export`
|
||||
* \#1828 Force user to specify amount on create-validator command by removing default
|
||||
* \#1839 Fixed bug where intra-tx counter wasn't set correctly for genesis validators
|
||||
|
|
|
@ -21,6 +21,7 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, data types.GenesisState) (res [
|
|||
keeper.InitIntraTxCounter(ctx)
|
||||
|
||||
for i, validator := range data.Validators {
|
||||
validator.BondIntraTxCounter = int16(i) // set the intra-tx counter to the order the validators are presented
|
||||
keeper.SetValidator(ctx, validator)
|
||||
|
||||
if validator.Tokens.IsZero() {
|
||||
|
@ -33,7 +34,6 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, data types.GenesisState) (res [
|
|||
// Manually set indexes for the first time
|
||||
keeper.SetValidatorByPubKeyIndex(ctx, validator)
|
||||
|
||||
validator.BondIntraTxCounter = int16(i) // set the intra-tx counter to the order the validators are presented
|
||||
keeper.SetValidatorByPowerIndex(ctx, validator, data.Pool)
|
||||
|
||||
if validator.Status == sdk.Bonded {
|
||||
|
|
|
@ -42,14 +42,16 @@ func TestInitGenesis(t *testing.T) {
|
|||
vals, err := InitGenesis(ctx, keeper, genesisState)
|
||||
require.NoError(t, err)
|
||||
|
||||
// now make sure the validators are bonded
|
||||
// now make sure the validators are bonded and intra-tx counters are correct
|
||||
resVal, found := keeper.GetValidator(ctx, keep.Addrs[0])
|
||||
require.True(t, found)
|
||||
require.Equal(t, sdk.Bonded, resVal.Status)
|
||||
require.Equal(t, int16(0), resVal.BondIntraTxCounter)
|
||||
|
||||
resVal, found = keeper.GetValidator(ctx, keep.Addrs[1])
|
||||
require.True(t, found)
|
||||
require.Equal(t, sdk.Bonded, resVal.Status)
|
||||
require.Equal(t, int16(1), resVal.BondIntraTxCounter)
|
||||
|
||||
abcivals := make([]abci.Validator, len(vals))
|
||||
for i, val := range validators {
|
||||
|
|
Loading…
Reference in New Issue