github.com/Finschia/finschia-sdk@v0.48.1/x/bank/testutil/test_helpers.go (about) 1 package testutil 2 3 import ( 4 sdk "github.com/Finschia/finschia-sdk/types" 5 bankkeeper "github.com/Finschia/finschia-sdk/x/bank/keeper" 6 minttypes "github.com/Finschia/finschia-sdk/x/mint/types" 7 ) 8 9 // FundAccount is a utility function that funds an account by minting and 10 // sending the coins to the address. This should be used for testing purposes 11 // only! 12 // 13 // TODO: Instead of using the mint module account, which has the 14 // permission of minting, create a "faucet" account. (@fdymylja) 15 func FundAccount(bankKeeper bankkeeper.Keeper, ctx sdk.Context, addr sdk.AccAddress, amounts sdk.Coins) error { 16 if err := bankKeeper.MintCoins(ctx, minttypes.ModuleName, amounts); err != nil { 17 return err 18 } 19 20 return bankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, addr, amounts) 21 } 22 23 // FundModuleAccount is a utility function that funds a module account by 24 // minting and sending the coins to the address. This should be used for testing 25 // purposes only! 26 // 27 // TODO: Instead of using the mint module account, which has the 28 // permission of minting, create a "faucet" account. (@fdymylja) 29 func FundModuleAccount(bankKeeper bankkeeper.Keeper, ctx sdk.Context, recipientMod string, amounts sdk.Coins) error { 30 if err := bankKeeper.MintCoins(ctx, minttypes.ModuleName, amounts); err != nil { 31 return err 32 } 33 34 return bankKeeper.SendCoinsFromModuleToModule(ctx, minttypes.ModuleName, recipientMod, amounts) 35 }