mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-06-07 14:46:39 +00:00
[tests] Use sample.Machine()
Signed-off-by: Julian Strobl <jmastr@mailbox.org>
This commit is contained in:
parent
5a435575b5
commit
18ce58f139
@ -14,8 +14,6 @@ import (
|
|||||||
|
|
||||||
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
|
||||||
|
|
||||||
machinetypes "planetmint-go/x/machine/types"
|
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
"github.com/cosmos/cosmos-sdk/crypto/hd"
|
||||||
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
"github.com/cosmos/cosmos-sdk/crypto/keyring"
|
||||||
@ -72,20 +70,7 @@ func (s *E2ETestSuite) SetupSuite() {
|
|||||||
|
|
||||||
s.Require().NoError(s.network.WaitForNextBlock())
|
s.Require().NoError(s.network.WaitForNextBlock())
|
||||||
|
|
||||||
machine := machinetypes.Machine{
|
machine := sample.Machine("machine", pkHex)
|
||||||
Name: "machine",
|
|
||||||
Ticker: "machine_ticker",
|
|
||||||
Issued: 1,
|
|
||||||
Amount: 1000,
|
|
||||||
Precision: 8,
|
|
||||||
IssuerPlanetmint: pkHex,
|
|
||||||
IssuerLiquid: pkHex,
|
|
||||||
MachineId: pkHex,
|
|
||||||
Metadata: &machinetypes.Metadata{
|
|
||||||
AdditionalDataCID: "CID",
|
|
||||||
Gps: "{\"Latitude\":\"-48.876667\",\"Longitude\":\"-123.393333\"}",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
machineJSON, err := json.Marshal(&machine)
|
machineJSON, err := json.Marshal(&machine)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package machine
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"planetmint-go/testutil"
|
"planetmint-go/testutil"
|
||||||
|
"planetmint-go/testutil/sample"
|
||||||
machinetypes "planetmint-go/x/machine/types"
|
machinetypes "planetmint-go/x/machine/types"
|
||||||
|
|
||||||
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
|
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
|
||||||
@ -20,21 +21,7 @@ func (s *E2ETestSuite) TestAttestMachineREST() {
|
|||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
// Create Attest Machine TX
|
// Create Attest Machine TX
|
||||||
machine := machinetypes.Machine{
|
machine := sample.Machine("machine", pubKey)
|
||||||
Name: "machine",
|
|
||||||
Ticker: "machine_ticker",
|
|
||||||
Issued: 1,
|
|
||||||
Amount: 1000,
|
|
||||||
Precision: 8,
|
|
||||||
IssuerPlanetmint: pubKey,
|
|
||||||
IssuerLiquid: pubKey,
|
|
||||||
MachineId: pubKey,
|
|
||||||
Metadata: &machinetypes.Metadata{
|
|
||||||
AdditionalDataCID: "CID",
|
|
||||||
Gps: "{\"Latitude\":\"-48.876667\",\"Longitude\":\"-123.393333\"}",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
msg := machinetypes.MsgAttestMachine{
|
msg := machinetypes.MsgAttestMachine{
|
||||||
Creator: addr.String(),
|
Creator: addr.String(),
|
||||||
Machine: &machine,
|
Machine: &machine,
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
clitestutil "planetmint-go/testutil/cli"
|
clitestutil "planetmint-go/testutil/cli"
|
||||||
"planetmint-go/testutil/network"
|
"planetmint-go/testutil/network"
|
||||||
|
"planetmint-go/testutil/sample"
|
||||||
machinecli "planetmint-go/x/machine/client/cli"
|
machinecli "planetmint-go/x/machine/client/cli"
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
@ -13,8 +14,6 @@ import (
|
|||||||
bank "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
|
bank "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
|
||||||
"github.com/stretchr/testify/suite"
|
"github.com/stretchr/testify/suite"
|
||||||
|
|
||||||
machinetypes "planetmint-go/x/machine/types"
|
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -71,20 +70,7 @@ func (s *E2ETestSuite) TearDownSuite() {
|
|||||||
func (s *E2ETestSuite) TestAttestMachine() {
|
func (s *E2ETestSuite) TestAttestMachine() {
|
||||||
val := s.network.Validators[0]
|
val := s.network.Validators[0]
|
||||||
|
|
||||||
machine := machinetypes.Machine{
|
machine := sample.Machine("machine", pubKey)
|
||||||
Name: "machine",
|
|
||||||
Ticker: "machine_ticker",
|
|
||||||
Issued: 1,
|
|
||||||
Amount: 1000,
|
|
||||||
Precision: 8,
|
|
||||||
IssuerPlanetmint: pubKey,
|
|
||||||
IssuerLiquid: pubKey,
|
|
||||||
MachineId: pubKey,
|
|
||||||
Metadata: &machinetypes.Metadata{
|
|
||||||
AdditionalDataCID: "CID",
|
|
||||||
Gps: "{\"Latitude\":\"-48.876667\",\"Longitude\":\"-123.393333\"}",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
machineJSON, err := json.Marshal(&machine)
|
machineJSON, err := json.Marshal(&machine)
|
||||||
s.Require().NoError(err)
|
s.Require().NoError(err)
|
||||||
|
|
||||||
|
@ -48,11 +48,11 @@ func AssetKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
|
|||||||
ctrl := gomock.NewController(t)
|
ctrl := gomock.NewController(t)
|
||||||
mk := assettestutils.NewMockMachineKeeper(ctrl)
|
mk := assettestutils.NewMockMachineKeeper(ctrl)
|
||||||
sk, pk := sample.KeyPair()
|
sk, pk := sample.KeyPair()
|
||||||
id := sample.MachineIndex(pk, pk, pk)
|
id := sample.MachineIndex(pk)
|
||||||
mk.EXPECT().GetMachineIndex(ctx, pk).Return(id, true).AnyTimes()
|
mk.EXPECT().GetMachineIndex(ctx, pk).Return(id, true).AnyTimes()
|
||||||
mk.EXPECT().GetMachineIndex(ctx, sk).Return(id, false).AnyTimes()
|
mk.EXPECT().GetMachineIndex(ctx, sk).Return(id, false).AnyTimes()
|
||||||
mk.EXPECT().GetMachine(ctx, id).Return(sample.Machine(pk, pk, pk), true).AnyTimes()
|
mk.EXPECT().GetMachine(ctx, id).Return(sample.Machine(pk, pk), true).AnyTimes()
|
||||||
mk.EXPECT().GetMachine(ctx, sk).Return(sample.Machine(pk, pk, pk), false).AnyTimes()
|
mk.EXPECT().GetMachine(ctx, sk).Return(sample.Machine(pk, pk), false).AnyTimes()
|
||||||
|
|
||||||
k := keeper.NewKeeper(
|
k := keeper.NewKeeper(
|
||||||
cdc,
|
cdc,
|
||||||
|
@ -26,25 +26,27 @@ func AccAddress() string {
|
|||||||
return sdk.AccAddress(addr).String()
|
return sdk.AccAddress(addr).String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func Machine(machineId string, pkPM string, pkL string) machinetypes.Machine {
|
func Machine(name, pubKey string) machinetypes.Machine {
|
||||||
|
metadata := Metadata()
|
||||||
m := machinetypes.Machine{
|
m := machinetypes.Machine{
|
||||||
Name: "machine",
|
Name: name,
|
||||||
Ticker: "PM",
|
Ticker: name + "_ticker",
|
||||||
Issued: 1,
|
Issued: 1,
|
||||||
Amount: 1000,
|
Amount: 1000,
|
||||||
Precision: 8,
|
Precision: 8,
|
||||||
IssuerPlanetmint: pkPM,
|
IssuerPlanetmint: pubKey,
|
||||||
IssuerLiquid: pkL,
|
IssuerLiquid: pubKey,
|
||||||
MachineId: machineId,
|
MachineId: pubKey,
|
||||||
|
Metadata: &metadata,
|
||||||
}
|
}
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
func MachineIndex(machineId string, pkPM string, pkL string) machinetypes.MachineIndex {
|
func MachineIndex(pubKey string) machinetypes.MachineIndex {
|
||||||
return machinetypes.MachineIndex{
|
return machinetypes.MachineIndex{
|
||||||
MachineId: machineId,
|
MachineId: pubKey,
|
||||||
IssuerPlanetmint: pkPM,
|
IssuerPlanetmint: pubKey,
|
||||||
IssuerLiquid: pkL,
|
IssuerLiquid: pubKey,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ func TestMsgServer(t *testing.T) {
|
|||||||
|
|
||||||
func TestMsgServerAttestMachine(t *testing.T) {
|
func TestMsgServerAttestMachine(t *testing.T) {
|
||||||
_, pk := sample.KeyPair()
|
_, pk := sample.KeyPair()
|
||||||
machine := sample.Machine(pk, pk, pk)
|
machine := sample.Machine(pk, pk)
|
||||||
msg := types.NewMsgAttestMachine(pk, &machine)
|
msg := types.NewMsgAttestMachine(pk, &machine)
|
||||||
msgServer, ctx := setupMsgServer(t)
|
msgServer, ctx := setupMsgServer(t)
|
||||||
res, err := msgServer.AttestMachine(ctx, msg)
|
res, err := msgServer.AttestMachine(ctx, msg)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user