package auction import ( "fmt" "cosmossdk.io/math" "github.com/stretchr/testify/suite" "github.com/cosmos/cosmos-sdk/client/flags" addresscodec "github.com/cosmos/cosmos-sdk/codec/address" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" sdk "github.com/cosmos/cosmos-sdk/types" ) var ( ownerAccount = "owner" bidderAccount = "bidder" ownerAddress string bidderAddress string ) type E2ETestSuite struct { suite.Suite cfg network.Config network *network.Network } func NewE2ETestSuite(cfg network.Config) *E2ETestSuite { return &E2ETestSuite{cfg: cfg} } func (s *E2ETestSuite) SetupSuite() { //nolint: all s.T().Log("setting up e2e test suite") var err error s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg) s.Require().NoError(err) _, err = s.network.WaitForHeight(1) s.Require().NoError(err) // setting up random owner and bidder accounts s.createAccountWithBalance(ownerAccount, &ownerAddress) s.createAccountWithBalance(bidderAccount, &bidderAddress) // s.defaultAuctionID = s.createAuctionAndBid(true, false) } func (s *E2ETestSuite) createAccountWithBalance(accountName string, accountAddress *string) { val := s.network.Validators[0] sr := s.Require() info, _, err := val.ClientCtx.Keyring.NewMnemonic(accountName, keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1) sr.NoError(err) newAddr, _ := info.GetAddress() _, err = clitestutil.MsgSendExec( val.ClientCtx, val.Address, newAddr, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, math.NewInt(200000))), addresscodec.NewBech32Codec("laconic"), fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=json", flags.FlagOutput), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, math.NewInt(10))).String()), ) sr.NoError(err) *accountAddress = newAddr.String() }