From 4120d283b1f3a7bd5837b0c0a04a95f43a7a3e73 Mon Sep 17 00:00:00 2001 From: ryanchristo <12519942+ryanchristo@users.noreply.github.com> Date: Tue, 28 Jun 2022 17:14:17 -0700 Subject: [PATCH] fix buy command tests --- x/ecocredit/client/testsuite/suite.go | 26 ++++++++++++++----- .../client/testsuite/tx_marketplace.go | 8 +++--- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/x/ecocredit/client/testsuite/suite.go b/x/ecocredit/client/testsuite/suite.go index dedde62b80..80ce572d60 100644 --- a/x/ecocredit/client/testsuite/suite.go +++ b/x/ecocredit/client/testsuite/suite.go @@ -239,9 +239,9 @@ func (s *IntegrationTestSuite) setupGenesis() { } func (s *IntegrationTestSuite) setupTestAccounts() { - // create validator account + // create secondary account info, _, err := s.val.ClientCtx.Keyring.NewMnemonic( - "validator", + "addr2", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, @@ -255,9 +255,9 @@ func (s *IntegrationTestSuite) setupTestAccounts() { // set secondary account s.addr2 = sdk.AccAddress(info.GetPubKey().Address()) - // fund the secondary account - s.fundAccount(s.val.ClientCtx, s.val.Address, s.addr2, sdk.Coins{ - sdk.NewInt64Coin(s.cfg.BondDenom, 20000000000000000), + // fund secondary account + s.fundAccount(s.val.ClientCtx, s.addr1, s.addr2, sdk.Coins{ + sdk.NewInt64Coin(s.cfg.BondDenom, 100000000), }) } @@ -270,14 +270,20 @@ func (s *IntegrationTestSuite) commonTxFlags() []string { } func (s *IntegrationTestSuite) fundAccount(clientCtx client.Context, from, to sdk.AccAddress, coins sdk.Coins) { - _, err := banktestutil.MsgSendExec( + require := s.Require() + + out, err := banktestutil.MsgSendExec( clientCtx, from, to, coins, s.commonTxFlags()..., ) - s.Require().NoError(err) + require.NoError(err) + + var res sdk.TxResponse + require.NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) + require.Zero(res.Code, res.RawLog) } func (s *IntegrationTestSuite) createClass(clientCtx client.Context, msg *core.MsgCreateClass) (classId string) { @@ -297,6 +303,8 @@ func (s *IntegrationTestSuite) createClass(clientCtx client.Context, msg *core.M var res sdk.TxResponse require.NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) + require.Zero(res.Code, res.RawLog) + for _, e := range res.Logs[0].Events { if e.Type == proto.MessageName(&core.EventCreateClass{}) { for _, attr := range e.Attributes { @@ -329,6 +337,8 @@ func (s *IntegrationTestSuite) createProject(clientCtx client.Context, msg *core var res sdk.TxResponse require.NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) + require.Zero(res.Code, res.RawLog) + for _, e := range res.Logs[0].Events { if e.Type == proto.MessageName(&core.EventCreateProject{}) { for _, attr := range e.Attributes { @@ -363,6 +373,8 @@ func (s *IntegrationTestSuite) createBatch(clientCtx client.Context, msg *core.M var res sdk.TxResponse require.NoError(clientCtx.Codec.UnmarshalJSON(out.Bytes(), &res)) + require.Zero(res.Code, res.RawLog) + for _, e := range res.Logs[0].Events { if e.Type == proto.MessageName(&core.EventCreateBatch{}) { for _, attr := range e.Attributes { diff --git a/x/ecocredit/client/testsuite/tx_marketplace.go b/x/ecocredit/client/testsuite/tx_marketplace.go index 6ead5918cc..456c401c37 100644 --- a/x/ecocredit/client/testsuite/tx_marketplace.go +++ b/x/ecocredit/client/testsuite/tx_marketplace.go @@ -275,7 +275,7 @@ func (s *IntegrationTestSuite) TestTxUpdateSellOrders() { func (s *IntegrationTestSuite) TestTxBuyDirectCmd() { require := s.Require() - buyer := s.addr1.String() + buyer := s.addr2.String() sellOrderId := fmt.Sprint(s.sellOrderId) bidPrice := sdk.NewInt64Coin(s.allowedDenoms[0], 10).String() @@ -326,7 +326,7 @@ func (s *IntegrationTestSuite) TestTxBuyDirectCmd() { "10", bidPrice, "true", - fmt.Sprintf("--%s=%s", flags.FlagFrom, s.val.Moniker), + fmt.Sprintf("--%s=%s", flags.FlagFrom, "addr2"), }, }, { @@ -364,7 +364,7 @@ func (s *IntegrationTestSuite) TestTxBuyDirectCmd() { func (s *IntegrationTestSuite) TestTxBuyDirectBatchCmd() { require := s.Require() - buyer := s.addr1.String() + buyer := s.addr2.String() bidPrice := sdk.NewInt64Coin(s.allowedDenoms[0], 10) @@ -451,7 +451,7 @@ func (s *IntegrationTestSuite) TestTxBuyDirectBatchCmd() { name: "valid from key-name", args: []string{ validJson, - fmt.Sprintf("--%s=%s", flags.FlagFrom, s.val.Moniker), + fmt.Sprintf("--%s=%s", flags.FlagFrom, "addr2"), }, }, {