-
Notifications
You must be signed in to change notification settings - Fork 127
/
test_helpers.go
60 lines (50 loc) · 1.58 KB
/
test_helpers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package testutil
import (
"fmt"
"testing"
"github.com/cometbft/cometbft/libs/cli"
coretypes "github.com/cometbft/cometbft/rpc/core/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/testutil"
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
"github.com/cosmos/cosmos-sdk/testutil/network"
guardiancli "github.com/irisnet/irishub/v3/modules/guardian/client/cli"
apptestutil "github.com/irisnet/irishub/v3/testutil"
)
// CreateSuperExec creates a new super
func CreateSuperExec(
t *testing.T,
network *network.Network,
clientCtx client.Context,
from string,
extraArgs ...string,
) *coretypes.ResultTx {
args := []string{
fmt.Sprintf("--%s=%s", flags.FlagFrom, from),
}
args = append(args, extraArgs...)
return apptestutil.ExecCommand(t, network, clientCtx, guardiancli.GetCmdCreateSuper(), args)
}
// DeleteSuperExec deletes a super
func DeleteSuperExec(
t *testing.T,
network *network.Network,
clientCtx client.Context,
from string,
extraArgs ...string,
) *coretypes.ResultTx {
args := []string{
fmt.Sprintf("--%s=%s", flags.FlagFrom, from),
}
args = append(args, extraArgs...)
return apptestutil.ExecCommand(t, network, clientCtx, guardiancli.GetCmdDeleteSuper(), args)
}
// QuerySupersExec queries supers
func QuerySupersExec(clientCtx client.Context, extraArgs ...string) (testutil.BufferWriter, error) {
args := []string{
fmt.Sprintf("--%s=json", cli.OutputFlag),
}
args = append(args, extraArgs...)
return clitestutil.ExecTestCLICmd(clientCtx, guardiancli.GetCmdQuerySupers(), args)
}