11package testutil
22
33import (
4+ "encoding/binary"
45 "encoding/json"
56 "math/big"
67 "time"
78
89 coreheader "cosmossdk.io/core/header"
910 sdkmath "cosmossdk.io/math"
11+ storetypes "cosmossdk.io/store/types"
1012 abci "github.com/cometbft/cometbft/abci/types"
1113 tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
1214 "github.com/cosmos/cosmos-sdk/baseapp"
@@ -17,6 +19,7 @@ import (
1719 sdk "github.com/cosmos/cosmos-sdk/types"
1820 authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
1921 authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
22+ banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
2023 stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
2124 "github.com/ethereum/go-ethereum/common"
2225 "github.com/ethereum/go-ethereum/common/hexutil"
@@ -41,6 +44,30 @@ type BaseTestSuite struct {
4144 App * app.EthermintApp
4245}
4346
47+ func (suite * BaseTestSuite ) MintFeeCollectorVirtual (coins sdk.Coins ) {
48+ // add some virtual balance to the fee collector for refunding
49+ addVirtualCoins (
50+ suite .Ctx .ObjectStore (suite .App .GetStoreKey (banktypes .ObjectStoreKey )),
51+ suite .Ctx .TxIndex (),
52+ authtypes .NewModuleAddress (authtypes .FeeCollectorName ),
53+ coins ,
54+ )
55+ }
56+
57+ func addVirtualCoins (store storetypes.ObjKVStore , txIndex int , addr sdk.AccAddress , amt sdk.Coins ) {
58+ key := make ([]byte , len (addr )+ 8 )
59+ copy (key , addr )
60+ binary .BigEndian .PutUint64 (key [len (addr ):], uint64 (txIndex ))
61+
62+ var coins sdk.Coins
63+ value := store .Get (key )
64+ if value != nil {
65+ coins = value .(sdk.Coins )
66+ }
67+ coins = coins .Add (amt ... )
68+ store .Set (key , coins )
69+ }
70+
4471func (suite * BaseTestSuite ) SetupTest () {
4572 suite .SetupTestWithCb (suite .T (), nil )
4673}
0 commit comments