diff --git a/tests/e2e/dao/gas_consumption_suite.go b/tests/e2e/dao/gas_consumption_suite.go index 737ec25..7a2a3cf 100644 --- a/tests/e2e/dao/gas_consumption_suite.go +++ b/tests/e2e/dao/gas_consumption_suite.go @@ -12,6 +12,7 @@ import ( "github.com/planetmint/planetmint-go/lib" clitestutil "github.com/planetmint/planetmint-go/testutil/cli" e2etestutil "github.com/planetmint/planetmint-go/testutil/e2e" + "github.com/planetmint/planetmint-go/testutil/moduleobject" "github.com/planetmint/planetmint-go/testutil/network" "github.com/planetmint/planetmint-go/testutil/sample" daotypes "github.com/planetmint/planetmint-go/x/dao/types" @@ -155,7 +156,7 @@ func (s *GasConsumptionE2ETestSuite) TestNetworkBasedTxGasLimit() { var msgs []sdk.Msg for i := 0; i < 1000; i++ { - mintRequest := sample.MintRequest(s.minterAddr.String(), 1, "hash"+strconv.Itoa(i)) + mintRequest := moduleobject.MintRequest(s.minterAddr.String(), 1, "hash"+strconv.Itoa(i)) msg := daotypes.NewMsgMintToken(s.minterAddr.String(), &mintRequest) msgs = append(msgs, msg) } diff --git a/tests/e2e/dao/suite.go b/tests/e2e/dao/suite.go index 184d61a..1ec8e81 100644 --- a/tests/e2e/dao/suite.go +++ b/tests/e2e/dao/suite.go @@ -21,6 +21,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/planetmint/planetmint-go/testutil/moduleobject" daotypes "github.com/planetmint/planetmint-go/x/dao/types" ) @@ -114,7 +115,7 @@ func (s *E2ETestSuite) TearDownSuite() { func (s *E2ETestSuite) TestMintToken() { val := s.network.Validators[0] - mintRequest := sample.MintRequest(s.aliceAddr.String(), 1000, "hash") + mintRequest := moduleobject.MintRequest(s.aliceAddr.String(), 1000, "hash") msg1 := daotypes.NewMsgMintToken(val.Address.String(), &mintRequest) out, err := e2etestutil.BuildSignBroadcastTx(s.T(), val.Address, msg1) s.Require().NoError(err) diff --git a/tests/e2e/machine/suite.go b/tests/e2e/machine/suite.go index 78a7d03..8b267bd 100644 --- a/tests/e2e/machine/suite.go +++ b/tests/e2e/machine/suite.go @@ -15,6 +15,8 @@ import ( e2etestutil "github.com/planetmint/planetmint-go/testutil/e2e" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" + + "github.com/planetmint/planetmint-go/testutil/moduleobject" ) // E2ETestSuite struct definition of machine suite @@ -57,7 +59,7 @@ func (s *E2ETestSuite) TestAttestMachine() { // register Ta prvKey, pubKey := sample.KeyPair() - ta := sample.TrustAnchor(pubKey) + ta := moduleobject.TrustAnchor(pubKey) msg1 := machinetypes.NewMsgRegisterTrustAnchor(val.Address.String(), &ta) out, err := e2etestutil.BuildSignBroadcastTx(s.T(), val.Address, msg1) s.Require().NoError(err) @@ -72,7 +74,7 @@ func (s *E2ETestSuite) TestAttestMachine() { s.Require().NoError(err) addr, _ := k.GetAddress() - machine := sample.Machine(sample.Name, pubKey, prvKey, addr.String()) + machine := moduleobject.Machine(sample.Name, pubKey, prvKey, addr.String()) msg2 := machinetypes.NewMsgAttestMachine(addr.String(), &machine) out, err = e2etestutil.BuildSignBroadcastTx(s.T(), addr, msg2) s.Require().NoError(err) @@ -105,7 +107,7 @@ func (s *E2ETestSuite) TestInvalidAttestMachine() { s.Require().NoError(err) addr, _ := k.GetAddress() - machine := sample.Machine(sample.Name, pubKey, prvKey, addr.String()) + machine := moduleobject.Machine(sample.Name, pubKey, prvKey, addr.String()) s.Require().NoError(err) msg := machinetypes.NewMsgAttestMachine(addr.String(), &machine) @@ -115,7 +117,7 @@ func (s *E2ETestSuite) TestInvalidAttestMachine() { s.Require().Equal(int(txResponse.Code), int(4)) unregisteredPubKey, unregisteredPrivKey := sample.KeyPair(2) - machine = sample.Machine(sample.Name, unregisteredPubKey, unregisteredPrivKey, addr.String()) + machine = moduleobject.Machine(sample.Name, unregisteredPubKey, unregisteredPrivKey, addr.String()) s.Require().NoError(err) msg = machinetypes.NewMsgAttestMachine(addr.String(), &machine) @@ -139,7 +141,7 @@ func (s *E2ETestSuite) TestMachineAllowanceAttestation() { // register TA prvKey, pubKey := sample.KeyPair(3) - ta := sample.TrustAnchor(pubKey) + ta := moduleobject.TrustAnchor(pubKey) msg1 := machinetypes.NewMsgRegisterTrustAnchor(val.Address.String(), &ta) _, err = e2etestutil.BuildSignBroadcastTx(s.T(), val.Address, msg1) s.Require().NoError(err) @@ -163,7 +165,7 @@ func (s *E2ETestSuite) TestMachineAllowanceAttestation() { s.Require().NoError(s.network.WaitForNextBlock()) // attest machine with fee granter without funding the machine account first - machine := sample.Machine(sample.Name, pubKey, prvKey, addr.String()) + machine := moduleobject.Machine(sample.Name, pubKey, prvKey, addr.String()) s.Require().NoError(err) // name and address of private key with which to sign diff --git a/testutil/e2e/e2e.go b/testutil/e2e/e2e.go index d3f5146..c914a2b 100644 --- a/testutil/e2e/e2e.go +++ b/testutil/e2e/e2e.go @@ -10,6 +10,7 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/planetmint/planetmint-go/lib" clitestutil "github.com/planetmint/planetmint-go/testutil/cli" + moduleobjects "github.com/planetmint/planetmint-go/testutil/moduleobject" "github.com/planetmint/planetmint-go/testutil/network" "github.com/planetmint/planetmint-go/testutil/sample" machinetypes "github.com/planetmint/planetmint-go/x/machine/types" @@ -75,8 +76,7 @@ func AttestMachine(network *network.Network, name string, mnemonic string, num i // register Ta prvKey, pubKey := sample.KeyPair(num) - - ta := sample.TrustAnchor(pubKey) + ta := moduleobjects.TrustAnchor(pubKey) registerMsg := machinetypes.NewMsgRegisterTrustAnchor(val.Address.String(), &ta) _, err = lib.BroadcastTxWithFileLock(val.Address, registerMsg) if err != nil { @@ -92,7 +92,7 @@ func AttestMachine(network *network.Network, name string, mnemonic string, num i return err } - machine := sample.Machine(name, pubKey, prvKey, addr.String()) + machine := moduleobjects.Machine(name, pubKey, prvKey, addr.String()) attestMsg := machinetypes.NewMsgAttestMachine(addr.String(), &machine) _, err = lib.BroadcastTxWithFileLock(addr, attestMsg) if err != nil { diff --git a/testutil/sample/error.go b/testutil/errormsg/error.go similarity index 74% rename from testutil/sample/error.go rename to testutil/errormsg/error.go index 0ae8bf4..94eb7b1 100644 --- a/testutil/sample/error.go +++ b/testutil/errormsg/error.go @@ -1,4 +1,4 @@ -package sample +package errormsg var ( ErrorInvalidAddress = "invalid_address" diff --git a/testutil/keeper/asset.go b/testutil/keeper/asset.go index 55e1822..2326da9 100644 --- a/testutil/keeper/asset.go +++ b/testutil/keeper/asset.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/planetmint/planetmint-go/config" + "github.com/planetmint/planetmint-go/testutil/moduleobject" "github.com/planetmint/planetmint-go/testutil/sample" "github.com/planetmint/planetmint-go/x/asset/keeper" "github.com/planetmint/planetmint-go/x/asset/types" @@ -49,15 +50,15 @@ func AssetKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { ctrl := gomock.NewController(t) mk := assettestutils.NewMockMachineKeeper(ctrl) sk, pk := sample.KeyPair() - _, ppk := sample.ExtendedKeyPair(config.PlmntNetParams) - _, lpk := sample.ExtendedKeyPair(config.LiquidNetParams) + _, ppk := moduleobject.ExtendedKeyPair(config.PlmntNetParams) + _, lpk := moduleobject.ExtendedKeyPair(config.LiquidNetParams) - id := sample.MachineIndex(pk, ppk, lpk) + id := moduleobject.MachineIndex(pk, ppk, lpk) mk.EXPECT().GetMachineIndexByPubKey(ctx, pk).Return(id, true).AnyTimes() mk.EXPECT().GetMachineIndexByPubKey(ctx, ppk).Return(id, true).AnyTimes() mk.EXPECT().GetMachineIndexByPubKey(ctx, sk).Return(id, false).AnyTimes() - mk.EXPECT().GetMachine(ctx, id).Return(sample.Machine(pk, pk, sk, ""), true).AnyTimes() - mk.EXPECT().GetMachine(ctx, sk).Return(sample.Machine(pk, pk, sk, ""), false).AnyTimes() + mk.EXPECT().GetMachine(ctx, id).Return(moduleobject.Machine(pk, pk, sk, ""), true).AnyTimes() + mk.EXPECT().GetMachine(ctx, sk).Return(moduleobject.Machine(pk, pk, sk, ""), false).AnyTimes() k := keeper.NewKeeper( cdc, diff --git a/testutil/moduleobject/sampleobject.go b/testutil/moduleobject/sampleobject.go new file mode 100644 index 0000000..63778df --- /dev/null +++ b/testutil/moduleobject/sampleobject.go @@ -0,0 +1,98 @@ +package moduleobject + +import ( + "encoding/hex" + + "github.com/btcsuite/btcd/btcutil/hdkeychain" + "github.com/btcsuite/btcd/chaincfg" + "github.com/planetmint/planetmint-go/config" + "github.com/planetmint/planetmint-go/testutil/sample" + daotypes "github.com/planetmint/planetmint-go/x/dao/types" + machinetypes "github.com/planetmint/planetmint-go/x/machine/types" + + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + "github.com/cosmos/go-bip39" +) + +func ExtendedKeyPair(cfg chaincfg.Params) (string, string) { + seed, err := bip39.NewSeedWithErrorChecking(sample.Mnemonic, keyring.DefaultBIP39Passphrase) + if err != nil { + panic(err) + } + xprivKey, err := hdkeychain.NewMaster(seed, &cfg) + if err != nil { + panic(err) + } + xpubKey, err := xprivKey.Neuter() + if err != nil { + panic(err) + } + return xprivKey.String(), xpubKey.String() +} + +// Machine creates a new machine object +// TODO: make address deterministic for test cases +func Machine(name, pubKey string, prvKey string, address string) machinetypes.Machine { + metadata := Metadata() + _, liquidPubKey := ExtendedKeyPair(config.LiquidNetParams) + _, planetmintPubKey := ExtendedKeyPair(config.PlmntNetParams) + + prvKeyBytes, _ := hex.DecodeString(prvKey) + sk := &secp256k1.PrivKey{Key: prvKeyBytes} + pubKeyBytes, _ := hex.DecodeString(pubKey) + sign, _ := sk.Sign(pubKeyBytes) + signatureHex := hex.EncodeToString(sign) + + if address == "" { + address = sample.Secp256k1AccAddress().String() + } + + m := machinetypes.Machine{ + Name: name, + Ticker: name + "_ticker", + Domain: "lab.r3c.network", + Reissue: true, + Amount: 1000, + Precision: 8, + IssuerPlanetmint: planetmintPubKey, + IssuerLiquid: liquidPubKey, + MachineId: pubKey, + Metadata: &metadata, + Type: 1, + MachineIdSignature: signatureHex, + Address: address, + } + return m +} + +func MachineIndex(pubKey string, planetmintPubKey string, liquidPubKey string) machinetypes.MachineIndex { + return machinetypes.MachineIndex{ + MachineId: pubKey, + IssuerPlanetmint: planetmintPubKey, + IssuerLiquid: liquidPubKey, + } +} + +func Metadata() machinetypes.Metadata { + return machinetypes.Metadata{ + Gps: "{\"Latitude\":\"-48.876667\",\"Longitude\":\"-123.393333\"}", + Device: "{\"Manufacturer\": \"RDDL\",\"Serial\":\"AdnT2uyt\"}", + AssetDefinition: "{\"Version\": \"0.1\"}", + AdditionalDataCID: "CID", + } +} + +func TrustAnchor(pubkey string) machinetypes.TrustAnchor { + return machinetypes.TrustAnchor{ + Pubkey: pubkey, + } +} + +func MintRequest(beneficiaryAddr string, amount uint64, txhash string) daotypes.MintRequest { + return daotypes.MintRequest{ + Beneficiary: beneficiaryAddr, + Amount: amount, + LiquidTxHash: txhash, + } +} diff --git a/testutil/sample/sample.go b/testutil/sample/sample.go index 6e3d2a3..0bbf381 100644 --- a/testutil/sample/sample.go +++ b/testutil/sample/sample.go @@ -4,10 +4,6 @@ import ( "encoding/hex" "fmt" - "github.com/planetmint/planetmint-go/config" - daotypes "github.com/planetmint/planetmint-go/x/dao/types" - machinetypes "github.com/planetmint/planetmint-go/x/machine/types" - "github.com/btcsuite/btcd/btcutil/hdkeychain" "github.com/btcsuite/btcd/chaincfg" "github.com/cosmos/cosmos-sdk/crypto/keyring" @@ -60,58 +56,6 @@ func Secp256k1AccAddress() sdk.AccAddress { return sdk.AccAddress(addr) } -// Machine creates a new machine object -// TODO: make address deterministic for test cases -func Machine(name, pubKey string, prvKey string, address string) machinetypes.Machine { - metadata := Metadata() - _, liquidPubKey := ExtendedKeyPair(config.LiquidNetParams) - _, planetmintPubKey := ExtendedKeyPair(config.PlmntNetParams) - - prvKeyBytes, _ := hex.DecodeString(prvKey) - sk := &secp256k1.PrivKey{Key: prvKeyBytes} - pubKeyBytes, _ := hex.DecodeString(pubKey) - sign, _ := sk.Sign(pubKeyBytes) - signatureHex := hex.EncodeToString(sign) - - if address == "" { - address = Secp256k1AccAddress().String() - } - - m := machinetypes.Machine{ - Name: name, - Ticker: name + "_ticker", - Domain: "lab.r3c.network", - Reissue: true, - Amount: 1000, - Precision: 8, - IssuerPlanetmint: planetmintPubKey, - IssuerLiquid: liquidPubKey, - MachineId: pubKey, - Metadata: &metadata, - Type: 1, - MachineIdSignature: signatureHex, - Address: address, - } - return m -} - -func MachineIndex(pubKey string, planetmintPubKey string, liquidPubKey string) machinetypes.MachineIndex { - return machinetypes.MachineIndex{ - MachineId: pubKey, - IssuerPlanetmint: planetmintPubKey, - IssuerLiquid: liquidPubKey, - } -} - -func Metadata() machinetypes.Metadata { - return machinetypes.Metadata{ - Gps: "{\"Latitude\":\"-48.876667\",\"Longitude\":\"-123.393333\"}", - Device: "{\"Manufacturer\": \"RDDL\",\"Serial\":\"AdnT2uyt\"}", - AssetDefinition: "{\"Version\": \"0.1\"}", - AdditionalDataCID: "CID", - } -} - func Asset() string { cid := "cid0" return cid @@ -132,17 +76,3 @@ func ExtendedKeyPair(cfg chaincfg.Params) (string, string) { } return xprivKey.String(), xpubKey.String() } - -func TrustAnchor(pubkey string) machinetypes.TrustAnchor { - return machinetypes.TrustAnchor{ - Pubkey: pubkey, - } -} - -func MintRequest(beneficiaryAddr string, amount uint64, txhash string) daotypes.MintRequest { - return daotypes.MintRequest{ - Beneficiary: beneficiaryAddr, - Amount: amount, - LiquidTxHash: txhash, - } -} diff --git a/util/rddl_token_test.go b/util/rddl_token_test.go index be91dd2..f4e7605 100644 --- a/util/rddl_token_test.go +++ b/util/rddl_token_test.go @@ -6,7 +6,9 @@ import ( "gotest.tools/assert" ) -var rddlTokenAmount string = "998.85844748" +const ( + rddlTokenAmount string = "998.85844748" +) func Test2FloatConvertion(t *testing.T) { t.Parallel() diff --git a/x/asset/types/message_notarize_asset_test.go b/x/asset/types/message_notarize_asset_test.go index e27ae8e..cf8e7ae 100644 --- a/x/asset/types/message_notarize_asset_test.go +++ b/x/asset/types/message_notarize_asset_test.go @@ -3,7 +3,7 @@ package types import ( "testing" - "github.com/planetmint/planetmint-go/testutil/sample" + "github.com/planetmint/planetmint-go/testutil/errormsg" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/stretchr/testify/require" @@ -19,14 +19,9 @@ func TestMsgNotarizeAssetValidateBasic(t *testing.T) { { name: "invalid address", msg: MsgNotarizeAsset{ - Creator: sample.ErrorInvalidAddress, + Creator: errormsg.ErrorInvalidAddress, }, err: sdkerrors.ErrInvalidAddress, - }, { - name: "valid address", - msg: MsgNotarizeAsset{ - Creator: sample.AccAddress(), - }, }, } for _, tt := range tests { diff --git a/x/dao/keeper/msg_server_test.go b/x/dao/keeper/msg_server_test.go index be230d5..e9ecdca 100644 --- a/x/dao/keeper/msg_server_test.go +++ b/x/dao/keeper/msg_server_test.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" keepertest "github.com/planetmint/planetmint-go/testutil/keeper" + "github.com/planetmint/planetmint-go/testutil/moduleobject" "github.com/planetmint/planetmint-go/testutil/sample" "github.com/planetmint/planetmint-go/x/dao/keeper" "github.com/planetmint/planetmint-go/x/dao/types" @@ -170,7 +171,7 @@ func TestMsgServerMintToken(t *testing.T) { t.Parallel() minter := sample.AccAddress() beneficiary := sample.ConstBech32Addr - mintRequest := sample.MintRequest(beneficiary, 1000, "hash") + mintRequest := moduleobject.MintRequest(beneficiary, 1000, "hash") msg := types.NewMsgMintToken(minter, &mintRequest) msgServer, ctx, _ := setupMsgServer(t) @@ -190,7 +191,7 @@ func TestMsgServerMintTokenInvalidAddress(t *testing.T) { t.Parallel() minter := sample.AccAddress() beneficiary := "invalid address" - mintRequest := sample.MintRequest(beneficiary, 1000, "hash") + mintRequest := moduleobject.MintRequest(beneficiary, 1000, "hash") msg := types.NewMsgMintToken(minter, &mintRequest) msgServer, ctx, _ := setupMsgServer(t) diff --git a/x/dao/types/message_init_pop_test.go b/x/dao/types/message_init_pop_test.go index 604d596..1b1119f 100644 --- a/x/dao/types/message_init_pop_test.go +++ b/x/dao/types/message_init_pop_test.go @@ -4,7 +4,7 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/planetmint/planetmint-go/testutil/sample" + "github.com/planetmint/planetmint-go/testutil/errormsg" "github.com/stretchr/testify/require" ) @@ -18,7 +18,7 @@ func TestMsgInitPop_ValidateBasic(t *testing.T) { { name: "invalid address", msg: MsgInitPop{ - Creator: sample.ErrorInvalidAddress, + Creator: errormsg.ErrorInvalidAddress, }, err: sdkerrors.ErrInvalidAddress, }, diff --git a/x/dao/types/message_mint_token_test.go b/x/dao/types/message_mint_token_test.go index 68e927f..436f3f1 100644 --- a/x/dao/types/message_mint_token_test.go +++ b/x/dao/types/message_mint_token_test.go @@ -4,7 +4,7 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/planetmint/planetmint-go/testutil/sample" + "github.com/planetmint/planetmint-go/testutil/errormsg" "github.com/stretchr/testify/require" ) @@ -18,7 +18,7 @@ func TestMsgMintToken_ValidateBasic(t *testing.T) { { name: "invalid address", msg: MsgMintToken{ - Creator: sample.ErrorInvalidAddress, + Creator: errormsg.ErrorInvalidAddress, }, err: sdkerrors.ErrInvalidAddress, }, diff --git a/x/dao/types/message_update_params_test.go b/x/dao/types/message_update_params_test.go index 5d12232..90f4217 100644 --- a/x/dao/types/message_update_params_test.go +++ b/x/dao/types/message_update_params_test.go @@ -4,7 +4,7 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/planetmint/planetmint-go/testutil/sample" + "github.com/planetmint/planetmint-go/testutil/errormsg" "github.com/stretchr/testify/require" ) @@ -18,7 +18,7 @@ func TestMsgUpdateParams_ValidateBasic(t *testing.T) { { name: "invalid address", msg: MsgUpdateParams{ - Authority: sample.ErrorInvalidAddress, + Authority: errormsg.ErrorInvalidAddress, }, err: sdkerrors.ErrInvalidAddress, }, diff --git a/x/dao/types/messages_redeem_claim_test.go b/x/dao/types/messages_redeem_claim_test.go index baf789e..88f0dab 100644 --- a/x/dao/types/messages_redeem_claim_test.go +++ b/x/dao/types/messages_redeem_claim_test.go @@ -4,7 +4,7 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/planetmint/planetmint-go/testutil/sample" + "github.com/planetmint/planetmint-go/testutil/errormsg" "github.com/stretchr/testify/require" ) @@ -18,7 +18,7 @@ func TestMsgCreateRedeemClaim_ValidateBasic(t *testing.T) { { name: "invalid address", msg: MsgCreateRedeemClaim{ - Creator: sample.ErrorInvalidAddress, + Creator: errormsg.ErrorInvalidAddress, }, err: sdkerrors.ErrInvalidAddress, }, @@ -47,7 +47,7 @@ func TestMsgUpdateRedeemClaim_ValidateBasic(t *testing.T) { { name: "invalid address", msg: MsgUpdateRedeemClaim{ - Creator: sample.ErrorInvalidAddress, + Creator: errormsg.ErrorInvalidAddress, }, err: sdkerrors.ErrInvalidAddress, }, @@ -76,7 +76,7 @@ func TestMsgConfirmRedeemClaim_ValidateBasic(t *testing.T) { { name: "invalid address", msg: MsgConfirmRedeemClaim{ - Creator: sample.ErrorInvalidAddress, + Creator: errormsg.ErrorInvalidAddress, }, err: sdkerrors.ErrInvalidAddress, }, diff --git a/x/machine/keeper/msg_server_test.go b/x/machine/keeper/msg_server_test.go index 938063a..73dd467 100644 --- a/x/machine/keeper/msg_server_test.go +++ b/x/machine/keeper/msg_server_test.go @@ -5,6 +5,7 @@ import ( "testing" keepertest "github.com/planetmint/planetmint-go/testutil/keeper" + "github.com/planetmint/planetmint-go/testutil/moduleobject" "github.com/planetmint/planetmint-go/x/machine/keeper" "github.com/planetmint/planetmint-go/x/machine/types" @@ -30,9 +31,9 @@ func TestMsgServer(t *testing.T) { func TestMsgServerAttestMachine(t *testing.T) { t.Parallel() sk, pk := sample.KeyPair() - ta := sample.TrustAnchor(pk) + ta := moduleobject.TrustAnchor(pk) taMsg := types.NewMsgRegisterTrustAnchor(pk, &ta) - machine := sample.Machine(pk, pk, sk, "") + machine := moduleobject.Machine(pk, pk, sk, "") msg := types.NewMsgAttestMachine(pk, &machine) msgServer, ctx := setupMsgServer(t) _, err := msgServer.RegisterTrustAnchor(ctx, taMsg) @@ -46,9 +47,9 @@ func TestMsgServerAttestMachine(t *testing.T) { func TestMsgServerAttestMachineInvalidLiquidKey(t *testing.T) { t.Parallel() sk, pk := sample.KeyPair() - ta := sample.TrustAnchor(pk) + ta := moduleobject.TrustAnchor(pk) taMsg := types.NewMsgRegisterTrustAnchor(pk, &ta) - machine := sample.Machine(pk, pk, sk, "") + machine := moduleobject.Machine(pk, pk, sk, "") machine.IssuerLiquid = "invalidkey" msg := types.NewMsgAttestMachine(pk, &machine) msgServer, ctx := setupMsgServer(t) @@ -61,7 +62,7 @@ func TestMsgServerAttestMachineInvalidLiquidKey(t *testing.T) { func TestMsgServerRegisterTrustAnchor(t *testing.T) { t.Parallel() _, pk := sample.KeyPair() - ta := sample.TrustAnchor(pk) + ta := moduleobject.TrustAnchor(pk) msg := types.NewMsgRegisterTrustAnchor(pk, &ta) msgServer, ctx := setupMsgServer(t) res, err := msgServer.RegisterTrustAnchor(ctx, msg) @@ -73,7 +74,7 @@ func TestMsgServerRegisterTrustAnchor(t *testing.T) { func TestMsgServerRegisterTrustAnchorTwice(t *testing.T) { t.Parallel() _, pk := sample.KeyPair() - ta := sample.TrustAnchor(pk) + ta := moduleobject.TrustAnchor(pk) msg := types.NewMsgRegisterTrustAnchor(pk, &ta) msgServer, ctx := setupMsgServer(t) res, err := msgServer.RegisterTrustAnchor(ctx, msg) diff --git a/x/machine/types/message_attest_machine_test.go b/x/machine/types/message_attest_machine_test.go index b34a5f4..3eb2f51 100644 --- a/x/machine/types/message_attest_machine_test.go +++ b/x/machine/types/message_attest_machine_test.go @@ -4,7 +4,7 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/planetmint/planetmint-go/testutil/sample" + "github.com/planetmint/planetmint-go/testutil/errormsg" "github.com/stretchr/testify/require" ) @@ -18,7 +18,7 @@ func TestMsgAttestMachineValidateBasic(t *testing.T) { { name: "invalid address", msg: MsgAttestMachine{ - Creator: sample.ErrorInvalidAddress, + Creator: errormsg.ErrorInvalidAddress, }, err: sdkerrors.ErrInvalidAddress, }, diff --git a/x/machine/types/message_register_trust_anchor_test.go b/x/machine/types/message_register_trust_anchor_test.go index 9f10207..f348711 100644 --- a/x/machine/types/message_register_trust_anchor_test.go +++ b/x/machine/types/message_register_trust_anchor_test.go @@ -4,7 +4,7 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/planetmint/planetmint-go/testutil/sample" + "github.com/planetmint/planetmint-go/testutil/errormsg" "github.com/stretchr/testify/require" ) @@ -18,7 +18,7 @@ func TestMsgRegisterTrustAnchor_ValidateBasic(t *testing.T) { { name: "invalid address", msg: MsgRegisterTrustAnchor{ - Creator: sample.ErrorInvalidAddress, + Creator: errormsg.ErrorInvalidAddress, }, err: sdkerrors.ErrInvalidAddress, }, diff --git a/x/machine/types/message_update_params_test.go b/x/machine/types/message_update_params_test.go index 5d12232..90f4217 100644 --- a/x/machine/types/message_update_params_test.go +++ b/x/machine/types/message_update_params_test.go @@ -4,7 +4,7 @@ import ( "testing" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/planetmint/planetmint-go/testutil/sample" + "github.com/planetmint/planetmint-go/testutil/errormsg" "github.com/stretchr/testify/require" ) @@ -18,7 +18,7 @@ func TestMsgUpdateParams_ValidateBasic(t *testing.T) { { name: "invalid address", msg: MsgUpdateParams{ - Authority: sample.ErrorInvalidAddress, + Authority: errormsg.ErrorInvalidAddress, }, err: sdkerrors.ErrInvalidAddress, },