diff --git a/tests/e2e/machine/suite.go b/tests/e2e/machine/suite.go index 21c6368..4b1de37 100644 --- a/tests/e2e/machine/suite.go +++ b/tests/e2e/machine/suite.go @@ -1,6 +1,8 @@ package machine import ( + "bytes" + "github.com/planetmint/planetmint-go/lib" clitestutil "github.com/planetmint/planetmint-go/testutil/cli" "github.com/planetmint/planetmint-go/testutil/network" @@ -12,6 +14,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keyring" sdk "github.com/cosmos/cosmos-sdk/types" txcli "github.com/cosmos/cosmos-sdk/x/auth/tx" + bank "github.com/cosmos/cosmos-sdk/x/bank/client/cli" "github.com/cosmos/cosmos-sdk/x/feegrant" e2etestutil "github.com/planetmint/planetmint-go/testutil/e2e" "github.com/stretchr/testify/assert" @@ -75,6 +78,17 @@ func (s *E2ETestSuite) TestAttestMachine() { s.Require().NoError(err) addr, _ := k.GetAddress() + // Check preAttestationBalance in order to verify that it doesn't change after machine attestation + preAttestationBalanceOutput, err := clitestutil.ExecTestCLICmd(val.ClientCtx, bank.GetBalancesCmd(), []string{ + addr.String(), + }) + s.Require().NoError(err) + preAttestationBalance, ok := preAttestationBalanceOutput.(*bytes.Buffer) + if !ok { + err = lib.ErrTypeAssertionFailed + s.Require().NoError(err) + } + machine := moduleobject.Machine(sample.Name, pubKey, prvKey, addr.String()) msg2 := machinetypes.NewMsgAttestMachine(addr.String(), &machine) out, err = e2etestutil.BuildSignBroadcastTx(s.T(), addr, msg2) @@ -104,6 +118,19 @@ func (s *E2ETestSuite) TestAttestMachine() { assert.Contains(s.T(), txResp.TxHash, txResponse.TxHash) s.Require().NoError(err) + + // Check postAttestationBalance as it should be the same as prior to the machine attestation + postAttestationBalanceOutput, err := clitestutil.ExecTestCLICmd(val.ClientCtx, bank.GetBalancesCmd(), []string{ + addr.String(), + }) + s.Require().NoError(err) + postAttestationBalance, ok := postAttestationBalanceOutput.(*bytes.Buffer) + if !ok { + err = lib.ErrTypeAssertionFailed + s.Require().NoError(err) + } + + assert.Equal(s.T(), preAttestationBalance, postAttestationBalance) } func (s *E2ETestSuite) TestInvalidAttestMachine() {