-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use correct directories for commands
- Loading branch information
Showing
5 changed files
with
111 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package main_test | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
wasmd "github.com/CosmWasm/wasmd/cmd/wasmd" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/cosmos/cosmos-sdk/x/genutil/client/cli" | ||
) | ||
|
||
func TestInitCmd(t *testing.T) { | ||
rootCmd, _ := wasmd.NewRootCmd() | ||
rootCmd.SetArgs([]string{ | ||
"init", // Test the init cmd | ||
"simapp-test", // Moniker | ||
fmt.Sprintf("--%s=%s", cli.FlagOverwrite, "true"), // Overwrite genesis.json, in case it already exists | ||
}) | ||
|
||
err := wasmd.Execute(rootCmd) | ||
require.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package main_test | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/spf13/viper" | ||
"github.com/stretchr/testify/require" | ||
"github.com/tendermint/tendermint/libs/log" | ||
|
||
wasmd "github.com/CosmWasm/wasmd/cmd/wasmd" | ||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/flags" | ||
"github.com/cosmos/cosmos-sdk/server" | ||
"github.com/cosmos/cosmos-sdk/simapp" | ||
"github.com/cosmos/cosmos-sdk/testutil/testdata" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
"github.com/cosmos/cosmos-sdk/x/genutil" | ||
genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil" | ||
) | ||
|
||
var testMbm = module.NewBasicManager(genutil.AppModuleBasic{}) | ||
|
||
func TestAddGenesisAccountCmd(t *testing.T) { | ||
_, _, addr1 := testdata.KeyTestPubAddr() | ||
tests := []struct { | ||
name string | ||
addr string | ||
denom string | ||
expectErr bool | ||
}{ | ||
{ | ||
name: "invalid address", | ||
addr: "", | ||
denom: "1000atom", | ||
expectErr: true, | ||
}, | ||
{ | ||
name: "valid address", | ||
addr: addr1.String(), | ||
denom: "1000atom", | ||
expectErr: false, | ||
}, | ||
{ | ||
name: "multiple denoms", | ||
addr: addr1.String(), | ||
denom: "1000atom, 2000stake", | ||
expectErr: false, | ||
}, | ||
} | ||
|
||
for _, tc := range tests { | ||
tc := tc | ||
t.Run(tc.name, func(t *testing.T) { | ||
home := t.TempDir() | ||
logger := log.NewNopLogger() | ||
cfg, err := genutiltest.CreateDefaultTendermintConfig(home) | ||
require.NoError(t, err) | ||
|
||
appCodec, _ := simapp.MakeCodecs() | ||
err = genutiltest.ExecInitCmd(testMbm, home, appCodec) | ||
require.NoError(t, err) | ||
|
||
serverCtx := server.NewContext(viper.New(), cfg, logger) | ||
clientCtx := client.Context{}.WithJSONMarshaler(appCodec).WithHomeDir(home) | ||
|
||
ctx := context.Background() | ||
ctx = context.WithValue(ctx, client.ClientContextKey, &clientCtx) | ||
ctx = context.WithValue(ctx, server.ServerContextKey, serverCtx) | ||
|
||
cmd := wasmd.AddGenesisAccountCmd(home) | ||
cmd.SetArgs([]string{ | ||
tc.addr, | ||
tc.denom, | ||
fmt.Sprintf("--%s=home", flags.FlagHome)}) | ||
|
||
if tc.expectErr { | ||
require.Error(t, cmd.ExecuteContext(ctx)) | ||
} else { | ||
require.NoError(t, cmd.ExecuteContext(ctx)) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters