mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-03-30 15:08:28 +00:00
add to asset e2e test suite
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
5c82451c09
commit
b7c177aa46
2
go.mod
2
go.mod
@ -4,6 +4,7 @@ go 1.19
|
||||
|
||||
require (
|
||||
cosmossdk.io/api v0.3.1
|
||||
cosmossdk.io/errors v1.0.0-beta.7
|
||||
github.com/cometbft/cometbft v0.37.1
|
||||
github.com/cometbft/cometbft-db v0.7.0
|
||||
github.com/cosmos/cosmos-sdk v0.47.3
|
||||
@ -31,7 +32,6 @@ require (
|
||||
cloud.google.com/go/storage v1.29.0 // indirect
|
||||
cosmossdk.io/core v0.5.1 // indirect
|
||||
cosmossdk.io/depinject v1.0.0-alpha.3 // indirect
|
||||
cosmossdk.io/errors v1.0.0-beta.7 // indirect
|
||||
cosmossdk.io/log v1.1.0 // indirect
|
||||
cosmossdk.io/math v1.0.1 // indirect
|
||||
cosmossdk.io/tools/rosetta v0.2.1 // indirect
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"planetmint-go/testutil/network"
|
||||
"planetmint-go/testutil/sample"
|
||||
|
||||
clitestutil "planetmint-go/testutil/cli"
|
||||
assetcli "planetmint-go/x/asset/client/cli"
|
||||
@ -80,7 +81,6 @@ func (s *E2ETestSuite) SetupSuite() {
|
||||
s.Require().NoError(err)
|
||||
|
||||
args = []string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagChainID, s.network.Config.ChainID),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, "machine"),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, "2stake"),
|
||||
"--yes",
|
||||
@ -89,6 +89,7 @@ func (s *E2ETestSuite) SetupSuite() {
|
||||
|
||||
_, err = clitestutil.ExecTestCLICmd(val.ClientCtx, machinecli.CmdAttestMachine(), args)
|
||||
s.Require().NoError(err)
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
}
|
||||
|
||||
// Tear down machine E2ETestSuite
|
||||
@ -99,15 +100,65 @@ func (s *E2ETestSuite) TearDownSuite() {
|
||||
func (s *E2ETestSuite) TestNotarizeAsset() {
|
||||
val := s.network.Validators[0]
|
||||
|
||||
args := []string{
|
||||
// TODO: add cid-hash and signature
|
||||
pubKey,
|
||||
fmt.Sprintf("--%s=%s", flags.FlagChainID, s.network.Config.ChainID),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, "machine"),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, "2stake"),
|
||||
"--yes",
|
||||
sk, pk := sample.KeyPair()
|
||||
cid, signature := sample.Asset(sk, pk)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
expErr bool
|
||||
errMsg string
|
||||
}{
|
||||
{
|
||||
"machine not found",
|
||||
[]string{
|
||||
cid,
|
||||
signature,
|
||||
pk,
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, "machine"),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, "2stake"),
|
||||
"--yes",
|
||||
},
|
||||
true,
|
||||
"machine not found",
|
||||
},
|
||||
{
|
||||
"invalid signature",
|
||||
[]string{
|
||||
"cid",
|
||||
"signature",
|
||||
pubKey,
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, "machine"),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, "2stake"),
|
||||
"--yes",
|
||||
},
|
||||
true,
|
||||
"invalid signature",
|
||||
},
|
||||
{
|
||||
"valid notarization",
|
||||
[]string{
|
||||
// TODO: Create Valid Inputs
|
||||
cid,
|
||||
signature,
|
||||
pubKey,
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, "machine"),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, "2stake"),
|
||||
"--yes",
|
||||
},
|
||||
false,
|
||||
"",
|
||||
},
|
||||
}
|
||||
|
||||
_, err := clitestutil.ExecTestCLICmd(val.ClientCtx, assetcli.CmdNotarizeAsset(), args)
|
||||
s.Require().NoError(err)
|
||||
for _, tc := range testCases {
|
||||
out, err := clitestutil.ExecTestCLICmd(val.ClientCtx, assetcli.CmdNotarizeAsset(), tc.args)
|
||||
if tc.expErr {
|
||||
s.Require().Error(err)
|
||||
s.Require().Contains(err.Error(), tc.errMsg)
|
||||
} else {
|
||||
s.Require().NoError(err)
|
||||
s.T().Log(out)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,9 +6,8 @@ import (
|
||||
"planetmint-go/testutil"
|
||||
machinetypes "planetmint-go/x/machine/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
|
||||
|
Loading…
x
Reference in New Issue
Block a user