mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-03-30 15:08:28 +00:00
[test] Use machine struct and marshal it to JSON
Signed-off-by: Julian Strobl <jmastr@mailbox.org>
This commit is contained in:
parent
a766379c39
commit
06688a8ad0
@ -1,6 +1,7 @@
|
||||
package machine
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
clitestutil "planetmint-go/testutil/cli"
|
||||
"planetmint-go/testutil/network"
|
||||
@ -12,9 +13,13 @@ import (
|
||||
bank "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
machinetypes "planetmint-go/x/machine/types"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
const pubKey = "A/ZrbETECRq5DNGJZ0aH0DjlV4Y1opMlRfGoEJH454eB"
|
||||
|
||||
type E2ETestSuite struct {
|
||||
suite.Suite
|
||||
|
||||
@ -59,21 +64,38 @@ func (s *E2ETestSuite) TearDownSuite() {
|
||||
func (s *E2ETestSuite) TestAttestMachine() {
|
||||
val := s.network.Validators[0]
|
||||
|
||||
machine := machinetypes.Machine{
|
||||
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)
|
||||
s.Require().NoError(err)
|
||||
|
||||
args := []string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagChainID, s.network.Config.ChainID),
|
||||
"{\"name\": \"machine\", \"ticker\": \"machine_ticker\", \"issued\": 1, \"amount\": 1000, \"precision\": 8, \"issuerPlanetmint\": \"A/ZrbETECRq5DNGJZ0aH0DjlV4Y1opMlRfGoEJH454eB\", \"issuerLiquid\": \"A/ZrbETECRq5DNGJZ0aH0DjlV4Y1opMlRfGoEJH454eB\", \"machineId\": \"A/ZrbETECRq5DNGJZ0aH0DjlV4Y1opMlRfGoEJH454eB\", \"metadata\": {\"additionalDataCID\": \"CID\", \"gps\": \"{'Latitude':'-48.876667','Longitude':'-123.393333'}\"}}",
|
||||
string(machineJSON),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, "machine"),
|
||||
"-y",
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, "2stake"),
|
||||
}
|
||||
|
||||
_, err := clitestutil.ExecTestCLICmd(val.ClientCtx, machinecli.CmdAttestMachine(), args)
|
||||
_, err = clitestutil.ExecTestCLICmd(val.ClientCtx, machinecli.CmdAttestMachine(), args)
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.Require().NoError(s.network.WaitForNextBlock())
|
||||
|
||||
args = []string{
|
||||
"A/ZrbETECRq5DNGJZ0aH0DjlV4Y1opMlRfGoEJH454eB",
|
||||
pubKey,
|
||||
}
|
||||
|
||||
_, err = clitestutil.ExecTestCLICmd(val.ClientCtx, machinecli.CmdGetMachineByPublicKey(), args)
|
||||
|
Loading…
x
Reference in New Issue
Block a user