-
Notifications
You must be signed in to change notification settings - Fork 558
/
test_helpers.go
68 lines (53 loc) · 2.33 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
package testutil
import (
"fmt"
lockupcli "github.com/c-osmosis/osmosis/x/lockup/client/cli"
"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"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// commonArgs is args for CLI test commands
var commonArgs = []string{
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()),
}
// MsgLockTokens creates a lock tokens message.
func MsgLockTokens(clientCtx client.Context, owner fmt.Stringer, amount fmt.Stringer, duration string, extraArgs ...string) (testutil.BufferWriter, error) {
args := []string{
amount.String(),
fmt.Sprintf("--%s=%s", lockupcli.FlagDuration, duration),
fmt.Sprintf("--%s=%s", flags.FlagFrom, owner.String()),
}
args = append(args, commonArgs...)
return clitestutil.ExecTestCLICmd(clientCtx, lockupcli.NewLockTokensCmd(), args)
}
// MsgBeginUnlocking creates a begin unlock tokens message
func MsgBeginUnlocking(clientCtx client.Context, owner fmt.Stringer, extraArgs ...string) (testutil.BufferWriter, error) {
args := []string{
fmt.Sprintf("--%s=%s", flags.FlagFrom, owner.String()),
fmt.Sprintf("--%s=%d", flags.FlagGas, 500000),
}
args = append(args, commonArgs...)
return clitestutil.ExecTestCLICmd(clientCtx, lockupcli.NewBeginUnlockingCmd(), args)
}
// MsgUnlockTokens unlock all unlockable tokens from an account
func MsgUnlockTokens(clientCtx client.Context, owner fmt.Stringer, extraArgs ...string) (testutil.BufferWriter, error) {
args := []string{
fmt.Sprintf("--%s=%s", flags.FlagFrom, owner.String()),
fmt.Sprintf("--%s=%d", flags.FlagGas, 500000),
}
args = append(args, commonArgs...)
return clitestutil.ExecTestCLICmd(clientCtx, lockupcli.NewUnlockTokensCmd(), args)
}
// MsgUnlockByID unlock unlockable tokens
func MsgUnlockByID(clientCtx client.Context, owner fmt.Stringer, ID string, extraArgs ...string) (testutil.BufferWriter, error) {
args := []string{
ID,
fmt.Sprintf("--%s=%s", flags.FlagFrom, owner.String()),
}
args = append(args, commonArgs...)
return clitestutil.ExecTestCLICmd(clientCtx, lockupcli.NewUnlockByIDCmd(), args)
}