Skip to content

Commit

Permalink
test: add cli_test for tx
Browse files Browse the repository at this point in the history
Signed-off-by: 170210 <[email protected]>
  • Loading branch information
170210 committed May 22, 2024
1 parent 710e64e commit 1c891b6
Show file tree
Hide file tree
Showing 3 changed files with 386 additions and 5 deletions.
9 changes: 5 additions & 4 deletions x/fswap/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ const (
FlagSwapRate = "swap-rate"
)

type ToDenomMeta struct {
Metadata bank.Metadata `json:"metadata"`
}

// GetTxCmd returns the transaction commands for this module
func GetTxCmd() *cobra.Command {
cmd := &cobra.Command{
Expand Down Expand Up @@ -232,10 +236,7 @@ func validateGenerateOnly(cmd *cobra.Command) error {
}

func parseToDenomMetadata(jsonDenomMetadata string) (bank.Metadata, error) {
type toDenomMeta struct {
Metadata bank.Metadata `json:"metadata"`
}
denomMeta := toDenomMeta{}
denomMeta := ToDenomMeta{}
if err := json.Unmarshal([]byte(jsonDenomMetadata), &denomMeta); err != nil {
return bank.Metadata{}, err
}
Expand Down
4 changes: 3 additions & 1 deletion x/fswap/client/testutil/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type IntegrationTestSuite struct {
cfg network.Config
network *network.Network

authority sdk.AccAddress
toDenom banktypes.Metadata
dummySwap fswaptypes.Swap
}
Expand All @@ -40,7 +41,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
},
},
Base: "dummy",
Display: "Dummy",
Display: "dummy",
}
bankGenesis.DenomMetadata = []banktypes.Metadata{s.toDenom}
bankDataBz, err := s.cfg.Codec.MarshalJSON(&bankGenesis)
Expand Down Expand Up @@ -80,6 +81,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
s.cfg.GenesisState = genesisState

s.network = network.New(s.T(), s.cfg)
s.authority = fswaptypes.DefaultAuthority()

_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
Expand Down
Loading

0 comments on commit 1c891b6

Please sign in to comment.