mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-11-27 15:53:41 +00:00
test: add balance check to machine attestation e2e test
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
63649c868c
commit
7c6e30d4d1
@ -1,6 +1,8 @@
|
|||||||
package machine
|
package machine
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
|
||||||
"github.com/planetmint/planetmint-go/lib"
|
"github.com/planetmint/planetmint-go/lib"
|
||||||
clitestutil "github.com/planetmint/planetmint-go/testutil/cli"
|
clitestutil "github.com/planetmint/planetmint-go/testutil/cli"
|
||||||
"github.com/planetmint/planetmint-go/testutil/network"
|
"github.com/planetmint/planetmint-go/testutil/network"
|
||||||
@ -12,6 +14,7 @@ import (
|
|||||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
txcli "github.com/cosmos/cosmos-sdk/x/auth/tx"
|
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"
|
"github.com/cosmos/cosmos-sdk/x/feegrant"
|
||||||
e2etestutil "github.com/planetmint/planetmint-go/testutil/e2e"
|
e2etestutil "github.com/planetmint/planetmint-go/testutil/e2e"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@ -75,6 +78,17 @@ func (s *E2ETestSuite) TestAttestMachine() {
|
|||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
addr, _ := k.GetAddress()
|
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())
|
machine := moduleobject.Machine(sample.Name, pubKey, prvKey, addr.String())
|
||||||
msg2 := machinetypes.NewMsgAttestMachine(addr.String(), &machine)
|
msg2 := machinetypes.NewMsgAttestMachine(addr.String(), &machine)
|
||||||
out, err = e2etestutil.BuildSignBroadcastTx(s.T(), addr, msg2)
|
out, err = e2etestutil.BuildSignBroadcastTx(s.T(), addr, msg2)
|
||||||
@ -104,6 +118,19 @@ func (s *E2ETestSuite) TestAttestMachine() {
|
|||||||
|
|
||||||
assert.Contains(s.T(), txResp.TxHash, txResponse.TxHash)
|
assert.Contains(s.T(), txResp.TxHash, txResponse.TxHash)
|
||||||
s.Require().NoError(err)
|
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() {
|
func (s *E2ETestSuite) TestInvalidAttestMachine() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user