refactor(x/staking)!: KVStoreService, return errors and use context.Context (backport #16324) (#16598)
Co-authored-by: Facundo Medica <14063057+facundomedica@users.noreply.github.com> Co-authored-by: Julien Robert <julien@rbrt.fr> Co-authored-by: Facundo Medica <facundomedica@gmail.com>
This commit is contained in:
co-authored by
Facundo Medica
Julien Robert
Facundo Medica
parent
c06d8d7bef
commit
9f7a16080a
@@ -2,6 +2,7 @@ package sims
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"strconv"
|
||||
@@ -23,12 +24,16 @@ type GenerateAccountStrategy func(int) []sdk.AccAddress
|
||||
// provides the staking bond denom. It is used in arguments in this package's
|
||||
// functions so that a mock staking keeper can be passed instead of the real one.
|
||||
type BondDenomProvider interface {
|
||||
BondDenom(ctx sdk.Context) string
|
||||
BondDenom(ctx context.Context) (string, error)
|
||||
}
|
||||
|
||||
// AddTestAddrsFromPubKeys adds the addresses into the SimApp providing only the public keys.
|
||||
func AddTestAddrsFromPubKeys(bankKeeper bankkeeper.Keeper, stakingKeeper BondDenomProvider, ctx sdk.Context, pubKeys []cryptotypes.PubKey, accAmt math.Int) {
|
||||
initCoins := sdk.NewCoins(sdk.NewCoin(stakingKeeper.BondDenom(ctx), accAmt))
|
||||
bondDenom, err := stakingKeeper.BondDenom(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
initCoins := sdk.NewCoins(sdk.NewCoin(bondDenom, accAmt))
|
||||
|
||||
for _, pk := range pubKeys {
|
||||
initAccountWithCoins(bankKeeper, ctx, sdk.AccAddress(pk.Address()), initCoins)
|
||||
@@ -48,7 +53,11 @@ func AddTestAddrsIncremental(bankKeeper bankkeeper.Keeper, stakingKeeper BondDen
|
||||
|
||||
func addTestAddrs(bankKeeper bankkeeper.Keeper, stakingKeeper BondDenomProvider, ctx sdk.Context, accNum int, accAmt math.Int, strategy GenerateAccountStrategy) []sdk.AccAddress {
|
||||
testAddrs := strategy(accNum)
|
||||
initCoins := sdk.NewCoins(sdk.NewCoin(stakingKeeper.BondDenom(ctx), accAmt))
|
||||
bondDenom, err := stakingKeeper.BondDenom(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
initCoins := sdk.NewCoins(sdk.NewCoin(bondDenom, accAmt))
|
||||
|
||||
for _, addr := range testAddrs {
|
||||
initAccountWithCoins(bankKeeper, ctx, addr, initCoins)
|
||||
|
||||
Reference in New Issue
Block a user