forked from akash-network/node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_helpers.go
72 lines (58 loc) · 2.65 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
61
62
63
64
65
66
67
68
69
70
71
72
package cli
import (
"context"
"fmt"
testutilcli "github.com/akash-network/node/testutil/cli"
"github.com/cosmos/cosmos-sdk/client"
sdktest "github.com/cosmos/cosmos-sdk/testutil"
)
// TxCreateServerExec is used for testing create server certificate tx
func TxGenerateServerExec(ctx context.Context, clientCtx client.Context, from fmt.Stringer, host string, extraArgs ...string) (sdktest.BufferWriter, error) {
var args []string
if len(host) != 0 { // for testing purposes, of passing no arguments
args = []string{host}
}
args = append(args, fmt.Sprintf("--from=%s", from.String()))
args = append(args, extraArgs...)
return testutilcli.ExecTestCLICmd(ctx, clientCtx, cmdGenerateServer(), args...)
}
// TxCreateClientExec is used for testing create client certificate tx
func TxGenerateClientExec(ctx context.Context, clientCtx client.Context, from fmt.Stringer, extraArgs ...string) (sdktest.BufferWriter, error) {
args := []string{
fmt.Sprintf("--from=%s", from.String()),
}
args = append(args, extraArgs...)
return testutilcli.ExecTestCLICmd(ctx, clientCtx, cmdGenerateClient(), args...)
}
// TxCreateServerExec is used for testing create server certificate tx
func TxPublishServerExec(ctx context.Context, clientCtx client.Context, from fmt.Stringer, extraArgs ...string) (sdktest.BufferWriter, error) {
args := []string{
fmt.Sprintf("--from=%s", from.String()),
}
args = append(args, extraArgs...)
return testutilcli.ExecTestCLICmd(ctx, clientCtx, cmdPublishServer(), args...)
}
// TxCreateClientExec is used for testing create client certificate tx
func TxPublishClientExec(ctx context.Context, clientCtx client.Context, from fmt.Stringer, extraArgs ...string) (sdktest.BufferWriter, error) {
args := []string{
fmt.Sprintf("--from=%s", from.String()),
}
args = append(args, extraArgs...)
return testutilcli.ExecTestCLICmd(ctx, clientCtx, cmdPublishClient(), args...)
}
// TxCreateServerExec is used for testing create server certificate tx
func TxRevokeServerExec(ctx context.Context, clientCtx client.Context, from fmt.Stringer, extraArgs ...string) (sdktest.BufferWriter, error) {
args := []string{
fmt.Sprintf("--from=%s", from.String()),
}
args = append(args, extraArgs...)
return testutilcli.ExecTestCLICmd(ctx, clientCtx, cmdRevokeServer(), args...)
}
// TxCreateClientExec is used for testing create client certificate tx
func TxRevokeClientExec(ctx context.Context, clientCtx client.Context, from fmt.Stringer, extraArgs ...string) (sdktest.BufferWriter, error) {
args := []string{
fmt.Sprintf("--from=%s", from.String()),
}
args = append(args, extraArgs...)
return testutilcli.ExecTestCLICmd(ctx, clientCtx, cmdRevokeClient(), args...)
}