diff --git a/e2e/service/query.go b/e2e/service/query.go index ba448f78..92b3c3e1 100644 --- a/e2e/service/query.go +++ b/e2e/service/query.go @@ -63,7 +63,7 @@ func (s *QueryTestSuite) TestQueryCmd() { serviceName := "test-service" serviceDesc := "test-description" serviceAuthorDesc := "test-author-description" - serviceTags := "tags1,tags2" + serviceTags := "tags3,tags4" serviceSchemas := `{"input":{"type":"object"},"output":{"type":"object"},"error":{"type":"object"}}` serviceDenom := sdk.DefaultBondDenom baseURL := val.APIAddress diff --git a/modules/coinswap/client/testutil/grpc_query_test.go b/modules/coinswap/client/testutil/grpc_query_test.go deleted file mode 100644 index dfa36b89..00000000 --- a/modules/coinswap/client/testutil/grpc_query_test.go +++ /dev/null @@ -1,254 +0,0 @@ -package testutil_test - -// import ( -// "context" -// "fmt" -// "testing" -// "time" - -// "github.com/cosmos/gogoproto/proto" -// "github.com/stretchr/testify/suite" - -// "github.com/cosmos/cosmos-sdk/testutil" -// sdk "github.com/cosmos/cosmos-sdk/types" - -// tokentypes "github.com/irisnet/irismod/modules/token/types/v1" -// "mods.irisnet.org/simapp" -// coinswaptypes "mods.irisnet.org/modules/coinswap/types" -// ) - -// type IntegrationTestSuite struct { -// suite.Suite -// network simapp.Network -// } - -// func (s *IntegrationTestSuite) SetupSuite() { -// s.T().Log("setting up integration test suite") - -// s.network = simapp.SetupNetwork(s.T()) -// sdk.SetCoinDenomRegex(func() string { -// return `[a-zA-Z][a-zA-Z0-9/\-]{2,127}` -// }) -// } - -// func (s *IntegrationTestSuite) TearDownSuite() { -// s.T().Log("tearing down integration test suite") -// s.network.Cleanup() -// } - -// func TestIntegrationTestSuite(t *testing.T) { -// suite.Run(t, new(IntegrationTestSuite)) -// } - -// func (s *IntegrationTestSuite) TestCoinswap() { -// val := s.network.Validators[0] -// clientCtx := val.ClientCtx -// // --------------------------------------------------------------------------- - -// from := val.Address -// symbol := "kitty" -// name := "Kitty Token" -// minUnit := "kitty" -// scale := uint32(0) -// initialSupply := uint64(100000000) -// maxSupply := uint64(200000000) -// mintable := true -// baseURL := val.APIAddress -// lptDenom := "lpt-1" - -// // issue token -// msgIssueToken := &tokentypes.MsgIssueToken{ -// Symbol: symbol, -// Name: name, -// Scale: scale, -// MinUnit: minUnit, -// InitialSupply: initialSupply, -// MaxSupply: maxSupply, -// Mintable: mintable, -// Owner: from.String(), -// } -// s.network.SendMsgs(s.T(), msgIssueToken) - -// //_ = tokentestutil.IssueTokenExec(s.T(), s.network, clientCtx, from.String(), args...) - -// balances := simapp.QueryBalancesExec(s.T(), s.network, clientCtx, from.String()) -// s.Require().Equal("100000000", balances.AmountOf(symbol).String()) -// s.Require().Equal("399986975", balances.AmountOf(sdk.DefaultBondDenom).String()) - -// // test add liquidity (poor not exist) -// status, err := clientCtx.Client.Status(context.Background()) -// s.Require().NoError(err) -// deadline := status.SyncInfo.LatestBlockTime.Add(time.Minute) - -// msgAddLiquidity := &coinswaptypes.MsgAddLiquidity{ -// MaxToken: sdk.NewCoin(symbol, sdk.NewInt(1000)), -// ExactStandardAmt: sdk.NewInt(1000), -// MinLiquidity: sdk.NewInt(1000), -// Deadline: deadline.Unix(), -// Sender: from.String(), -// } -// s.network.SendMsgs(s.T(), msgAddLiquidity) - -// balances = simapp.QueryBalancesExec(s.T(), s.network, clientCtx, from.String()) -// s.Require().Equal("99999000", balances.AmountOf(symbol).String()) -// s.Require().Equal("399980965", balances.AmountOf(sdk.DefaultBondDenom).String()) -// s.Require().Equal("1000", balances.AmountOf(lptDenom).String()) - -// queryPoolResponse := proto.Message(&coinswaptypes.QueryLiquidityPoolResponse{}) -// url := fmt.Sprintf("%s/irismod/coinswap/pools/%s", baseURL, lptDenom) -// resp, err := testutil.GetRequest(url) -// s.Require().NoError(err) -// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(resp, queryPoolResponse)) - -// queryPool := queryPoolResponse.(*coinswaptypes.QueryLiquidityPoolResponse) -// s.Require().Equal("1000", queryPool.Pool.Standard.Amount.String()) -// s.Require().Equal("1000", queryPool.Pool.Token.Amount.String()) -// s.Require().Equal("1000", queryPool.Pool.Lpt.Amount.String()) - -// // test add liquidity (poor exist) -// status, err = clientCtx.Client.Status(context.Background()) -// s.Require().NoError(err) -// deadline = status.SyncInfo.LatestBlockTime.Add(time.Minute) - -// msgAddLiquidity = &coinswaptypes.MsgAddLiquidity{ -// MaxToken: sdk.NewCoin(symbol, sdk.NewInt(2001)), -// ExactStandardAmt: sdk.NewInt(2000), -// MinLiquidity: sdk.NewInt(2000), -// Deadline: deadline.Unix(), -// Sender: from.String(), -// } -// s.network.SendMsgs(s.T(), msgAddLiquidity) - -// balances = simapp.QueryBalancesExec(s.T(), s.network, clientCtx, from.String()) -// s.Require().Equal("99996999", balances.AmountOf(symbol).String()) -// s.Require().Equal("399978955", balances.AmountOf(sdk.DefaultBondDenom).String()) -// s.Require().Equal("3000", balances.AmountOf(lptDenom).String()) - -// url = fmt.Sprintf("%s/irismod/coinswap/pools/%s", baseURL, lptDenom) -// resp, err = testutil.GetRequest(url) -// s.Require().NoError(err) -// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(resp, queryPoolResponse)) - -// s.Require().Equal("3000", queryPool.Pool.Standard.Amount.String()) -// s.Require().Equal("3001", queryPool.Pool.Token.Amount.String()) -// s.Require().Equal("3000", queryPool.Pool.Lpt.Amount.String()) - -// // test sell order -// msgSellOrder := &coinswaptypes.MsgSwapOrder{ -// Input: coinswaptypes.Input{ -// Address: from.String(), -// Coin: sdk.NewCoin(symbol, sdk.NewInt(1000)), -// }, -// Output: coinswaptypes.Output{ -// Address: from.String(), -// Coin: sdk.NewInt64Coin(s.network.BondDenom, 748), -// }, -// Deadline: deadline.Unix(), -// IsBuyOrder: false, -// } -// s.network.SendMsgs(s.T(), msgSellOrder) - -// balances = simapp.QueryBalancesExec(s.T(), s.network, clientCtx, from.String()) -// s.Require().Equal("99995999", balances.AmountOf(symbol).String()) -// s.Require().Equal("399979693", balances.AmountOf(sdk.DefaultBondDenom).String()) -// s.Require().Equal("3000", balances.AmountOf(lptDenom).String()) - -// url = fmt.Sprintf("%s/irismod/coinswap/pools/%s", baseURL, lptDenom) -// resp, err = testutil.GetRequest(url) -// s.Require().NoError(err) -// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(resp, queryPoolResponse)) - -// s.Require().Equal("2252", queryPool.Pool.Standard.Amount.String()) -// s.Require().Equal("4001", queryPool.Pool.Token.Amount.String()) -// s.Require().Equal("3000", queryPool.Pool.Lpt.Amount.String()) - -// // test buy order -// msgBuyOrder := &coinswaptypes.MsgSwapOrder{ -// Input: coinswaptypes.Input{ -// Address: from.String(), -// Coin: sdk.NewInt64Coin(s.network.BondDenom, 753), -// }, -// Output: coinswaptypes.Output{ -// Address: from.String(), -// Coin: sdk.NewCoin(symbol, sdk.NewInt(1000)), -// }, -// Deadline: deadline.Unix(), -// IsBuyOrder: true, -// } -// s.network.SendMsgs(s.T(), msgBuyOrder) - -// balances = simapp.QueryBalancesExec(s.T(), s.network, clientCtx, from.String()) -// s.Require().Equal("99996999", balances.AmountOf(symbol).String()) -// s.Require().Equal("399978930", balances.AmountOf(sdk.DefaultBondDenom).String()) -// s.Require().Equal("3000", balances.AmountOf(lptDenom).String()) - -// url = fmt.Sprintf("%s/irismod/coinswap/pools/%s", baseURL, lptDenom) -// resp, err = testutil.GetRequest(url) -// s.Require().NoError(err) -// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(resp, queryPoolResponse)) - -// s.Require().Equal("3005", queryPool.Pool.Standard.Amount.String()) -// s.Require().Equal("3001", queryPool.Pool.Token.Amount.String()) -// s.Require().Equal("3000", queryPool.Pool.Lpt.Amount.String()) - -// // Test remove liquidity (remove part) -// msgRemoveLiquidity := &coinswaptypes.MsgRemoveLiquidity{ -// WithdrawLiquidity: sdk.NewCoin(lptDenom, sdk.NewInt(2000)), -// MinToken: sdk.NewInt(2000), -// MinStandardAmt: sdk.NewInt(2000), -// Deadline: deadline.Unix(), -// Sender: from.String(), -// } - -// // prepare txBuilder with msg -// s.network.SendMsgs(s.T(), msgRemoveLiquidity) - -// balances = simapp.QueryBalancesExec(s.T(), s.network, clientCtx, from.String()) -// s.Require().Equal("99998999", balances.AmountOf(symbol).String()) -// s.Require().Equal("399980923", balances.AmountOf(sdk.DefaultBondDenom).String()) -// s.Require().Equal("1000", balances.AmountOf(lptDenom).String()) - -// url = fmt.Sprintf("%s/irismod/coinswap/pools/%s", baseURL, lptDenom) -// resp, err = testutil.GetRequest(url) -// s.Require().NoError(err) -// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(resp, queryPoolResponse)) - -// s.Require().Equal("1002", queryPool.Pool.Standard.Amount.String()) -// s.Require().Equal("1001", queryPool.Pool.Token.Amount.String()) -// s.Require().Equal("1000", queryPool.Pool.Lpt.Amount.String()) - -// // Test remove liquidity (remove all) -// msgRemoveLiquidity = &coinswaptypes.MsgRemoveLiquidity{ -// WithdrawLiquidity: sdk.NewCoin(lptDenom, sdk.NewInt(1000)), -// MinToken: sdk.NewInt(1000), -// MinStandardAmt: sdk.NewInt(1000), -// Deadline: deadline.Unix(), -// Sender: from.String(), -// } - -// // prepare txBuilder with msg -// s.network.SendMsgs(s.T(), msgRemoveLiquidity) - -// balances = simapp.QueryBalancesExec(s.T(), s.network, clientCtx, from.String()) -// s.Require().Equal("100000000", balances.AmountOf(symbol).String()) -// s.Require().Equal("399981915", balances.AmountOf(sdk.DefaultBondDenom).String()) -// s.Require().Equal("0", balances.AmountOf(lptDenom).String()) - -// url = fmt.Sprintf("%s/irismod/coinswap/pools/%s", baseURL, lptDenom) -// resp, err = testutil.GetRequest(url) -// s.Require().NoError(err) -// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(resp, queryPoolResponse)) - -// s.Require().Equal("0", queryPool.Pool.Standard.Amount.String()) -// s.Require().Equal("0", queryPool.Pool.Token.Amount.String()) -// s.Require().Equal("0", queryPool.Pool.Lpt.Amount.String()) - -// queryPoolsResponse := proto.Message(&coinswaptypes.QueryLiquidityPoolsResponse{}) -// url = fmt.Sprintf("%s/irismod/coinswap/pools", baseURL) -// resp, err = testutil.GetRequest(url) -// s.Require().NoError(err) -// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(resp, queryPoolsResponse)) - -// queryPools := queryPoolsResponse.(*coinswaptypes.QueryLiquidityPoolsResponse) -// s.Require().Len(queryPools.Pools, 1) -// } diff --git a/modules/farm/client/cli/cli_test.go b/modules/farm/client/cli/cli_test.go deleted file mode 100644 index 52542001..00000000 --- a/modules/farm/client/cli/cli_test.go +++ /dev/null @@ -1,251 +0,0 @@ -package cli_test - -// import ( -// "context" -// "fmt" -// "testing" -// "time" - -// "github.com/stretchr/testify/suite" - -// "github.com/cosmos/cosmos-sdk/client/flags" -// sdk "github.com/cosmos/cosmos-sdk/types" - -// coinswaptypes "mods.irisnet.org/modules/coinswap/types" -// tokentypes "mods.irisnet.org/modules/token/types/v1" -// "mods.irisnet.org/simapp" -// farmcli "mods.irisnet.org/modules/farm/client/cli" -// "mods.irisnet.org/modules/farm/client/testutil" -// farmtypes "mods.irisnet.org/modules/farm/types" -// ) - -// type IntegrationTestSuite struct { -// suite.Suite - -// network simapp.Network -// } - -// func (s *IntegrationTestSuite) SetupSuite() { -// s.T().Log("setting up integration test suite") - -// s.network = simapp.SetupNetwork(s.T()) -// sdk.SetCoinDenomRegex(func() string { -// return `[a-zA-Z][a-zA-Z0-9/\-]{2,127}` -// }) -// } - -// func (s *IntegrationTestSuite) TearDownSuite() { -// s.T().Log("tearing down integration test suite") -// s.network.Cleanup() -// } - -// func TestIntegrationTestSuite(t *testing.T) { -// suite.Run(t, new(IntegrationTestSuite)) -// } - -// func (s *IntegrationTestSuite) TestFarm() { -// val := s.network.Validators[0] -// clientCtx := val.ClientCtx - -// s.Init() - -// // --------------------------------------------------------------------------- - -// creator := val.Address -// description := "iris-atom farm pool" -// startHeight := s.LatestHeight() + 2 -// rewardPerBlock := sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))) -// totalReward := sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(1000))) -// editable := true -// lptDenom := "lpt-1" - -// globalFlags := []string{ -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// args := []string{ -// fmt.Sprintf("--%s=%s", farmcli.FlagDescription, description), -// fmt.Sprintf("--%s=%d", farmcli.FlagStartHeight, startHeight), -// fmt.Sprintf("--%s=%s", farmcli.FlagRewardPerBlock, rewardPerBlock), -// fmt.Sprintf("--%s=%s", farmcli.FlagLPTokenDenom, lptDenom), -// fmt.Sprintf("--%s=%s", farmcli.FlagTotalReward, totalReward), -// fmt.Sprintf("--%s=%v", farmcli.FlagEditable, editable), -// } - -// args = append(args, globalFlags...) -// txResult := testutil.CreateFarmPoolExec( -// s.T(), -// s.network, -// clientCtx, -// creator.String(), -// args..., -// ) -// s.Require().EqualValues(txResult.Code, 0, txResult.Log) - -// poolId := s.network.GetAttribute( -// farmtypes.EventTypeCreatePool, -// farmtypes.AttributeValuePoolId, -// txResult.Events, -// ) -// expectedContents := &farmtypes.FarmPoolEntry{ -// Id: poolId, -// Creator: creator.String(), -// Description: description, -// StartHeight: startHeight, -// EndHeight: startHeight + 100, -// Editable: editable, -// Expired: false, -// TotalLptLocked: sdk.NewCoin(lptDenom, sdk.ZeroInt()), -// TotalReward: totalReward, -// RemainingReward: totalReward, -// RewardPerBlock: rewardPerBlock, -// } - -// respType := testutil.QueryFarmPoolExec(s.T(), s.network, val.ClientCtx, poolId) -// s.Require().EqualValues(expectedContents, respType.Pool) - -// reward := sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(1000))) -// args = []string{ -// fmt.Sprintf("--%s=%v", farmcli.FlagAdditionalReward, reward.String()), -// } -// args = append(args, globalFlags...) -// txResult = testutil.AppendRewardExec( -// s.T(), -// s.network, -// clientCtx, -// creator.String(), -// poolId, -// args..., -// ) -// s.Require().EqualValues(txResult.Code, 0, txResult.Log) - -// lpToken := sdk.NewCoin(lptDenom, sdk.NewInt(100)) -// txResult = testutil.StakeExec( -// s.T(), -// s.network, -// clientCtx, -// creator.String(), -// poolId, -// lpToken.String(), -// globalFlags..., -// ) -// s.Require().EqualValues(txResult.Code, 0, txResult.Log) -// beginHeight := txResult.Height - -// unstakeLPToken := sdk.NewCoin(lptDenom, sdk.NewInt(50)) -// txResult = testutil.UnstakeExec( -// s.T(), -// s.network, -// clientCtx, -// creator.String(), -// poolId, -// unstakeLPToken.String(), -// globalFlags..., -// ) -// s.Require().EqualValues(txResult.Code, 0, txResult.Log) -// endHeight := txResult.Height - -// rewardGot := s.network.GetAttribute( -// farmtypes.EventTypeUnstake, -// farmtypes.AttributeValueReward, -// txResult.Events, -// ) -// expectedReward := rewardPerBlock.MulInt(sdk.NewInt(endHeight - beginHeight)) -// s.Require().Equal(expectedReward.String(), rewardGot) - -// txResult = testutil.HarvestExec( -// s.T(), -// s.network, -// clientCtx, -// creator.String(), -// poolId, -// globalFlags..., -// ) -// s.Require().EqualValues(txResult.Code, 0, txResult.Log) -// endHeight1 := txResult.Height - -// rewardGot = s.network.GetAttribute( -// farmtypes.EventTypeHarvest, -// farmtypes.AttributeValueReward, -// txResult.Events, -// ) -// expectedReward = rewardPerBlock.MulInt(sdk.NewInt(endHeight1 - endHeight)) -// s.Require().Equal(expectedReward.String(), rewardGot) - -// queryFarmerArgs := []string{ -// fmt.Sprintf("--%s=%s", farmcli.FlagFarmPool, poolId), -// } - -// leftlpToken := lpToken.Sub(unstakeLPToken) -// response := testutil.QueryFarmerExec( -// s.T(), -// s.network, -// val.ClientCtx, creator.String(), queryFarmerArgs...) -// s.Require().EqualValues(leftlpToken, response.List[0].Locked) - -// txResult = testutil.DestroyExec( -// s.T(), -// s.network, -// clientCtx, -// creator.String(), -// poolId, -// globalFlags..., -// ) -// s.Require().EqualValues(txResult.Code, 0, txResult.Log) -// } - -// func (s *IntegrationTestSuite) LatestHeight() int64 { -// height, err := s.network.LatestHeight() -// s.Require().NoError(err) -// return height -// } - -// func (s *IntegrationTestSuite) Init() { - -// val := s.network.Validators[0] -// clientCtx := val.ClientCtx - -// from := val.Address -// symbol := "kitty" -// name := "Kitty Token" -// minUnit := "kitty" -// scale := uint32(0) -// initialSupply := uint64(100000000) -// maxSupply := uint64(200000000) -// mintable := true - -// // issue token -// msgIssueToken := &tokentypes.MsgIssueToken{ -// Symbol: symbol, -// Name: name, -// Scale: scale, -// MinUnit: minUnit, -// InitialSupply: initialSupply, -// MaxSupply: maxSupply, -// Mintable: mintable, -// Owner: from.String(), -// } -// res := s.network.BlockSendMsgs(s.T(), msgIssueToken) -// s.Require().Equal(uint32(0), res.Code, res.Log) - -// // add liquidity -// status, err := clientCtx.Client.Status(context.Background()) -// s.Require().NoError(err) -// deadline := status.SyncInfo.LatestBlockTime.Add(time.Minute) - -// msgAddLiquidity := &coinswaptypes.MsgAddLiquidity{ -// MaxToken: sdk.NewCoin(symbol, sdk.NewInt(1000)), -// ExactStandardAmt: sdk.NewInt(1000), -// MinLiquidity: sdk.NewInt(1000), -// Deadline: deadline.Unix(), -// Sender: val.Address.String(), -// } -// res = s.network.BlockSendMsgs(s.T(), msgAddLiquidity) -// s.Require().Equal(uint32(0), res.Code, res.Log) -// } diff --git a/modules/farm/client/testutil/grpc_query_test.go b/modules/farm/client/testutil/grpc_query_test.go deleted file mode 100644 index 4bd798c7..00000000 --- a/modules/farm/client/testutil/grpc_query_test.go +++ /dev/null @@ -1,207 +0,0 @@ -package testutil_test - -// import ( -// "context" -// "fmt" -// "testing" -// "time" - -// "github.com/cosmos/gogoproto/proto" -// "github.com/stretchr/testify/suite" - -// "github.com/cosmos/cosmos-sdk/client/flags" -// "github.com/cosmos/cosmos-sdk/testutil" -// sdk "github.com/cosmos/cosmos-sdk/types" - -// coinswaptypes "mods.irisnet.org/modules/coinswap/types" -// tokentypes "mods.irisnet.org/modules/token/types/v1" -// "mods.irisnet.org/simapp" -// farmcli "mods.irisnet.org/modules/farm/client/cli" -// farmtestutil "mods.irisnet.org/modules/farm/client/testutil" -// farmtypes "mods.irisnet.org/modules/farm/types" -// ) - -// type IntegrationTestSuite struct { -// suite.Suite - -// network simapp.Network -// } - -// func (s *IntegrationTestSuite) SetupSuite() { -// s.T().Log("setting up integration test suite") - -// s.network = simapp.SetupNetwork(s.T()) -// sdk.SetCoinDenomRegex(func() string { -// return `[a-zA-Z][a-zA-Z0-9/\-]{2,127}` -// }) -// } - -// func (s *IntegrationTestSuite) TearDownSuite() { -// s.T().Log("tearing down integration test suite") -// s.network.Cleanup() -// } - -// func TestIntegrationTestSuite(t *testing.T) { -// suite.Run(t, new(IntegrationTestSuite)) -// } - -// func (s *IntegrationTestSuite) TestRest() { -// val := s.network.Validators[0] -// clientCtx := val.ClientCtx -// baseURL := val.APIAddress - -// s.Init() - -// // --------------------------------------------------------------------------- - -// creator := val.Address -// description := "iris-atom farm pool" -// startHeight := s.LatestHeight() + 1 -// rewardPerBlock := sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))) -// lpTokenDenom := "lpt-1" -// totalReward := sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(1000))) -// editable := true - -// globalFlags := []string{ -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// args := []string{ -// fmt.Sprintf("--%s=%s", farmcli.FlagDescription, description), -// fmt.Sprintf("--%s=%d", farmcli.FlagStartHeight, startHeight), -// fmt.Sprintf("--%s=%s", farmcli.FlagRewardPerBlock, rewardPerBlock), -// fmt.Sprintf("--%s=%s", farmcli.FlagLPTokenDenom, lpTokenDenom), -// fmt.Sprintf("--%s=%s", farmcli.FlagTotalReward, totalReward), -// fmt.Sprintf("--%s=%v", farmcli.FlagEditable, editable), -// } - -// args = append(args, globalFlags...) -// txResult := farmtestutil.CreateFarmPoolExec( -// s.T(), -// s.network, -// clientCtx, -// creator.String(), -// args..., -// ) -// s.Require().EqualValues(txResult.Code, 0, txResult.Log) - -// poolId := s.network.GetAttribute( -// farmtypes.EventTypeCreatePool, -// farmtypes.AttributeValuePoolId, -// txResult.Events, -// ) -// expectedContents := farmtypes.FarmPoolEntry{ -// Id: poolId, -// Description: description, -// Creator: creator.String(), -// StartHeight: startHeight, -// EndHeight: startHeight + 100, -// Editable: editable, -// Expired: false, -// TotalLptLocked: sdk.NewCoin(lpTokenDenom, sdk.ZeroInt()), -// TotalReward: totalReward, -// RemainingReward: totalReward, -// RewardPerBlock: rewardPerBlock, -// } - -// respType := proto.Message(&farmtypes.QueryFarmPoolsResponse{}) -// queryPoolURL := fmt.Sprintf("%s/irismod/farm/pools", baseURL) -// resp, err := testutil.GetRequest(queryPoolURL) - -// s.Require().NoError(err) -// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(resp, respType)) -// result := respType.(*farmtypes.QueryFarmPoolsResponse) -// s.Require().EqualValues(expectedContents, *result.Pools[0]) - -// _, err = s.network.WaitForHeight(startHeight) -// s.Require().NoError(err) -// s.network.WaitForNextBlock() - -// lpToken := sdk.NewCoin(lpTokenDenom, sdk.NewInt(100)) -// txResult = farmtestutil.StakeExec( -// s.T(), -// s.network, -// clientCtx, -// creator.String(), -// poolId, -// lpToken.String(), -// globalFlags..., -// ) -// s.Require().Equal(uint32(0), txResult.Code, txResult.Log) - -// expectFarmer := farmtypes.LockedInfo{ -// PoolId: poolId, -// Locked: lpToken, -// PendingReward: sdk.Coins{}, -// } - -// queryFarmerRespType := proto.Message(&farmtypes.QueryFarmerResponse{}) -// queryFarmInfoURL := fmt.Sprintf("%s/irismod/farm/farmers/%s", baseURL, creator.String()) -// resp, err = testutil.GetRequest(queryFarmInfoURL) -// s.Require().NoError(err) -// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(resp, queryFarmerRespType)) -// farmer := queryFarmerRespType.(*farmtypes.QueryFarmerResponse) - -// if farmer.Height-txResult.Height > 0 { -// expectFarmer.PendingReward = rewardPerBlock.MulInt( -// sdk.NewInt((farmer.Height - txResult.Height)), -// ) -// } -// s.Require().EqualValues(expectFarmer, *farmer.List[0]) -// } - -// func (s *IntegrationTestSuite) LatestHeight() int64 { -// height, err := s.network.LatestHeight() -// s.Require().NoError(err) -// return height -// } - -// func (s *IntegrationTestSuite) Init() { - -// val := s.network.Validators[0] -// clientCtx := val.ClientCtx - -// from := val.Address -// symbol := "kitty" -// name := "Kitty Token" -// minUnit := "kitty" -// scale := uint32(0) -// initialSupply := uint64(100000000) -// maxSupply := uint64(200000000) -// mintable := true - -// // issue token -// msgIssueToken := &tokentypes.MsgIssueToken{ -// Symbol: symbol, -// Name: name, -// Scale: scale, -// MinUnit: minUnit, -// InitialSupply: initialSupply, -// MaxSupply: maxSupply, -// Mintable: mintable, -// Owner: from.String(), -// } -// res := s.network.BlockSendMsgs(s.T(), msgIssueToken) -// s.Require().Equal(uint32(0), res.Code, res.Log) - -// // add liquidity -// status, err := clientCtx.Client.Status(context.Background()) -// s.Require().NoError(err) -// deadline := status.SyncInfo.LatestBlockTime.Add(time.Minute) - -// msgAddLiquidity := &coinswaptypes.MsgAddLiquidity{ -// MaxToken: sdk.NewCoin(symbol, sdk.NewInt(1000)), -// ExactStandardAmt: sdk.NewInt(1000), -// MinLiquidity: sdk.NewInt(1000), -// Deadline: deadline.Unix(), -// Sender: val.Address.String(), -// } -// res = s.network.BlockSendMsgs(s.T(), msgAddLiquidity) -// s.Require().Equal(uint32(0), res.Code, res.Log) -// } diff --git a/modules/farm/client/testutil/test_helper.go b/modules/farm/client/testutil/test_helper.go deleted file mode 100644 index c5f35dc8..00000000 --- a/modules/farm/client/testutil/test_helper.go +++ /dev/null @@ -1,142 +0,0 @@ -package testutil - -// import ( -// "fmt" -// "testing" - -// "github.com/cometbft/cometbft/libs/cli" - -// "github.com/cosmos/cosmos-sdk/client" -// "github.com/cosmos/cosmos-sdk/client/flags" - -// "mods.irisnet.org/simapp" -// farmcli "mods.irisnet.org/modules/farm/client/cli" -// farmtypes "mods.irisnet.org/modules/farm/types" -// ) - -// // CreateFarmPoolExec creates a redelegate message. -// func CreateFarmPoolExec(t *testing.T, network simapp.Network, clientCtx client.Context, -// creator string, -// extraArgs ...string) *simapp.ResponseTx { -// args := []string{ -// fmt.Sprintf("--%s=%s", flags.FlagFrom, creator), -// } -// args = append(args, extraArgs...) -// return network.ExecTxCmdWithResult(t, clientCtx, farmcli.GetCmdCreateFarmPool(), args) -// } - -// func QueryFarmPoolsExec( -// t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// extraArgs ...string, -// ) *farmtypes.QueryFarmPoolsResponse { -// args := []string{ -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) - -// response := &farmtypes.QueryFarmPoolsResponse{} -// network.ExecQueryCmd(t, clientCtx, farmcli.GetCmdQueryFarmPools(), args, response) -// return response -// } - -// func QueryFarmPoolExec( -// t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// poolId string, -// extraArgs ...string, -// ) *farmtypes.QueryFarmPoolResponse { -// args := []string{ -// poolId, -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) -// response := &farmtypes.QueryFarmPoolResponse{} -// network.ExecQueryCmd(t, clientCtx, farmcli.GetCmdQueryFarmPool(), args, response) -// return response -// } - -// // AppendRewardExec creates a redelegate message. -// func AppendRewardExec(t *testing.T, network simapp.Network, clientCtx client.Context, -// creator, -// poolId string, -// extraArgs ...string) *simapp.ResponseTx { -// args := []string{ -// poolId, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, creator), -// } -// args = append(args, extraArgs...) -// return network.ExecTxCmdWithResult(t, clientCtx, farmcli.GetCmdAdjustPool(), args) -// } - -// // StakeExec creates a redelegate message. -// func StakeExec(t *testing.T, network simapp.Network, clientCtx client.Context, -// creator, -// poolId, -// lpToken string, -// extraArgs ...string) *simapp.ResponseTx { -// args := []string{ -// poolId, -// lpToken, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, creator), -// } -// args = append(args, extraArgs...) -// return network.ExecTxCmdWithResult(t, clientCtx, farmcli.GetCmdStake(), args) -// } - -// // UnstakeExec creates a redelegate message. -// func UnstakeExec(t *testing.T, network simapp.Network, clientCtx client.Context, -// creator, -// poolId, -// lpToken string, -// extraArgs ...string) *simapp.ResponseTx { -// args := []string{ -// poolId, -// lpToken, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, creator), -// } -// args = append(args, extraArgs...) -// return network.ExecTxCmdWithResult(t, clientCtx, farmcli.GetCmdUnstake(), args) -// } - -// // HarvestExec creates a redelegate message. -// func HarvestExec(t *testing.T, network simapp.Network, clientCtx client.Context, -// creator, -// poolId string, -// extraArgs ...string) *simapp.ResponseTx { -// args := []string{ -// poolId, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, creator), -// } -// args = append(args, extraArgs...) -// return network.ExecTxCmdWithResult(t, clientCtx, farmcli.GetCmdHarvest(), args) -// } - -// // DestroyExec creates a redelegate message. -// func DestroyExec(t *testing.T, network simapp.Network, clientCtx client.Context, -// creator, -// poolId string, -// extraArgs ...string) *simapp.ResponseTx { -// args := []string{ -// poolId, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, creator), -// } -// args = append(args, extraArgs...) -// return network.ExecTxCmdWithResult(t, clientCtx, farmcli.GetCmdDestroyFarmPool(), args) -// } - -// // QueryFarmerExec creates a redelegate message. -// func QueryFarmerExec(t *testing.T, network simapp.Network, clientCtx client.Context, -// creator string, -// extraArgs ...string) *farmtypes.QueryFarmerResponse { -// args := []string{ -// creator, -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) -// response := &farmtypes.QueryFarmerResponse{} -// network.ExecQueryCmd(t, clientCtx, farmcli.GetCmdQueryFarmer(), args, response) -// return response -// } diff --git a/modules/htlc/client/cli/cli_test.go b/modules/htlc/client/cli/cli_test.go deleted file mode 100644 index 83e4ab99..00000000 --- a/modules/htlc/client/cli/cli_test.go +++ /dev/null @@ -1,535 +0,0 @@ -package cli_test - -// import ( -// "fmt" -// "math/rand" -// "strconv" -// "testing" -// "time" - -// "github.com/stretchr/testify/suite" - -// tmbytes "github.com/cometbft/cometbft/libs/bytes" - -// "github.com/cosmos/cosmos-sdk/client/flags" -// sdk "github.com/cosmos/cosmos-sdk/types" - -// "mods.irisnet.org/simapp" -// htlccli "mods.irisnet.org/modules/htlc/client/cli" -// htlctestutil "mods.irisnet.org/modules/htlc/client/testutil" -// htlctypes "mods.irisnet.org/modules/htlc/types" -// ) - -// const ( -// BNB_DENOM = "htltbnb" -// DEPUTY_ADDR = "cosmos1kznrznww4pd6gx0zwrpthjk68fdmqypjpkj5hp" -// ) - -// var ( -// Deputy sdk.AccAddress -// MinTimeLock uint64 = 50 -// MaxTimeLock uint64 = 60 -// ReceiverOnOtherChain = "ReceiverOnOtherChain" -// SenderOnOtherChain = "SenderOnOtherChain" -// ) - -// const DeputyArmor = `-----BEGIN TENDERMINT PRIVATE KEY----- -// salt: C3586B75587D2824187D2CDA22B6AFB6 -// type: secp256k1 -// kdf: bcrypt - -// 1+15OrCKgjnwym1zO3cjo/SGe3PPqAYChQ5wMHjdUbTZM7mWsH3/ueL6swgjzI3b -// DDzEQAPXBQflzNW6wbne9IfT651zCSm+j1MWaGk= -// =wEHs -// -----END TENDERMINT PRIVATE KEY-----` - -// type IntegrationTestSuite struct { -// suite.Suite - -// network simapp.Network -// } - -// func c(denom string, amount int64) sdk.Coin { -// return sdk.NewInt64Coin(denom, amount) -// } - -// func cs(coins ...sdk.Coin) sdk.Coins { -// return sdk.NewCoins(coins...) -// } - -// func ts(minOffset int) uint64 { -// return uint64(time.Now().Add(time.Duration(minOffset) * time.Minute).Unix()) -// } - -// func (s *IntegrationTestSuite) SetupSuite() { -// s.T().Log("setting up integration test suite") - -// cfg := simapp.NewConfig() -// cfg.NumValidators = 4 - -// Deputy, _ = sdk.AccAddressFromBech32(DEPUTY_ADDR) -// cfg.GenesisState[htlctypes.ModuleName] = cfg.Codec.MustMarshalJSON(NewHTLTGenesis(Deputy)) -// s.network = simapp.SetupNetworkWithConfig(s.T(), cfg) -// } - -// func (s *IntegrationTestSuite) TearDownSuite() { -// s.T().Log("tearing down integration test suite") -// s.network.Cleanup() -// } - -// func TestIntegrationTestSuite(t *testing.T) { -// suite.Run(t, new(IntegrationTestSuite)) -// } - -// func (s *IntegrationTestSuite) TestHTLC() { -// // --------------------------------------------------------------- -// ctx := s.network.Validators[0].ClientCtx -// err := ctx.Keyring.ImportPrivKey("deputy", DeputyArmor, "1234567890") -// s.Require().NoError(err) - -// args := []string{ -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// _ = simapp.MsgSendExec( -// s.T(), -// s.network, -// ctx, -// s.network.Validators[0].Address, -// Deputy, -// cs(c(sdk.DefaultBondDenom, 50000000)), -// args..., -// ) - -// // --------------------------------------------------------------- - -// type htlcArgs struct { -// sender sdk.AccAddress -// receiver sdk.AccAddress -// receiverOtherChain string -// senderOtherChain string -// amount sdk.Coins -// secret tmbytes.HexBytes -// timestamp uint64 -// timeLock uint64 -// transfer bool -// direction htlctypes.SwapDirection -// } -// testCases := []struct { -// name string -// args htlcArgs -// pass bool -// }{{ -// "valid htlc", -// htlcArgs{ -// sender: s.network.Validators[0].Address, -// receiver: s.network.Validators[1].Address, -// receiverOtherChain: ReceiverOnOtherChain, -// senderOtherChain: SenderOnOtherChain, -// amount: cs(c(sdk.DefaultBondDenom, 1000)), -// secret: GenerateRandomSecret(), -// timestamp: uint64(1580000000), -// timeLock: uint64(50), -// transfer: false, -// direction: htlctypes.None, -// }, -// true, -// }, { -// "valid incoming htlt", -// htlcArgs{ -// sender: Deputy, -// receiver: s.network.Validators[0].Address, -// receiverOtherChain: ReceiverOnOtherChain, -// senderOtherChain: SenderOnOtherChain, -// amount: cs(c(BNB_DENOM, 10000)), -// secret: GenerateRandomSecret(), -// timestamp: ts(0), -// timeLock: MinTimeLock, -// transfer: true, -// direction: htlctypes.Incoming, -// }, -// true, -// }, { -// "valid outgoing htlt", -// htlcArgs{ -// sender: s.network.Validators[0].Address, -// receiver: Deputy, -// receiverOtherChain: ReceiverOnOtherChain, -// senderOtherChain: SenderOnOtherChain, -// amount: cs(c(BNB_DENOM, 5000)), -// secret: GenerateRandomSecret(), -// timestamp: ts(0), -// timeLock: MinTimeLock, -// transfer: true, -// direction: htlctypes.Outgoing, -// }, -// true, -// }} - -// // --------------------------------------------------------------- -// // HTLC -// // --------------------------------------------------------------- - -// args = []string{ -// fmt.Sprintf("--%s=%s", htlccli.FlagTo, testCases[0].args.receiver), -// fmt.Sprintf("--%s=%s", htlccli.FlagAmount, testCases[0].args.amount), -// fmt.Sprintf( -// "--%s=%s", -// htlccli.FlagReceiverOnOtherChain, -// testCases[0].args.receiverOtherChain, -// ), -// fmt.Sprintf("--%s=%s", htlccli.FlagSenderOnOtherChain, testCases[0].args.senderOtherChain), -// fmt.Sprintf( -// "--%s=%s", -// htlccli.FlagHashLock, -// tmbytes.HexBytes(htlctypes.GetHashLock(testCases[0].args.secret, testCases[0].args.timestamp)). -// String(), -// ), -// fmt.Sprintf("--%s=%d", htlccli.FlagTimeLock, testCases[0].args.timeLock), -// fmt.Sprintf("--%s=%d", htlccli.FlagTimestamp, testCases[0].args.timestamp), -// fmt.Sprintf( -// "--%s=%s", -// htlccli.FlagTransfer, -// strconv.FormatBool(testCases[0].args.transfer), -// ), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult := htlctestutil.CreateHTLCExec( -// s.T(), -// s.network, -// ctx, -// testCases[0].args.sender.String(), -// args..., -// ) - -// // --------------------------------------------------------------- - -// expectedhtlc := htlctypes.HTLC{ -// Id: htlctypes.GetID(testCases[0].args.sender, testCases[0].args.receiver, testCases[0].args.amount, htlctypes.GetHashLock(testCases[0].args.secret, testCases[0].args.timestamp)). -// String(), -// Sender: testCases[0].args.sender.String(), -// To: testCases[0].args.receiver.String(), -// ReceiverOnOtherChain: ReceiverOnOtherChain, -// SenderOnOtherChain: SenderOnOtherChain, -// Amount: testCases[0].args.amount, -// Secret: "", -// HashLock: tmbytes.HexBytes(htlctypes.GetHashLock(testCases[0].args.secret, testCases[0].args.timestamp)). -// String(), -// Timestamp: testCases[0].args.timestamp, -// ExpirationHeight: uint64(txResult.Height) + testCases[0].args.timeLock, -// State: htlctypes.Open, -// ClosedBlock: 0, -// Transfer: testCases[0].args.transfer, -// Direction: testCases[0].args.direction, -// } -// respType := htlctestutil.QueryHTLCExec( -// s.T(), -// s.network, -// ctx, -// expectedhtlc.Id, -// ) -// s.Require().Equal(expectedhtlc.String(), respType.String()) - -// // --------------------------------------------------------------- - -// args = []string{ -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = htlctestutil.ClaimHTLCExec( -// s.T(), -// s.network, -// ctx, -// testCases[0].args.sender.String(), -// expectedhtlc.Id, -// testCases[0].args.secret.String(), -// args..., -// ) - -// respType = htlctestutil.QueryHTLCExec( -// s.T(), -// s.network, -// ctx, -// expectedhtlc.Id, -// ) -// s.Require().Equal(htlctypes.Completed.String(), respType.State.String()) - -// balance := simapp.QueryBalanceExec( -// s.T(), -// s.network, -// ctx, testCases[0].args.receiver.String(), -// sdk.DefaultBondDenom, -// ) -// s.Require().Equal("400001000stake", balance.String()) - -// // --------------------------------------------------------------- -// // HTLT INCOMING -// // --------------------------------------------------------------- - -// args = []string{ -// fmt.Sprintf("--%s=%s", htlccli.FlagTo, testCases[1].args.receiver), -// fmt.Sprintf("--%s=%s", htlccli.FlagAmount, testCases[1].args.amount), -// fmt.Sprintf( -// "--%s=%s", -// htlccli.FlagReceiverOnOtherChain, -// testCases[1].args.receiverOtherChain, -// ), -// fmt.Sprintf("--%s=%s", htlccli.FlagSenderOnOtherChain, testCases[1].args.senderOtherChain), -// fmt.Sprintf( -// "--%s=%s", -// htlccli.FlagHashLock, -// tmbytes.HexBytes(htlctypes.GetHashLock(testCases[1].args.secret, testCases[1].args.timestamp)). -// String(), -// ), -// fmt.Sprintf("--%s=%d", htlccli.FlagTimeLock, testCases[1].args.timeLock), -// fmt.Sprintf("--%s=%d", htlccli.FlagTimestamp, testCases[1].args.timestamp), -// fmt.Sprintf( -// "--%s=%s", -// htlccli.FlagTransfer, -// strconv.FormatBool(testCases[1].args.transfer), -// ), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = htlctestutil.CreateHTLCExec( -// s.T(), -// s.network, -// ctx, -// testCases[1].args.sender.String(), -// args..., -// ) - -// // --------------------------------------------------------------- - -// expectedhtlt := htlctypes.HTLC{ -// Id: htlctypes.GetID(testCases[1].args.sender, testCases[1].args.receiver, testCases[1].args.amount, htlctypes.GetHashLock(testCases[1].args.secret, testCases[1].args.timestamp)). -// String(), -// Sender: testCases[1].args.sender.String(), -// To: testCases[1].args.receiver.String(), -// ReceiverOnOtherChain: ReceiverOnOtherChain, -// SenderOnOtherChain: SenderOnOtherChain, -// Amount: testCases[1].args.amount, -// Secret: "", -// HashLock: tmbytes.HexBytes(htlctypes.GetHashLock(testCases[1].args.secret, testCases[1].args.timestamp)). -// String(), -// Timestamp: testCases[1].args.timestamp, -// ExpirationHeight: uint64(txResult.Height) + testCases[1].args.timeLock, -// State: htlctypes.Open, -// ClosedBlock: 0, -// Transfer: testCases[1].args.transfer, -// Direction: testCases[1].args.direction, -// } -// respType = htlctestutil.QueryHTLCExec( -// s.T(), -// s.network, -// ctx, -// expectedhtlt.Id, -// ) -// s.Require().Equal(expectedhtlt.String(), respType.String()) - -// // --------------------------------------------------------------- - -// args = []string{ -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = htlctestutil.ClaimHTLCExec( -// s.T(), -// s.network, -// ctx, -// testCases[1].args.sender.String(), -// expectedhtlt.Id, -// testCases[1].args.secret.String(), -// args..., -// ) - -// respType = htlctestutil.QueryHTLCExec( -// s.T(), -// s.network, -// ctx, -// expectedhtlc.Id, -// ) -// s.Require().Equal(htlctypes.Completed.String(), respType.State.String()) - -// // --------------------------------------------------------------- -// // HTLT OUTGOING -// // --------------------------------------------------------------- - -// args = []string{ -// fmt.Sprintf("--%s=%s", htlccli.FlagTo, testCases[2].args.receiver), -// fmt.Sprintf("--%s=%s", htlccli.FlagAmount, testCases[2].args.amount), -// fmt.Sprintf( -// "--%s=%s", -// htlccli.FlagReceiverOnOtherChain, -// testCases[2].args.receiverOtherChain, -// ), -// fmt.Sprintf("--%s=%s", htlccli.FlagSenderOnOtherChain, testCases[2].args.senderOtherChain), -// fmt.Sprintf( -// "--%s=%s", -// htlccli.FlagHashLock, -// tmbytes.HexBytes(htlctypes.GetHashLock(testCases[2].args.secret, testCases[2].args.timestamp)). -// String(), -// ), -// fmt.Sprintf("--%s=%d", htlccli.FlagTimeLock, testCases[2].args.timeLock), -// fmt.Sprintf("--%s=%d", htlccli.FlagTimestamp, testCases[2].args.timestamp), -// fmt.Sprintf( -// "--%s=%s", -// htlccli.FlagTransfer, -// strconv.FormatBool(testCases[2].args.transfer), -// ), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = htlctestutil.CreateHTLCExec( -// s.T(), -// s.network, -// ctx, -// testCases[2].args.sender.String(), -// args..., -// ) - -// // --------------------------------------------------------------- - -// expectedhtlt = htlctypes.HTLC{ -// Id: htlctypes.GetID(testCases[2].args.sender, testCases[2].args.receiver, testCases[2].args.amount, htlctypes.GetHashLock(testCases[2].args.secret, testCases[2].args.timestamp)). -// String(), -// Sender: testCases[2].args.sender.String(), -// To: testCases[2].args.receiver.String(), -// ReceiverOnOtherChain: ReceiverOnOtherChain, -// SenderOnOtherChain: SenderOnOtherChain, -// Amount: testCases[2].args.amount, -// Secret: "", -// HashLock: tmbytes.HexBytes(htlctypes.GetHashLock(testCases[2].args.secret, testCases[2].args.timestamp)). -// String(), -// Timestamp: testCases[2].args.timestamp, -// ExpirationHeight: uint64(txResult.Height) + testCases[2].args.timeLock, -// State: htlctypes.Open, -// ClosedBlock: 0, -// Transfer: testCases[2].args.transfer, -// Direction: testCases[2].args.direction, -// } - -// respType = htlctestutil.QueryHTLCExec( -// s.T(), -// s.network, -// ctx, -// expectedhtlc.Id, -// ) -// s.Require().Equal(htlctypes.Completed.String(), respType.State.String()) - -// // --------------------------------------------------------------- - -// args = []string{ -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = htlctestutil.ClaimHTLCExec( -// s.T(), -// s.network, -// ctx, -// testCases[2].args.sender.String(), -// expectedhtlt.Id, -// testCases[2].args.secret.String(), -// args..., -// ) - -// respType = htlctestutil.QueryHTLCExec( -// s.T(), -// s.network, -// ctx, -// expectedhtlc.Id, -// ) -// s.Require().Equal(htlctypes.Completed.String(), respType.State.String()) - -// // --------------------------------------------------------------- -// } - -// func NewHTLTGenesis(deputyAddress sdk.AccAddress) *htlctypes.GenesisState { -// return &htlctypes.GenesisState{ -// Params: htlctypes.Params{ -// AssetParams: []htlctypes.AssetParam{ -// { -// Denom: "htltbnb", -// SupplyLimit: htlctypes.SupplyLimit{ -// Limit: sdk.NewInt(350000000000000), -// TimeLimited: false, -// TimeBasedLimit: sdk.ZeroInt(), -// TimePeriod: time.Hour, -// }, -// Active: true, -// DeputyAddress: deputyAddress.String(), -// FixedFee: sdk.NewInt(1000), -// MinSwapAmount: sdk.OneInt(), -// MaxSwapAmount: sdk.NewInt(1000000000000), -// MinBlockLock: MinTimeLock, -// MaxBlockLock: MaxTimeLock, -// }, -// }, -// }, -// Htlcs: []htlctypes.HTLC{}, -// Supplies: []htlctypes.AssetSupply{ -// htlctypes.NewAssetSupply( -// sdk.NewCoin("htltbnb", sdk.ZeroInt()), -// sdk.NewCoin("htltbnb", sdk.ZeroInt()), -// sdk.NewCoin("htltbnb", sdk.ZeroInt()), -// sdk.NewCoin("htltbnb", sdk.ZeroInt()), -// time.Duration(0), -// ), -// }, -// PreviousBlockTime: htlctypes.DefaultPreviousBlockTime, -// } -// } - -// func GenerateRandomSecret() tmbytes.HexBytes { -// bytes := make([]byte, 32) -// if _, err := rand.Read(bytes); err != nil { -// panic(err.Error()) -// } -// return bytes -// } diff --git a/modules/htlc/client/testutil/grpc_query_test.go b/modules/htlc/client/testutil/grpc_query_test.go deleted file mode 100644 index 513b0326..00000000 --- a/modules/htlc/client/testutil/grpc_query_test.go +++ /dev/null @@ -1,78 +0,0 @@ -package testutil_test - -// import ( -// "fmt" -// "testing" - -// "github.com/stretchr/testify/suite" - -// "github.com/cometbft/cometbft/crypto" - -// "github.com/cosmos/cosmos-sdk/client/flags" -// sdk "github.com/cosmos/cosmos-sdk/types" - -// "mods.irisnet.org/simapp" -// htlccli "mods.irisnet.org/modules/htlc/client/cli" -// htlctestutil "mods.irisnet.org/modules/htlc/client/testutil" -// ) - -// type IntegrationTestSuite struct { -// suite.Suite - -// network simapp.Network -// } - -// func (s *IntegrationTestSuite) SetupSuite() { -// s.T().Log("setting up integration test suite") - -// s.network = simapp.SetupNetwork(s.T()) -// } - -// func (s *IntegrationTestSuite) TearDownSuite() { -// s.T().Log("tearing down integration test suite") -// s.network.Cleanup() -// } - -// func TestIntegrationTestSuite(t *testing.T) { -// suite.Run(t, new(IntegrationTestSuite)) -// } - -// func (s *IntegrationTestSuite) TestHtlc() { -// val := s.network.Validators[0] - -// //------test GetCmdCreateHTLC()------------- -// //baseURL := val.APIAddress -// from := val.Address -// to := sdk.AccAddress(crypto.AddressHash([]byte("dgsbl"))) -// amount := "1000" + sdk.DefaultBondDenom -// receiverOnOtherChain := "0xcd2a3d9f938e13cd947ec05abc7fe734df8dd826" -// hashLock := "e8d4133e1a82c74e2746e78c19385706ea7958a0ca441a08dacfa10c48ce2561" -// timeLock := uint64(50) -// timestamp := uint64(1580000000) -// //stateOpen := "HTLC_STATE_OPEN" - -// args := []string{ -// fmt.Sprintf("--%s=%s", htlccli.FlagTo, to), -// fmt.Sprintf("--%s=%s", htlccli.FlagAmount, amount), -// fmt.Sprintf("--%s=%s", htlccli.FlagReceiverOnOtherChain, receiverOnOtherChain), -// fmt.Sprintf("--%s=%s", htlccli.FlagHashLock, hashLock), -// fmt.Sprintf("--%s=%d", htlccli.FlagTimeLock, timeLock), -// fmt.Sprintf("--%s=%d", htlccli.FlagTimestamp, timestamp), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// _ = htlctestutil.CreateHTLCExec( -// s.T(), -// s.network, -// val.ClientCtx, -// from.String(), -// args..., -// ) -// } diff --git a/modules/htlc/client/testutil/test_helpers.go b/modules/htlc/client/testutil/test_helpers.go deleted file mode 100644 index 7606cfed..00000000 --- a/modules/htlc/client/testutil/test_helpers.go +++ /dev/null @@ -1,59 +0,0 @@ -package testutil - -// import ( -// "fmt" -// "testing" - -// "github.com/cometbft/cometbft/libs/cli" - -// "github.com/cosmos/cosmos-sdk/client" -// "github.com/cosmos/cosmos-sdk/client/flags" - -// "mods.irisnet.org/simapp" -// htlccli "mods.irisnet.org/modules/htlc/client/cli" -// htlctypes "mods.irisnet.org/modules/htlc/types" -// ) - -// // MsgRedelegateExec creates a redelegate message. -// func CreateHTLCExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// extraArgs ...string) *simapp.ResponseTx { -// args := []string{ -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) -// return network.ExecTxCmdWithResult(t, clientCtx, htlccli.GetCmdCreateHTLC(), args) -// } - -// func ClaimHTLCExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// id string, -// secret string, -// extraArgs ...string) *simapp.ResponseTx { -// args := []string{ -// id, -// secret, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) -// return network.ExecTxCmdWithResult(t, clientCtx, htlccli.GetCmdClaimHTLC(), args) -// } - -// func QueryHTLCExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// id string, -// extraArgs ...string) *htlctypes.HTLC { -// args := []string{ -// id, -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) -// response := &htlctypes.HTLC{} -// network.ExecQueryCmd(t, clientCtx, htlccli.GetCmdQueryHTLC(), args, response) -// return response -// } diff --git a/modules/mt/client/cli/cli_test.go b/modules/mt/client/cli/cli_test.go deleted file mode 100644 index de55b8ca..00000000 --- a/modules/mt/client/cli/cli_test.go +++ /dev/null @@ -1,216 +0,0 @@ -package cli_test - -// import ( -// "fmt" -// "testing" - -// "github.com/stretchr/testify/suite" - -// "github.com/cometbft/cometbft/crypto" - -// "github.com/cosmos/cosmos-sdk/client/flags" -// sdk "github.com/cosmos/cosmos-sdk/types" - -// "mods.irisnet.org/simapp" -// mtcli "mods.irisnet.org/modules/mt/client/cli" -// mttestutil "mods.irisnet.org/modules/mt/client/testutil" -// mttypes "mods.irisnet.org/modules/mt/types" -// ) - -// type IntegrationTestSuite struct { -// suite.Suite - -// network simapp.Network -// } - -// func (s *IntegrationTestSuite) SetupSuite() { -// s.T().Log("setting up integration test suite") - -// s.network = simapp.SetupNetwork(s.T()) -// } - -// func (s *IntegrationTestSuite) TearDownSuite() { -// s.T().Log("tearing down integration test suite") -// s.network.Cleanup() -// } - -// func TestIntegrationTestSuite(t *testing.T) { -// suite.Run(t, new(IntegrationTestSuite)) -// } - -// func (s *IntegrationTestSuite) TestMT() { -// val := s.network.Validators[0] -// val2 := s.network.Validators[1] -// clientCtx := val.ClientCtx - -// // --------------------------------------------------------------------------- -// denomName := "name" -// data := "data" -// from := val.Address -// mintAmt := "10" -// transferAmt := "5" -// burnAmt := "5" - -// expectedCode := uint32(0) - -// //------test GetCmdIssueDenom()------------- -// args := []string{ -// fmt.Sprintf("--%s=%s", mtcli.FlagName, denomName), -// fmt.Sprintf("--%s=%s", mtcli.FlagData, data), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult := mttestutil.IssueDenomExec( -// s.T(), -// s.network, -// clientCtx, -// from.String(), -// args..., -// ) -// denomID := s.network.GetAttribute( -// mttypes.EventTypeIssueDenom, -// mttypes.AttributeKeyDenomID, -// txResult.Events, -// ) - -// //------test GetCmdQueryDenom()------------- -// queryDenomRespType := mttestutil.QueryDenomExec(s.T(), s.network, clientCtx, denomID) -// s.Require().Equal(denomName, queryDenomRespType.Name) -// s.Require().Equal([]byte(data), queryDenomRespType.Data) - -// //------test GetCmdQueryDenoms()------------- -// queryDenomsRespType := mttestutil.QueryDenomsExec(s.T(), s.network, clientCtx) -// s.Require().Equal(1, len(queryDenomsRespType.Denoms)) -// s.Require().Equal(denomID, queryDenomsRespType.Denoms[0].Id) - -// //------test GetCmdMintMT()------------- -// args = []string{ -// fmt.Sprintf("--%s=%s", mtcli.FlagRecipient, from.String()), -// fmt.Sprintf("--%s=%s", mtcli.FlagAmount, mintAmt), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(100))).String(), -// ), -// } - -// txResult = mttestutil.MintMTExec(s.T(), -// s.network, -// clientCtx, from.String(), denomID, args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// mtID := s.network.GetAttribute( -// mttypes.EventTypeMintMT, -// mttypes.AttributeKeyMTID, -// txResult.Events, -// ) -// //------test GetCmdQueryMT()------------- -// queryMTResponse := mttestutil.QueryMTExec(s.T(), s.network, clientCtx, denomID, mtID) -// s.Require().Equal(mtID, queryMTResponse.Id) - -// //-------test GetCmdQueryBalances()---------- -// queryBalancesResponse := mttestutil.QueryBlancesExec( -// s.T(), -// s.network, -// clientCtx, -// from.String(), -// denomID, -// ) -// s.Require().Equal(1, len(queryBalancesResponse.Balance)) -// s.Require().Equal(uint64(10), queryBalancesResponse.Balance[0].Amount) - -// //------test GetCmdEditMT()------------- -// newTokenDate := "newdata" -// args = []string{ -// fmt.Sprintf("--%s=%s", mtcli.FlagData, newTokenDate), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = mttestutil.EditMTExec(s.T(), -// s.network, -// clientCtx, from.String(), denomID, mtID, args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// queryMTResponse = mttestutil.QueryMTExec(s.T(), s.network, clientCtx, denomID, mtID) -// s.Require().Equal([]byte(newTokenDate), queryMTResponse.Data) - -// //------test GetCmdTransferMT()------------- -// recipient := sdk.AccAddress(crypto.AddressHash([]byte("dgsbl"))) - -// args = []string{ -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = mttestutil.TransferMTExec(s.T(), -// s.network, -// clientCtx, from.String(), recipient.String(), denomID, mtID, transferAmt, args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// queryMTResponse = mttestutil.QueryMTExec(s.T(), s.network, clientCtx, denomID, mtID) -// s.Require().Equal(mtID, queryMTResponse.Id) -// s.Require().Equal([]byte(newTokenDate), queryMTResponse.Data) - -// //------test GetCmdBurnMT()------------- -// args = []string{ -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = mttestutil.BurnMTExec(s.T(), -// s.network, -// clientCtx, from.String(), denomID, mtID, burnAmt, args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// queryMTResponse = mttestutil.QueryMTExec(s.T(), s.network, clientCtx, denomID, mtID) -// s.Require().Equal(mtID, queryMTResponse.Id) -// s.Require().Equal([]byte(newTokenDate), queryMTResponse.Data) -// s.Require().Equal(uint64(5), queryMTResponse.Supply) - -// //------test GetCmdTransferDenom()------------- -// args = []string{ -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = mttestutil.TransferDenomExec(s.T(), -// s.network, -// clientCtx, from.String(), val2.Address.String(), denomID, args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// queryDenomResponse := mttestutil.QueryDenomExec(s.T(), s.network, clientCtx, denomID) -// s.Require().Equal(val2.Address.String(), queryDenomResponse.Owner) -// s.Require().Equal(denomName, queryDenomResponse.Name) -// } diff --git a/modules/mt/client/testutil/grpc_query_test.go b/modules/mt/client/testutil/grpc_query_test.go deleted file mode 100644 index 277370b7..00000000 --- a/modules/mt/client/testutil/grpc_query_test.go +++ /dev/null @@ -1,161 +0,0 @@ -package testutil_test - -// import ( -// "fmt" -// "testing" - -// "github.com/cosmos/cosmos-sdk/client/flags" -// "github.com/cosmos/cosmos-sdk/testutil" -// sdk "github.com/cosmos/cosmos-sdk/types" -// "github.com/cosmos/gogoproto/proto" - -// mtcli "mods.irisnet.org/modules/mt/client/cli" -// mttestutil "mods.irisnet.org/modules/mt/client/testutil" -// mttypes "mods.irisnet.org/modules/mt/types" - -// "github.com/stretchr/testify/suite" - -// "mods.irisnet.org/simapp" -// ) - -// type IntegrationTestSuite struct { -// suite.Suite - -// network simapp.Network -// } - -// func (s *IntegrationTestSuite) SetupSuite() { -// s.network = simapp.SetupNetwork(s.T()) -// } - -// func (s *IntegrationTestSuite) TearDownSuite() { -// s.T().Log("tearing down integration test suite") -// s.network.Cleanup() -// } - -// func TestIntegrationTestSuite(t *testing.T) { -// suite.Run(t, new(IntegrationTestSuite)) -// } - -// func (s *IntegrationTestSuite) TestMT() { -// denomName := "name" -// data := "data" -// mintAmt := "10" -// mintAmtUint := uint64(10) - -// denomID := "" -// mtID := "" - -// val := s.network.Validators[0] -// from := val.Address -// baseURL := val.APIAddress - -// expectedCode := uint32(0) -// clientCtx := val.ClientCtx - -// // Issue -// args := []string{ -// fmt.Sprintf("--%s=%s", mtcli.FlagName, denomName), -// fmt.Sprintf("--%s=%s", mtcli.FlagData, data), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } -// txResult := mttestutil.IssueDenomExec( -// s.T(), -// s.network, -// clientCtx, -// from.String(), -// args..., -// ) -// s.Require().Equal(expectedCode, txResult.Code) -// denomID = s.network.GetAttribute( -// mttypes.EventTypeIssueDenom, -// mttypes.AttributeKeyDenomID, -// txResult.Events, -// ) - -// // Mint -// args = []string{ -// fmt.Sprintf("--%s=%s", mtcli.FlagRecipient, from.String()), -// fmt.Sprintf("--%s=%s", mtcli.FlagAmount, mintAmt), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(100))).String(), -// ), -// } - -// txResult = mttestutil.MintMTExec(s.T(), -// s.network, -// clientCtx, from.String(), denomID, args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// mtID = s.network.GetAttribute( -// mttypes.EventTypeMintMT, -// mttypes.AttributeKeyMTID, -// txResult.Events, -// ) - -// //Denom -// respType := proto.Message(&mttypes.QueryDenomResponse{}) -// url := fmt.Sprintf("%s/irismod/mt/denoms/%s", baseURL, denomID) -// resp, err := testutil.GetRequest(url) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, respType)) - -// denomItem := respType.(*mttypes.QueryDenomResponse) -// s.Require().Equal(denomID, denomItem.Denom.Id) -// s.Require().Equal([]byte(data), denomItem.Denom.Data) -// s.Require().Equal(val.Address.String(), denomItem.Denom.Owner) - -// //Denoms -// respType = proto.Message(&mttypes.QueryDenomsResponse{}) -// url = fmt.Sprintf("%s/irismod/mt/denoms", baseURL) -// resp, err = testutil.GetRequest(url) - -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, respType)) - -// denomsItem := respType.(*mttypes.QueryDenomsResponse) -// s.Require().Equal(1, len(denomsItem.Denoms)) -// s.Require().Equal(denomID, denomsItem.Denoms[0].Id) - -// //MTSupply -// respType = proto.Message(&mttypes.QueryMTSupplyResponse{}) -// url = fmt.Sprintf("%s/irismod/mt/mts/%s/%s/supply", baseURL, denomID, mtID) -// resp, err = testutil.GetRequest(url) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, respType)) - -// mtSupplyItem := respType.(*mttypes.QueryMTSupplyResponse) -// s.Require().Equal(mintAmtUint, mtSupplyItem.Amount) - -// //MT -// respType = proto.Message(&mttypes.QueryMTResponse{}) -// url = fmt.Sprintf("%s/irismod/mt/mts/%s/%s", baseURL, denomID, mtID) -// resp, err = testutil.GetRequest(url) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, respType)) - -// mtItem := respType.(*mttypes.QueryMTResponse) -// s.Require().Equal(mtID, mtItem.Mt.Id) - -// //MTs -// respType = proto.Message(&mttypes.QueryMTsResponse{}) -// url = fmt.Sprintf("%s/irismod/mt/mts/%s", baseURL, denomID) -// resp, err = testutil.GetRequest(url) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, respType)) - -// mtsItem := respType.(*mttypes.QueryMTsResponse) -// s.Require().Equal(1, len(mtsItem.Mts)) -// } diff --git a/modules/mt/client/testutil/test_helpers.go b/modules/mt/client/testutil/test_helpers.go deleted file mode 100644 index 20a123a6..00000000 --- a/modules/mt/client/testutil/test_helpers.go +++ /dev/null @@ -1,207 +0,0 @@ -package testutil - -// import ( -// "fmt" -// "testing" - -// "github.com/cometbft/cometbft/libs/cli" -// "github.com/cosmos/gogoproto/proto" - -// "github.com/cosmos/cosmos-sdk/client" -// "github.com/cosmos/cosmos-sdk/client/flags" - -// "mods.irisnet.org/simapp" -// mtcli "mods.irisnet.org/modules/mt/client/cli" -// mttypes "mods.irisnet.org/modules/mt/types" -// ) - -// // IssueDenomExec creates a redelegate message. -// func IssueDenomExec( -// t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// extraArgs ...string, -// ) *simapp.ResponseTx { -// args := []string{ -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, mtcli.GetCmdIssueDenom(), args) -// } - -// func BurnMTExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// denomID string, -// mtID string, -// amount string, -// extraArgs ...string, -// ) *simapp.ResponseTx { -// args := []string{ -// denomID, -// mtID, -// amount, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, mtcli.GetCmdBurnMT(), args) -// } - -// func MintMTExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// denomID string, -// extraArgs ...string, -// ) *simapp.ResponseTx { -// args := []string{ -// denomID, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, mtcli.GetCmdMintMT(), args) -// } - -// func EditMTExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// denomID string, -// mtID string, -// extraArgs ...string, -// ) *simapp.ResponseTx { -// args := []string{ -// denomID, -// mtID, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, mtcli.GetCmdEditMT(), args) -// } - -// func TransferMTExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// recipient string, -// denomID string, -// mtID string, -// amount string, -// extraArgs ...string, -// ) *simapp.ResponseTx { -// args := []string{ -// from, -// recipient, -// denomID, -// mtID, -// amount, -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, mtcli.GetCmdTransferMT(), args) -// } - -// func QueryDenomExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// denomID string, -// extraArgs ...string) *mttypes.Denom { -// args := []string{ -// denomID, -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) - -// response := &mttypes.Denom{} -// network.ExecQueryCmd(t, clientCtx, mtcli.GetCmdQueryDenom(), args, response) -// return response -// } - -// func QueryDenomsExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// extraArgs ...string) *mttypes.QueryDenomsResponse { -// args := []string{ -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) - -// response := &mttypes.QueryDenomsResponse{} -// network.ExecQueryCmd(t, clientCtx, mtcli.GetCmdQueryDenoms(), args, response) -// return response -// } - -// func QueryMTsExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// denomID string, -// resp proto.Message, -// extraArgs ...string, -// ) { -// args := []string{ -// denomID, -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) - -// network.ExecQueryCmd(t, clientCtx, mtcli.GetCmdQueryMTs(), args, resp) -// } - -// func QueryMTExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// denomID string, -// mtID string, -// extraArgs ...string) *mttypes.MT { -// args := []string{ -// denomID, -// mtID, -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) -// response := &mttypes.MT{} -// network.ExecQueryCmd(t, clientCtx, mtcli.GetCmdQueryMT(), args, response) -// return response -// } - -// func QueryBlancesExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// denomID string, -// extraArgs ...string) *mttypes.QueryBalancesResponse { -// args := []string{ -// from, -// denomID, -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) - -// response := &mttypes.QueryBalancesResponse{} -// network.ExecQueryCmd(t, clientCtx, mtcli.GetCmdQueryBalances(), args, response) -// return response -// } - -// func TransferDenomExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// recipient string, -// denomID string, -// extraArgs ...string, -// ) *simapp.ResponseTx { -// args := []string{ -// from, -// recipient, -// denomID, -// } - -// args = append(args, extraArgs...) -// return network.ExecTxCmdWithResult(t, clientCtx, mtcli.GetCmdTransferDenom(), args) -// } diff --git a/modules/oracle/client/cli/cli_test.go b/modules/oracle/client/cli/cli_test.go deleted file mode 100644 index a13854bd..00000000 --- a/modules/oracle/client/cli/cli_test.go +++ /dev/null @@ -1,248 +0,0 @@ -package cli_test - -// import ( -// "context" -// "encoding/json" -// "fmt" -// "strconv" -// "testing" - -// "github.com/stretchr/testify/suite" - -// "github.com/cosmos/cosmos-sdk/client/flags" -// sdk "github.com/cosmos/cosmos-sdk/types" - -// servicecli "mods.irisnet.org/modules/service/client/cli" -// servicetestutil "mods.irisnet.org/modules/service/client/testutil" -// servicetypes "mods.irisnet.org/modules/service/types" -// "mods.irisnet.org/simapp" -// oraclecli "mods.irisnet.org/modules/oracle/client/cli" -// oracletestutil "mods.irisnet.org/modules/oracle/client/testutil" -// ) - -// type IntegrationTestSuite struct { -// suite.Suite - -// network simapp.Network -// } - -// func (s *IntegrationTestSuite) SetupSuite() { -// s.T().Log("setting up integration test suite") - -// s.network = simapp.SetupNetwork(s.T()) -// } - -// func (s *IntegrationTestSuite) TearDownSuite() { -// s.T().Log("tearing down integration test suite") -// s.network.Cleanup() -// } - -// func TestIntegrationTestSuite(t *testing.T) { -// suite.Run(t, new(IntegrationTestSuite)) -// } - -// func (s *IntegrationTestSuite) TestOracle() { -// val := s.network.Validators[0] -// clientCtx := val.ClientCtx -// expectedCode := uint32(0) - -// // --------------------------------------------------------------------------- -// serviceName := "test-service" -// serviceDesc := "test-description" -// serviceAuthorDesc := "test-author-description" -// serviceTags := "tags1,tags2" -// serviceSchemas := `{"input":{"type":"object"},"output":{"type":"object"},"error":{"type":"object"}}` -// serviceDenom := sdk.DefaultBondDenom - -// serviceDeposit := fmt.Sprintf("50000%s", serviceDenom) -// servicePrices := fmt.Sprintf(`{"price": "50%s"}`, serviceDenom) -// qos := int64(3) -// options := "{}" - -// author := val.Address -// provider := author -// creator := author - -// feedName := "test-feed" -// aggregateFunc := "avg" -// valueJsonPath := "price" -// latestHistory := 10 -// description := "description" -// input := `{"header":{},"body":{}}` -// respResult := `{"code":200,"message":""}` -// respOutput := `{"header":{},"body":{"price":"2"}}` -// providers := provider -// timeout := 2 -// newTimeout := qos -// serviceFeeCap := fmt.Sprintf("50%s", serviceDenom) -// threshold := 1 -// frequency := 12 - -// //------Define && Bind Service------------- -// args := []string{ -// fmt.Sprintf("--%s=%s", servicecli.FlagName, serviceName), -// fmt.Sprintf("--%s=%s", servicecli.FlagDescription, serviceDesc), -// fmt.Sprintf("--%s=%s", servicecli.FlagTags, serviceTags), -// fmt.Sprintf("--%s=%s", servicecli.FlagAuthorDescription, serviceAuthorDesc), -// fmt.Sprintf("--%s=%s", servicecli.FlagSchemas, serviceSchemas), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String()), -// } - -// txResult := servicetestutil.DefineServiceExec(s.T(), s.network, clientCtx, author.String(), args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// //------test GetCmdBindService()------------- -// args = []string{ -// fmt.Sprintf("--%s=%s", servicecli.FlagServiceName, serviceName), -// fmt.Sprintf("--%s=%s", servicecli.FlagDeposit, serviceDeposit), -// fmt.Sprintf("--%s=%s", servicecli.FlagPricing, servicePrices), -// fmt.Sprintf("--%s=%d", servicecli.FlagQoS, qos), -// fmt.Sprintf("--%s=%s", servicecli.FlagOptions, options), -// fmt.Sprintf("--%s=%s", servicecli.FlagProvider, provider), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String()), -// } - -// txResult = servicetestutil.BindServiceExec(s.T(), s.network, clientCtx, provider.String(), args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// //------test GetCmdCreateFeed()------------- -// args = []string{ -// fmt.Sprintf("--%s=%s", oraclecli.FlagFeedName, feedName), -// fmt.Sprintf("--%s=%s", oraclecli.FlagAggregateFunc, aggregateFunc), -// fmt.Sprintf("--%s=%s", oraclecli.FlagValueJsonPath, valueJsonPath), -// fmt.Sprintf("--%s=%d", oraclecli.FlagLatestHistory, latestHistory), -// fmt.Sprintf("--%s=%s", oraclecli.FlagDescription, description), -// fmt.Sprintf("--%s=%s", oraclecli.FlagServiceFeeCap, serviceFeeCap), -// fmt.Sprintf("--%s=%s", oraclecli.FlagServiceName, serviceName), -// fmt.Sprintf("--%s=%s", oraclecli.FlagInput, input), -// fmt.Sprintf("--%s=%s", oraclecli.FlagProviders, providers), -// fmt.Sprintf("--%s=%d", oraclecli.FlagTimeout, timeout), -// fmt.Sprintf("--%s=%d", oraclecli.FlagThreshold, threshold), -// fmt.Sprintf("--%s=%d", oraclecli.FlagFrequency, frequency), -// fmt.Sprintf("--%s=%s", oraclecli.FlagCreator, creator), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String()), -// } - -// txResult = oracletestutil.CreateFeedExec(s.T(), s.network, clientCtx, creator.String(), args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// // ------test GetCmdQueryFeed()------------- - -// feedContext := oracletestutil.QueryFeedExec(s.T(), s.network, clientCtx, feedName) -// s.Require().Equal(feedName, feedContext.Feed.FeedName) -// s.Require().Equal(servicetypes.PAUSED, feedContext.State) - -// // ------test GetCmdQueryFeeds()------------- -// feedsResp := oracletestutil.QueryFeedsExec(s.T(), s.network, clientCtx) -// s.Require().Len(feedsResp.Feeds, 1) -// s.Require().Equal(*feedContext, feedsResp.Feeds[0]) - -// // ------test GetCmdStartFeed()------------- -// args = []string{ -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String()), -// } - -// txResult = oracletestutil.StartFeedExec(s.T(), s.network, clientCtx, creator.String(), feedName, args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// feedContext = oracletestutil.QueryFeedExec(s.T(), s.network, clientCtx, feedName) -// s.Require().Equal(servicetypes.RUNNING, feedContext.State) - -// // ------test GetCmdPauseFeed()------------- -// txResult = oracletestutil.PauseFeedExec(s.T(), s.network, clientCtx, creator.String(), feedName, args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// feedContext = oracletestutil.QueryFeedExec(s.T(), s.network, clientCtx, feedName) -// s.Require().Equal(servicetypes.PAUSED, feedContext.State) - -// // ------test GetCmdEditFeed()------------- -// args = []string{ -// fmt.Sprintf("--%s=%d", oraclecli.FlagTimeout, newTimeout), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String()), -// } - -// txResult = oracletestutil.EditFeedExec(s.T(), s.network, clientCtx, creator.String(), feedName, args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// feedContext = oracletestutil.QueryFeedExec(s.T(), s.network, clientCtx, feedName) -// s.Require().Equal(newTimeout, feedContext.Timeout) -// s.Require().Equal(servicetypes.PAUSED, feedContext.State) - -// // ------test GetCmdQueryFeedValue()------------- -// feedValueResp := oracletestutil.QueryFeedValueExec(s.T(), s.network, clientCtx, feedName) -// s.Require().Len(feedValueResp.FeedValues, 0) - -// // ------restart Feed------------- -// args = []string{ -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String()), -// } - -// txResult = oracletestutil.StartFeedExec(s.T(), s.network, clientCtx, creator.String(), feedName, args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// feedContext = oracletestutil.QueryFeedExec(s.T(), s.network, clientCtx, feedName) -// s.Require().Equal(servicetypes.RUNNING, feedContext.State) - -// // ------get request------------- -// requestHeight := txResult.Height - -// blockResult, err := val.RPCClient.BlockResults(context.Background(), &requestHeight) -// s.Require().NoError(err) -// var requestId string -// for _, event := range blockResult.EndBlockEvents { -// if event.Type == servicetypes.EventTypeNewBatchRequestProvider { -// var found bool -// var requestIds []string -// var requestsBz []byte -// for _, attribute := range event.Attributes { -// if string(attribute.Key) == servicetypes.AttributeKeyRequests { -// requestsBz = []byte(attribute.GetValue()) -// found = true -// } -// } -// s.Require().True(found) -// if found { -// err := json.Unmarshal(requestsBz, &requestIds) -// s.Require().NoError(err) -// } -// s.Require().Len(requestIds, 1) -// requestId = requestIds[0] -// } -// } -// s.Require().NotNil(requestId) - -// //------respond service------------- -// args = []string{ -// fmt.Sprintf("--%s=%s", servicecli.FlagRequestID, requestId), -// fmt.Sprintf("--%s=%s", servicecli.FlagResult, respResult), -// fmt.Sprintf("--%s=%s", servicecli.FlagData, respOutput), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String()), -// } - -// txResult = servicetestutil.RespondServiceExec(s.T(), s.network, clientCtx, provider.String(), args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// // ------get feedValue------------- -// feedValueResp = oracletestutil.QueryFeedValueExec(s.T(), s.network, clientCtx, feedName) -// s.Require().Len(feedValueResp.FeedValues, 1) -// s.Require().Equal((strconv.FormatFloat(2, 'f', 8, 64)), feedValueResp.FeedValues[0].Data) -// } diff --git a/modules/oracle/client/testutil/grpc_query_test.go b/modules/oracle/client/testutil/grpc_query_test.go deleted file mode 100644 index 9b8cd2d6..00000000 --- a/modules/oracle/client/testutil/grpc_query_test.go +++ /dev/null @@ -1,189 +0,0 @@ -package testutil_test - -// import ( -// "fmt" -// "testing" - -// "github.com/cosmos/gogoproto/proto" -// "github.com/stretchr/testify/suite" - -// "github.com/cosmos/cosmos-sdk/client/flags" -// "github.com/cosmos/cosmos-sdk/testutil" -// sdk "github.com/cosmos/cosmos-sdk/types" - -// servicecli "mods.irisnet.org/modules/service/client/cli" -// servicetestutil "mods.irisnet.org/modules/service/client/testutil" -// servicetypes "mods.irisnet.org/modules/service/types" -// "mods.irisnet.org/simapp" -// oraclecli "mods.irisnet.org/modules/oracle/client/cli" -// oracletestutil "mods.irisnet.org/modules/oracle/client/testutil" -// oracletypes "mods.irisnet.org/modules/oracle/types" -// ) - -// type IntegrationTestSuite struct { -// suite.Suite - -// network simapp.Network -// } - -// func (s *IntegrationTestSuite) SetupSuite() { -// s.T().Log("setting up integration test suite") - -// s.network = simapp.SetupNetwork(s.T()) -// } - -// func (s *IntegrationTestSuite) TearDownSuite() { -// s.T().Log("tearing down integration test suite") -// s.network.Cleanup() -// } - -// func TestIntegrationTestSuite(t *testing.T) { -// suite.Run(t, new(IntegrationTestSuite)) -// } - -// func (s *IntegrationTestSuite) TestOracle() { -// val := s.network.Validators[0] -// clientCtx := val.ClientCtx -// expectedCode := uint32(0) - -// // --------------------------------------------------------------------------- -// serviceName := "test-service" -// serviceDesc := "test-description" -// serviceAuthorDesc := "test-author-description" -// serviceTags := "tags1,tags2" -// serviceSchemas := `{"input":{"type":"object"},"output":{"type":"object"},"error":{"type":"object"}}` -// serviceDenom := sdk.DefaultBondDenom - -// serviceDeposit := fmt.Sprintf("50000%s", serviceDenom) -// servicePrices := fmt.Sprintf(`{"price": "50%s"}`, serviceDenom) -// qos := int64(3) -// options := "{}" - -// author := val.Address -// provider := author -// creator := author - -// feedName := "test-feed" -// aggregateFunc := "avg" -// valueJsonPath := "price" -// latestHistory := 10 -// description := "description" -// input := `{"header":{},"body":{}}` -// providers := provider -// timeout := 2 -// serviceFeeCap := fmt.Sprintf("50%s", serviceDenom) -// threshold := 1 -// frequency := 12 -// baseURL := val.APIAddress - -// //------Define && Bind Service------------- -// args := []string{ -// fmt.Sprintf("--%s=%s", servicecli.FlagName, serviceName), -// fmt.Sprintf("--%s=%s", servicecli.FlagDescription, serviceDesc), -// fmt.Sprintf("--%s=%s", servicecli.FlagTags, serviceTags), -// fmt.Sprintf("--%s=%s", servicecli.FlagAuthorDescription, serviceAuthorDesc), -// fmt.Sprintf("--%s=%s", servicecli.FlagSchemas, serviceSchemas), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult := servicetestutil.DefineServiceExec( -// s.T(), -// s.network, -// clientCtx, -// author.String(), -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// //------test GetCmdBindService()------------- -// args = []string{ -// fmt.Sprintf("--%s=%s", servicecli.FlagServiceName, serviceName), -// fmt.Sprintf("--%s=%s", servicecli.FlagDeposit, serviceDeposit), -// fmt.Sprintf("--%s=%s", servicecli.FlagPricing, servicePrices), -// fmt.Sprintf("--%s=%d", servicecli.FlagQoS, qos), -// fmt.Sprintf("--%s=%s", servicecli.FlagOptions, options), -// fmt.Sprintf("--%s=%s", servicecli.FlagProvider, provider), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = servicetestutil.BindServiceExec( -// s.T(), -// s.network, -// clientCtx, -// provider.String(), -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// //------test GetCmdCreateFeed()------------- -// args = []string{ -// fmt.Sprintf("--%s=%s", oraclecli.FlagFeedName, feedName), -// fmt.Sprintf("--%s=%s", oraclecli.FlagAggregateFunc, aggregateFunc), -// fmt.Sprintf("--%s=%s", oraclecli.FlagValueJsonPath, valueJsonPath), -// fmt.Sprintf("--%s=%d", oraclecli.FlagLatestHistory, latestHistory), -// fmt.Sprintf("--%s=%s", oraclecli.FlagDescription, description), -// fmt.Sprintf("--%s=%s", oraclecli.FlagServiceFeeCap, serviceFeeCap), -// fmt.Sprintf("--%s=%s", oraclecli.FlagServiceName, serviceName), -// fmt.Sprintf("--%s=%s", oraclecli.FlagInput, input), -// fmt.Sprintf("--%s=%s", oraclecli.FlagProviders, providers), -// fmt.Sprintf("--%s=%d", oraclecli.FlagTimeout, timeout), -// fmt.Sprintf("--%s=%d", oraclecli.FlagThreshold, threshold), -// fmt.Sprintf("--%s=%d", oraclecli.FlagFrequency, frequency), -// fmt.Sprintf("--%s=%s", oraclecli.FlagCreator, creator), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = oracletestutil.CreateFeedExec(s.T(), s.network, clientCtx, creator.String(), args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// // ------test GetCmdQueryFeed()------------- -// url := fmt.Sprintf("%s/irismod/oracle/feeds/%s", baseURL, feedName) -// resp, err := testutil.GetRequest(url) -// s.Require().NoError(err) -// respType := proto.Message(&oracletypes.QueryFeedResponse{}) -// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(resp, respType)) -// feedResp := respType.(*oracletypes.QueryFeedResponse) -// s.Require().NoError(err) -// s.Require().Equal(feedName, feedResp.Feed.Feed.FeedName) -// s.Require().Equal(servicetypes.PAUSED, feedResp.Feed.State) - -// // ------test GetCmdQueryFeeds()------------- -// url = fmt.Sprintf("%s/irismod/oracle/feeds", baseURL) -// resp, err = testutil.GetRequest(url) -// s.Require().NoError(err) -// respType = proto.Message(&oracletypes.QueryFeedsResponse{}) -// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(resp, respType)) -// feedsResp := respType.(*oracletypes.QueryFeedsResponse) -// s.Require().NoError(err) -// s.Require().Len(feedsResp.Feeds, 1) -// s.Require().Equal(feedResp.Feed, feedsResp.Feeds[0]) - -// // ------test GetCmdQueryFeedValue()------------- -// url = fmt.Sprintf("%s/irismod/oracle/feeds/%s/values", baseURL, feedName) -// resp, err = testutil.GetRequest(url) -// respType = proto.Message(&oracletypes.QueryFeedValueResponse{}) -// s.Require().NoError(err) -// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(resp, respType)) -// feedValueResp := respType.(*oracletypes.QueryFeedValueResponse) -// s.Require().NoError(err) -// s.Require().Len(feedValueResp.FeedValues, 0) -// } diff --git a/modules/oracle/client/testutil/test-helpers.go b/modules/oracle/client/testutil/test-helpers.go deleted file mode 100644 index 95667d8c..00000000 --- a/modules/oracle/client/testutil/test-helpers.go +++ /dev/null @@ -1,120 +0,0 @@ -package testutil - -// import ( -// "fmt" -// "testing" - -// "github.com/cometbft/cometbft/libs/cli" - -// "github.com/cosmos/cosmos-sdk/client" -// "github.com/cosmos/cosmos-sdk/client/flags" - -// "mods.irisnet.org/simapp" -// oraclecli "mods.irisnet.org/modules/oracle/client/cli" -// oracletypes "mods.irisnet.org/modules/oracle/types" -// ) - -// // MsgRedelegateExec creates a redelegate message. -// func CreateFeedExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// extraArgs ...string) *simapp.ResponseTx { -// args := []string{ -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, oraclecli.GetCmdCreateFeed(), args) -// } - -// func EditFeedExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// feedName string, -// extraArgs ...string) *simapp.ResponseTx { -// args := []string{ -// feedName, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, oraclecli.GetCmdEditFeed(), args) -// } - -// func StartFeedExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// feedName string, -// extraArgs ...string) *simapp.ResponseTx { -// args := []string{ -// feedName, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, oraclecli.GetCmdStartFeed(), args) -// } - -// func PauseFeedExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// feedName string, -// extraArgs ...string) *simapp.ResponseTx { -// args := []string{ -// feedName, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, oraclecli.GetCmdPauseFeed(), args) -// } - -// func QueryFeedExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// feedName string, -// extraArgs ...string) *oracletypes.FeedContext { -// args := []string{ -// feedName, -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) - -// response := &oracletypes.FeedContext{} -// network.ExecQueryCmd(t, clientCtx, oraclecli.GetCmdQueryFeed(), args, response) -// return response -// } - -// func QueryFeedsExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// extraArgs ...string) *oracletypes.QueryFeedsResponse { -// args := []string{ -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) - -// response := &oracletypes.QueryFeedsResponse{} -// network.ExecQueryCmd(t, clientCtx, oraclecli.GetCmdQueryFeeds(), args, response) -// return response -// } - -// func QueryFeedValueExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// feedName string, -// extraArgs ...string) *oracletypes.QueryFeedValueResponse { -// args := []string{ -// feedName, -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) - -// response := &oracletypes.QueryFeedValueResponse{} -// network.ExecQueryCmd(t, clientCtx, oraclecli.GetCmdQueryFeedValue(), args, response) -// return response -// } diff --git a/modules/random/client/cli/cli_test.go b/modules/random/client/cli/cli_test.go deleted file mode 100644 index a0b423e0..00000000 --- a/modules/random/client/cli/cli_test.go +++ /dev/null @@ -1,194 +0,0 @@ -package cli_test - -// import ( -// "context" -// "encoding/hex" -// "encoding/json" -// "fmt" -// "testing" -// "time" - -// "github.com/stretchr/testify/suite" -// "github.com/tidwall/gjson" - -// "github.com/cosmos/cosmos-sdk/client/flags" -// sdk "github.com/cosmos/cosmos-sdk/types" - -// servicecli "mods.irisnet.org/modules/service/client/cli" -// servicetestutil "mods.irisnet.org/modules/service/client/testutil" -// servicetypes "mods.irisnet.org/modules/service/types" -// "mods.irisnet.org/simapp" -// randomcli "mods.irisnet.org/modules/random/client/cli" -// randomtestutil "mods.irisnet.org/modules/random/client/testutil" -// randomtypes "mods.irisnet.org/modules/random/types" -// ) - -// type IntegrationTestSuite struct { -// suite.Suite - -// network simapp.Network -// } - -// func (s *IntegrationTestSuite) SetupSuite() { -// s.T().Log("setting up integration test suite") - -// s.network = simapp.SetupNetwork(s.T()) -// } - -// func (s *IntegrationTestSuite) TearDownSuite() { -// s.T().Log("tearing down integration test suite") -// s.network.Cleanup() -// } - -// func TestIntegrationTestSuite(t *testing.T) { -// suite.Run(t, new(IntegrationTestSuite)) -// } - -// func (s *IntegrationTestSuite) TestRandom() { -// val := s.network.Validators[0] -// clientCtx := val.ClientCtx -// expectedCode := uint32(0) - -// // --------------------------------------------------------------------------- -// serviceDeposit := fmt.Sprintf("50000%s", s.network.BondDenom) -// servicePrices := fmt.Sprintf(`{"price": "50%s"}`, s.network.BondDenom) -// qos := int64(3) -// options := "{}" -// provider := val.Address - -// from := val.Address -// blockInterval := 4 -// oracle := true -// serviceFeeCap := fmt.Sprintf("50%s", s.network.BondDenom) - -// respResult := `{"code":200,"message":""}` -// seedStr := "ABCDEF12ABCDEF12ABCDEF12ABCDEF12ABCDEF12ABCDEF12ABCDEF12ABCDEF12" -// respOutput := fmt.Sprintf(`{"header":{},"body":{"seed":"%s"}}`, seedStr) - -// // ------bind random service------------- -// args := []string{ -// fmt.Sprintf("--%s=%s", servicecli.FlagServiceName, randomtypes.ServiceName), -// fmt.Sprintf("--%s=%s", servicecli.FlagDeposit, serviceDeposit), -// fmt.Sprintf("--%s=%s", servicecli.FlagPricing, servicePrices), -// fmt.Sprintf("--%s=%d", servicecli.FlagQoS, qos), -// fmt.Sprintf("--%s=%s", servicecli.FlagOptions, options), -// fmt.Sprintf("--%s=%s", servicecli.FlagProvider, provider), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult := servicetestutil.BindServiceExec( -// s.T(), -// s.network, -// clientCtx, -// provider.String(), -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// // ------test GetCmdRequestRandom()------------- -// args = []string{ -// fmt.Sprintf("--%s=%s", randomcli.FlagServiceFeeCap, serviceFeeCap), -// fmt.Sprintf("--%s=%t", randomcli.FlagOracle, oracle), -// fmt.Sprintf("--%s=%d", randomcli.FlagBlockInterval, blockInterval), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = randomtestutil.RequestRandomExec(s.T(), s.network, clientCtx, from.String(), args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// requestID := gjson.Get(txResult.Log, "0.events.1.attributes.0.value").String() -// requestHeight := gjson.Get(txResult.Log, "0.events.1.attributes.2.value").Int() - -// // ------test GetCmdQueryRandomRequestQueue()------------- -// qrrResp := randomtestutil.QueryRandomRequestQueueExec( -// s.T(), -// s.network, -// clientCtx, -// fmt.Sprintf("%d", requestHeight), -// ) -// s.Require().Len(qrrResp.Requests, 1) - -// // ------get service request------------- -// requestHeight = requestHeight + 1 -// _, err := s.network.WaitForHeightWithTimeout( -// requestHeight, -// time.Duration(int64(blockInterval+5)*int64(s.network.TimeoutCommit)), -// ) -// s.Require().NoError(err) - -// blockResult, err := val.RPCClient.BlockResults(context.Background(), &requestHeight) -// s.Require().NoError(err) -// var requestId string -// for _, event := range blockResult.EndBlockEvents { -// if event.Type == servicetypes.EventTypeNewBatchRequestProvider { -// var found bool -// var requestIds []string -// var requestsBz []byte -// for _, attribute := range event.Attributes { -// if string(attribute.Key) == servicetypes.AttributeKeyRequests { -// requestsBz = []byte(attribute.GetValue()) -// found = true -// } -// } -// s.Require().True(found) -// if found { -// err := json.Unmarshal(requestsBz, &requestIds) -// s.Require().NoError(err) -// } -// s.Require().Len(requestIds, 1) -// requestId = requestIds[0] -// } -// } -// s.Require().NotNil(requestId) - -// // ------respond service request------------- -// args = []string{ -// fmt.Sprintf("--%s=%s", servicecli.FlagRequestID, requestId), -// fmt.Sprintf("--%s=%s", servicecli.FlagResult, respResult), -// fmt.Sprintf("--%s=%s", servicecli.FlagData, respOutput), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = servicetestutil.RespondServiceExec( -// s.T(), -// s.network, -// clientCtx, -// provider.String(), -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// generateHeight := txResult.Height - -// // ------test GetCmdQueryRandom()------------- -// randomResp := randomtestutil.QueryRandomExec(s.T(), s.network, clientCtx, requestID) -// s.Require().NotNil(randomResp.Value) - -// generateBLock, err := clientCtx.Client.Block(context.Background(), &generateHeight) -// s.Require().NoError(err) -// seed, err := hex.DecodeString(seedStr) -// s.Require().NoError(err) -// random := randomtypes.MakePRNG(generateBLock.Block.LastBlockID.Hash, generateBLock.Block.Header.Time.Unix(), from, seed, true). -// GetRand(). -// FloatString(randomtypes.RandPrec) -// s.Require().Equal(random, randomResp.Value) -// } diff --git a/modules/random/client/testutil/grpc_query_test.go b/modules/random/client/testutil/grpc_query_test.go deleted file mode 100644 index 1cc6aec6..00000000 --- a/modules/random/client/testutil/grpc_query_test.go +++ /dev/null @@ -1,194 +0,0 @@ -package testutil_test - -// import ( -// "context" -// "encoding/json" -// "fmt" -// "testing" -// "time" - -// "github.com/cosmos/gogoproto/proto" -// "github.com/stretchr/testify/suite" -// "github.com/tidwall/gjson" - -// "github.com/cosmos/cosmos-sdk/client/flags" -// "github.com/cosmos/cosmos-sdk/testutil" -// sdk "github.com/cosmos/cosmos-sdk/types" - -// servicecli "mods.irisnet.org/modules/service/client/cli" -// servicetestutil "mods.irisnet.org/modules/service/client/testutil" -// servicetypes "mods.irisnet.org/modules/service/types" -// "mods.irisnet.org/simapp" -// randomcli "mods.irisnet.org/modules/random/client/cli" -// randomtestutil "mods.irisnet.org/modules/random/client/testutil" -// randomtypes "mods.irisnet.org/modules/random/types" -// ) - -// type IntegrationTestSuite struct { -// suite.Suite - -// network simapp.Network -// } - -// func (s *IntegrationTestSuite) SetupSuite() { -// s.T().Log("setting up integration test suite") - -// s.network = simapp.SetupNetwork(s.T()) -// } - -// func (s *IntegrationTestSuite) TearDownSuite() { -// s.T().Log("tearing down integration test suite") -// s.network.Cleanup() -// } - -// func TestIntegrationTestSuite(t *testing.T) { -// suite.Run(t, new(IntegrationTestSuite)) -// } - -// func (s *IntegrationTestSuite) TestRandom() { -// val := s.network.Validators[0] -// clientCtx := val.ClientCtx -// expectedCode := uint32(0) - -// // --------------------------------------------------------------------------- -// serviceDeposit := fmt.Sprintf("50000%s", s.network.BondDenom) -// servicePrices := fmt.Sprintf(`{"price": "50%s"}`, s.network.BondDenom) -// qos := int64(3) -// options := "{}" -// provider := val.Address -// baseURL := val.APIAddress - -// from := val.Address -// blockInterval := 4 -// oracle := true -// serviceFeeCap := fmt.Sprintf("50%s", s.network.BondDenom) - -// respResult := `{"code":200,"message":""}` -// seedStr := "ABCDEF12ABCDEF12ABCDEF12ABCDEF12ABCDEF12ABCDEF12ABCDEF12ABCDEF12" -// respOutput := fmt.Sprintf(`{"header":{},"body":{"seed":"%s"}}`, seedStr) - -// // ------bind random service------------- -// args := []string{ -// fmt.Sprintf("--%s=%s", servicecli.FlagServiceName, randomtypes.ServiceName), -// fmt.Sprintf("--%s=%s", servicecli.FlagDeposit, serviceDeposit), -// fmt.Sprintf("--%s=%s", servicecli.FlagPricing, servicePrices), -// fmt.Sprintf("--%s=%d", servicecli.FlagQoS, qos), -// fmt.Sprintf("--%s=%s", servicecli.FlagOptions, options), -// fmt.Sprintf("--%s=%s", servicecli.FlagProvider, provider), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult := servicetestutil.BindServiceExec( -// s.T(), -// s.network, -// clientCtx, -// provider.String(), -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// // ------test GetCmdRequestRandom()------------- -// args = []string{ -// fmt.Sprintf("--%s=%s", randomcli.FlagServiceFeeCap, serviceFeeCap), -// fmt.Sprintf("--%s=%t", randomcli.FlagOracle, oracle), -// fmt.Sprintf("--%s=%d", randomcli.FlagBlockInterval, blockInterval), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = randomtestutil.RequestRandomExec(s.T(), s.network, clientCtx, from.String(), args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// requestID := gjson.Get(txResult.Log, "0.events.1.attributes.0.value").String() -// requestHeight := gjson.Get(txResult.Log, "0.events.1.attributes.2.value").Int() - -// // ------test GetCmdQueryRandomRequestQueue()------------- -// url := fmt.Sprintf("%s/irismod/random/queue", baseURL) -// resp, err := testutil.GetRequest(url) -// respType := proto.Message(&randomtypes.QueryRandomRequestQueueResponse{}) -// s.Require().NoError(err) -// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(resp, respType)) -// qrrResp := respType.(*randomtypes.QueryRandomRequestQueueResponse) -// s.Require().NoError(err) -// s.Require().Len(qrrResp.Requests, 1) - -// // ------get service request------------- -// requestHeight = requestHeight + 1 -// _, err = s.network.WaitForHeightWithTimeout( -// requestHeight, -// time.Duration(int64(blockInterval+2)*int64(s.network.TimeoutCommit)), -// ) -// if err != nil { -// s.network.WaitForNBlock(2) -// } - -// blockResult, err := val.RPCClient.BlockResults(context.Background(), &requestHeight) -// s.Require().NoError(err) -// var requestId string -// for _, event := range blockResult.EndBlockEvents { -// if event.Type == servicetypes.EventTypeNewBatchRequestProvider { -// var found bool -// var requestIds []string -// var requestsBz []byte -// for _, attribute := range event.Attributes { -// if string(attribute.Key) == servicetypes.AttributeKeyRequests { -// requestsBz = []byte(attribute.Value) -// found = true -// } -// } -// s.Require().True(found) -// if found { -// err := json.Unmarshal(requestsBz, &requestIds) -// s.Require().NoError(err) -// } -// s.Require().Len(requestIds, 1) -// requestId = requestIds[0] -// } -// } -// s.Require().NotEmpty(requestId) - -// // ------respond service request------------- -// args = []string{ -// fmt.Sprintf("--%s=%s", servicecli.FlagRequestID, requestId), -// fmt.Sprintf("--%s=%s", servicecli.FlagResult, respResult), -// fmt.Sprintf("--%s=%s", servicecli.FlagData, respOutput), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = servicetestutil.RespondServiceExec( -// s.T(), -// s.network, -// clientCtx, -// provider.String(), -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// // ------test GetCmdQueryRandom()------------- -// url = fmt.Sprintf("%s/irismod/random/randoms/%s", baseURL, requestID) -// resp, err = testutil.GetRequest(url) -// respType = proto.Message(&randomtypes.QueryRandomResponse{}) -// s.Require().NoError(err) -// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(resp, respType)) -// randomResp := respType.(*randomtypes.QueryRandomResponse) -// s.Require().NoError(err) -// s.Require().NotNil(randomResp.Random.Value) -// } diff --git a/modules/random/client/testutil/test_helpers.go b/modules/random/client/testutil/test_helpers.go deleted file mode 100644 index 0c6c10a4..00000000 --- a/modules/random/client/testutil/test_helpers.go +++ /dev/null @@ -1,62 +0,0 @@ -package testutil - -// import ( -// "fmt" -// "testing" - -// "github.com/cometbft/cometbft/libs/cli" - -// "github.com/cosmos/cosmos-sdk/client" -// "github.com/cosmos/cosmos-sdk/client/flags" - -// "mods.irisnet.org/simapp" -// randomcli "mods.irisnet.org/modules/random/client/cli" -// randomtypes "mods.irisnet.org/modules/random/types" -// ) - -// // MsgRedelegateExec creates a redelegate message. -// func RequestRandomExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// extraArgs ...string, -// ) *simapp.ResponseTx { -// args := []string{ -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, randomcli.GetCmdRequestRandom(), args) -// } - -// func QueryRandomExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// requestID string, -// extraArgs ...string) *randomtypes.Random { -// args := []string{ -// requestID, -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) - -// response := &randomtypes.Random{} -// network.ExecQueryCmd(t, clientCtx, randomcli.GetCmdQueryRandom(), args, response) -// return response -// } - -// func QueryRandomRequestQueueExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// genHeight string, -// extraArgs ...string) *randomtypes.QueryRandomRequestQueueResponse { -// args := []string{ -// genHeight, -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) - -// response := &randomtypes.QueryRandomRequestQueueResponse{} -// network.ExecQueryCmd(t, clientCtx, randomcli.GetCmdQueryRandomRequestQueue(), args, response) -// return response -// } diff --git a/modules/record/client/cli/cli_test.go b/modules/record/client/cli/cli_test.go deleted file mode 100644 index 75e6724b..00000000 --- a/modules/record/client/cli/cli_test.go +++ /dev/null @@ -1,81 +0,0 @@ -package cli_test - -// import ( -// "fmt" -// "testing" - -// "github.com/stretchr/testify/suite" - -// "github.com/cosmos/cosmos-sdk/client/flags" -// sdk "github.com/cosmos/cosmos-sdk/types" - -// "mods.irisnet.org/simapp" -// recordcli "mods.irisnet.org/modules/record/client/cli" -// recordtestutil "mods.irisnet.org/modules/record/client/testutil" -// recordtypes "mods.irisnet.org/modules/record/types" -// ) - -// type IntegrationTestSuite struct { -// suite.Suite - -// network simapp.Network -// } - -// func (s *IntegrationTestSuite) SetupSuite() { -// s.T().Log("setting up integration test suite") - -// s.network = simapp.SetupNetwork(s.T()) -// } - -// func (s *IntegrationTestSuite) TearDownSuite() { -// s.T().Log("tearing down integration test suite") -// s.network.Cleanup() -// } - -// func TestIntegrationTestSuite(t *testing.T) { -// suite.Run(t, new(IntegrationTestSuite)) -// } - -// func (s *IntegrationTestSuite) TestRecord() { -// val := s.network.Validators[0] -// clientCtx := val.ClientCtx - -// // --------------------------------------------------------------------------- - -// from := val.Address -// digest := "digest" -// digestAlgo := "digest-algo" -// uri := "uri" -// meta := "meta" - -// args := []string{ -// fmt.Sprintf("--%s=%s", recordcli.FlagURI, uri), -// fmt.Sprintf("--%s=%s", recordcli.FlagMeta, meta), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String()), -// } - -// expectedCode := uint32(0) - -// txResult := recordtestutil.CreateRecordExec(s.T(), -// s.network, -// clientCtx, from.String(), digest, digestAlgo, args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// recordID := s.network.GetAttribute(recordtypes.EventTypeCreateRecord, recordtypes.AttributeKeyRecordID, txResult.Events) - -// // --------------------------------------------------------------------------- - -// record := &recordtypes.Record{} -// expectedContents := []recordtypes.Content{{ -// Digest: digest, -// DigestAlgo: digestAlgo, -// URI: uri, -// Meta: meta, -// }} - -// recordtestutil.QueryRecordExec(s.T(), s.network, clientCtx, recordID, record) -// s.Require().Equal(expectedContents, record.Contents) -// } diff --git a/modules/record/client/testutil/grpc_query_test.go b/modules/record/client/testutil/grpc_query_test.go deleted file mode 100644 index 47a27779..00000000 --- a/modules/record/client/testutil/grpc_query_test.go +++ /dev/null @@ -1,96 +0,0 @@ -package testutil_test - -// import ( -// "fmt" -// "testing" - -// "github.com/cosmos/gogoproto/proto" -// "github.com/stretchr/testify/suite" - -// "github.com/cosmos/cosmos-sdk/client/flags" -// "github.com/cosmos/cosmos-sdk/testutil" -// sdk "github.com/cosmos/cosmos-sdk/types" - -// "mods.irisnet.org/simapp" -// recordcli "mods.irisnet.org/modules/record/client/cli" -// recordtestutil "mods.irisnet.org/modules/record/client/testutil" -// recordtypes "mods.irisnet.org/modules/record/types" -// ) - -// type IntegrationTestSuite struct { -// suite.Suite - -// network simapp.Network -// } - -// func (s *IntegrationTestSuite) SetupSuite() { -// s.T().Log("setting up integration test suite") - -// s.network = simapp.SetupNetwork(s.T()) -// } - -// func (s *IntegrationTestSuite) TearDownSuite() { -// s.T().Log("tearing down integration test suite") -// s.network.Cleanup() -// } - -// func TestIntegrationTestSuite(t *testing.T) { -// suite.Run(t, new(IntegrationTestSuite)) -// } - -// func (s *IntegrationTestSuite) TestQueryRecordGRPC() { -// val := s.network.Validators[0] -// clientCtx := val.ClientCtx - -// // --------------------------------------------------------------------------- - -// from := val.Address -// digest := "digest" -// digestAlgo := "digest-algo" -// uri := "https://example.abc" -// meta := "meta data" - -// args := []string{ -// fmt.Sprintf("--%s=%s", recordcli.FlagURI, uri), -// fmt.Sprintf("--%s=%s", recordcli.FlagMeta, meta), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// expectedCode := uint32(0) - -// txResult := recordtestutil.CreateRecordExec(s.T(), -// s.network, -// clientCtx, from.String(), digest, digestAlgo, args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// recordID := s.network.GetAttribute( -// recordtypes.EventTypeCreateRecord, -// recordtypes.AttributeKeyRecordID, -// txResult.Events, -// ) -// // --------------------------------------------------------------------------- - -// baseURL := val.APIAddress -// url := fmt.Sprintf("%s/irismod/record/records/%s", baseURL, recordID) - -// respType := proto.Message(&recordtypes.QueryRecordResponse{}) -// expectedContents := []recordtypes.Content{{ -// Digest: digest, -// DigestAlgo: digestAlgo, -// URI: uri, -// Meta: meta, -// }} - -// resp, err := testutil.GetRequest(url) -// s.Require().NoError(err) -// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(resp, respType)) -// record := respType.(*recordtypes.QueryRecordResponse).Record -// s.Require().Equal(expectedContents, record.Contents) -// } diff --git a/modules/record/client/testutil/test_helpers.go b/modules/record/client/testutil/test_helpers.go deleted file mode 100644 index 420dba2a..00000000 --- a/modules/record/client/testutil/test_helpers.go +++ /dev/null @@ -1,48 +0,0 @@ -package testutil - -// import ( -// "fmt" -// "testing" - -// "github.com/cometbft/cometbft/libs/cli" -// "github.com/cosmos/gogoproto/proto" - -// "github.com/cosmos/cosmos-sdk/client" -// "github.com/cosmos/cosmos-sdk/client/flags" - -// "mods.irisnet.org/simapp" -// recordcli "mods.irisnet.org/modules/record/client/cli" -// ) - -// // CreateRecordExec creates a redelegate message. -// func CreateRecordExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// digest string, -// digestAlgo string, -// extraArgs ...string) *simapp.ResponseTx { -// args := []string{ -// digest, -// digestAlgo, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, recordcli.GetCmdCreateRecord(), args) -// } - -// func QueryRecordExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// recordID string, -// resp proto.Message, -// extraArgs ...string) { -// args := []string{ -// recordID, -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) - -// network.ExecQueryCmd(t, clientCtx, recordcli.GetCmdQueryRecord(), args, resp) -// } diff --git a/modules/service/client/cli/cli_test.go b/modules/service/client/cli/cli_test.go deleted file mode 100644 index 1b487886..00000000 --- a/modules/service/client/cli/cli_test.go +++ /dev/null @@ -1,476 +0,0 @@ -package cli_test - -// import ( -// "context" -// "encoding/json" -// "fmt" -// "testing" -// "time" - -// "github.com/stretchr/testify/suite" - -// "github.com/cometbft/cometbft/crypto" - -// "github.com/cosmos/cosmos-sdk/client/flags" -// "github.com/cosmos/cosmos-sdk/crypto/hd" -// "github.com/cosmos/cosmos-sdk/crypto/keyring" -// sdk "github.com/cosmos/cosmos-sdk/types" -// authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - -// "mods.irisnet.org/simapp" -// servicecli "mods.irisnet.org/modules/service/client/cli" -// servicetestutil "mods.irisnet.org/modules/service/client/testutil" -// "mods.irisnet.org/modules/service/types" -// servicetypes "mods.irisnet.org/modules/service/types" -// ) - -// type IntegrationTestSuite struct { -// suite.Suite - -// network simapp.Network -// } - -// func (s *IntegrationTestSuite) SetupSuite() { -// s.T().Log("setting up integration test suite") - -// cfg := simapp.NewConfig() -// cfg.NumValidators = 1 - -// var serviceGenesisState servicetypes.GenesisState -// cfg.Codec.MustUnmarshalJSON(cfg.GenesisState[servicetypes.ModuleName], &serviceGenesisState) - -// serviceGenesisState.Params.ArbitrationTimeLimit = time.Duration(time.Second) -// serviceGenesisState.Params.ComplaintRetrospect = time.Duration(time.Second) -// cfg.GenesisState[servicetypes.ModuleName] = cfg.Codec.MustMarshalJSON(&serviceGenesisState) - -// s.network = simapp.SetupNetworkWithConfig(s.T(), cfg) -// } - -// func (s *IntegrationTestSuite) TearDownSuite() { -// s.T().Log("tearing down integration test suite") -// s.network.Cleanup() -// } - -// func TestIntegrationTestSuite(t *testing.T) { -// suite.Run(t, new(IntegrationTestSuite)) -// } - -// func (s *IntegrationTestSuite) TestService() { -// val := s.network.Validators[0] -// clientCtx := val.ClientCtx -// expectedCode := uint32(0) -// // --------------------------------------------------------------------------- - -// serviceName := "test-service" -// serviceDesc := "test-description" -// serviceAuthorDesc := "test-author-description" -// serviceTags := "tags1,tags2" -// serviceSchemas := `{"input":{"type":"object"},"output":{"type":"object"},"error":{"type":"object"}}` -// serviceDenom := sdk.DefaultBondDenom - -// serviceDeposit := fmt.Sprintf("50000%s", serviceDenom) -// servicePrices := fmt.Sprintf(`{"price": "50%s"}`, serviceDenom) -// qos := uint64(3) -// options := "{}" - -// author := val.Address -// provider := author - -// consumerInfo, _, _ := val.ClientCtx.Keyring.NewMnemonic( -// "NewValidator", -// keyring.English, -// sdk.FullFundraiserPath, -// keyring.DefaultBIP39Passphrase, -// hd.Secp256k1, -// ) -// pubKey, err := consumerInfo.GetPubKey() -// s.Require().NoError(err) -// consumer := sdk.AccAddress(pubKey.Address()) - -// reqServiceFee := fmt.Sprintf("50%s", serviceDenom) -// reqInput := `{"header":{},"body":{}}` -// respResult := `{"code":200,"message":""}` -// respOutput := `{"header":{},"body":{}}` -// timeout := qos - -// expectedEarnedFees := fmt.Sprintf("48%s", serviceDenom) -// expectedTaxFees := fmt.Sprintf("2%s", serviceDenom) - -// withdrawalAddress := sdk.AccAddress(crypto.AddressHash([]byte("withdrawalAddress"))) - -// //------test GetCmdDefineService()------------- -// args := []string{ -// fmt.Sprintf("--%s=%s", servicecli.FlagName, serviceName), -// fmt.Sprintf("--%s=%s", servicecli.FlagDescription, serviceDesc), -// fmt.Sprintf("--%s=%s", servicecli.FlagTags, serviceTags), -// fmt.Sprintf("--%s=%s", servicecli.FlagAuthorDescription, serviceAuthorDesc), -// fmt.Sprintf("--%s=%s", servicecli.FlagSchemas, serviceSchemas), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult := servicetestutil.DefineServiceExec( -// s.T(), -// s.network, -// clientCtx, -// author.String(), -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// //------test GetCmdQueryServiceDefinition()------------- -// serviceDefinition := servicetestutil.QueryServiceDefinitionExec( -// s.T(), -// s.network, -// clientCtx, -// serviceName, -// ) -// s.Require().Equal(serviceName, serviceDefinition.Name) - -// //------test GetCmdBindService()------------- -// args = []string{ -// fmt.Sprintf("--%s=%s", servicecli.FlagServiceName, serviceName), -// fmt.Sprintf("--%s=%s", servicecli.FlagDeposit, serviceDeposit), -// fmt.Sprintf("--%s=%s", servicecli.FlagPricing, servicePrices), -// fmt.Sprintf("--%s=%d", servicecli.FlagQoS, qos), -// fmt.Sprintf("--%s=%s", servicecli.FlagOptions, options), -// fmt.Sprintf("--%s=%s", servicecli.FlagProvider, provider), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = servicetestutil.BindServiceExec( -// s.T(), -// s.network, -// clientCtx, -// provider.String(), -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// //------test GetCmdQueryServiceBinding()------------- -// serviceBinding := servicetestutil.QueryServiceBindingExec( -// s.T(), -// s.network, -// clientCtx, -// serviceName, -// provider.String(), -// ) -// s.Require().Equal(serviceName, serviceBinding.ServiceName) -// s.Require().Equal(provider.String(), serviceBinding.Provider) - -// //------test GetCmdQueryServiceBindings()------------- -// serviceBindings := servicetestutil.QueryServiceBindingsExec( -// s.T(), -// s.network, -// clientCtx, -// serviceName, -// ) -// s.Require().Len(serviceBindings.ServiceBindings, 1) - -// //------test GetCmdDisableServiceBinding()------------- -// args = []string{ -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = servicetestutil.DisableServiceExec( -// s.T(), -// s.network, -// clientCtx, -// serviceName, -// provider.String(), -// provider.String(), -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// serviceBinding = servicetestutil.QueryServiceBindingExec( -// s.T(), -// s.network, -// clientCtx, -// serviceName, -// provider.String(), -// ) -// s.Require().False(serviceBinding.Available) - -// //------test GetCmdRefundServiceDeposit()------------- -// args = []string{ -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = servicetestutil.RefundDepositExec( -// s.T(), -// s.network, -// clientCtx, -// serviceName, -// provider.String(), -// provider.String(), -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// serviceBinding = servicetestutil.QueryServiceBindingExec( -// s.T(), -// s.network, -// clientCtx, -// serviceName, -// provider.String(), -// ) -// s.Require().True(serviceBinding.Deposit.IsZero()) - -// //------test GetCmdEnableServiceBinding()------------- -// args = []string{ -// fmt.Sprintf("--%s=%s", servicecli.FlagDeposit, serviceDeposit), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = servicetestutil.EnableServiceExec( -// s.T(), -// s.network, -// clientCtx, -// serviceName, -// provider.String(), -// provider.String(), -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// serviceBinding = servicetestutil.QueryServiceBindingExec( -// s.T(), -// s.network, -// clientCtx, -// serviceName, -// provider.String(), -// ) -// s.Require().Equal(serviceDeposit, serviceBinding.Deposit.String()) - -// //------send token to consumer------------------------ -// amount := sdk.NewCoins( -// sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(50000000)), -// ) -// args = []string{ -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = simapp.MsgSendExec(s.T(), s.network, clientCtx, provider, consumer, amount, args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// //------test GetCmdCallService()------------- -// args = []string{ -// fmt.Sprintf("--%s=%s", servicecli.FlagServiceName, serviceName), -// fmt.Sprintf("--%s=%s", servicecli.FlagProviders, provider), -// fmt.Sprintf("--%s=%s", servicecli.FlagServiceFeeCap, reqServiceFee), -// fmt.Sprintf("--%s=%s", servicecli.FlagData, reqInput), -// fmt.Sprintf("--%s=%d", servicecli.FlagTimeout, timeout), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = servicetestutil.CallServiceExec( -// s.T(), -// s.network, -// clientCtx, -// consumer.String(), -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// requestContextId := s.network.GetAttribute( -// servicetypes.EventTypeCreateContext, -// servicetypes.AttributeKeyRequestContextID, -// txResult.Events, -// ) -// requestHeight := txResult.Height - -// blockResult, err := val.RPCClient.BlockResults(context.Background(), &requestHeight) -// s.Require().NoError(err) -// var compactRequest servicetypes.CompactRequest -// for _, event := range blockResult.EndBlockEvents { -// if event.Type == servicetypes.EventTypeNewBatchRequest { -// var found bool -// var requests []servicetypes.CompactRequest -// var requestsBz []byte -// for _, attribute := range event.Attributes { -// if string(attribute.Key) == types.AttributeKeyRequests { -// requestsBz = []byte(attribute.GetValue()) -// } -// if string(attribute.Key) == types.AttributeKeyRequestContextID && -// string(attribute.GetValue()) == requestContextId { -// found = true -// } -// } -// s.Require().True(found) -// if found { -// err := json.Unmarshal(requestsBz, &requests) -// s.Require().NoError(err) -// } -// s.Require().Len(requests, 1) -// compactRequest = requests[0] -// } -// } -// s.Require().Equal(requestContextId, compactRequest.RequestContextId) - -// //------test GetCmdQueryServiceRequests()------------- -// queryRequestsResponse := servicetestutil.QueryServiceRequestsExec( -// s.T(), -// s.network, -// clientCtx, -// serviceName, -// provider.String(), -// ) -// s.Require().Len(queryRequestsResponse.Requests, 1) -// s.Require().Equal(requestContextId, queryRequestsResponse.Requests[0].RequestContextId) - -// //------test GetCmdQueryServiceRequests()------------- -// queryRequestsResponse = servicetestutil.QueryServiceRequestsByReqCtx( -// s.T(), -// s.network, -// clientCtx, -// queryRequestsResponse.Requests[0].RequestContextId, -// fmt.Sprint(queryRequestsResponse.Requests[0].RequestContextBatchCounter), -// ) -// s.Require().Len(queryRequestsResponse.Requests, 1) -// s.Require().Equal(requestContextId, queryRequestsResponse.Requests[0].RequestContextId) - -// //------test GetCmdRespondService()------------- -// request := queryRequestsResponse.Requests[0] -// args = []string{ -// fmt.Sprintf("--%s=%s", servicecli.FlagRequestID, request.Id), -// fmt.Sprintf("--%s=%s", servicecli.FlagResult, respResult), -// fmt.Sprintf("--%s=%s", servicecli.FlagData, respOutput), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = servicetestutil.RespondServiceExec( -// s.T(), -// s.network, -// clientCtx, -// provider.String(), -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// //------test GetCmdQueryEarnedFees()------------- -// queryEarnedFeesResponse := servicetestutil.QueryEarnedFeesExec( -// s.T(), -// s.network, -// clientCtx, -// provider.String(), -// ) -// s.Require().Equal(expectedEarnedFees, queryEarnedFeesResponse.Fees.String()) - -// //------GetCmdSetWithdrawAddr()------------- -// args = []string{ -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = servicetestutil.SetWithdrawAddrExec( -// s.T(), -// s.network, -// clientCtx, -// withdrawalAddress.String(), -// provider.String(), -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// //------GetCmdWithdrawEarnedFees()------------- -// args = []string{ -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = servicetestutil.WithdrawEarnedFeesExec( -// s.T(), -// s.network, -// clientCtx, -// provider.String(), -// provider.String(), -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// withdrawalFees := simapp.QueryBalancesExec( -// s.T(), -// s.network, -// clientCtx, -// withdrawalAddress.String(), -// ) -// s.Require().Equal(expectedEarnedFees, withdrawalFees.String()) - -// //------check service tax------------- -// taxFees := simapp.QueryBalancesExec( -// s.T(), -// s.network, -// clientCtx, -// authtypes.NewModuleAddress(servicetypes.FeeCollectorName).String(), -// ) -// s.Require().Equal(expectedTaxFees, taxFees.String()) - -// //------GetCmdQueryRequestContext()------------- -// contextId := request.RequestContextId -// contextResp := servicetestutil.QueryRequestContextExec(s.T(), s.network, clientCtx, contextId) -// s.Require().False(contextResp.Empty()) - -// //------GetCmdQueryServiceRequest()------------- -// requestId := request.Id -// requestResp := servicetestutil.QueryServiceRequestExec(s.T(), s.network, clientCtx, requestId) -// s.Require().False(requestResp.Empty()) -// s.Require().Equal(requestId, requestResp.Id) - -// //------GetCmdQueryServiceResponse()------------- -// responseResp := servicetestutil.QueryServiceResponseExec(s.T(), s.network, clientCtx, requestId) -// s.Require().False(responseResp.Empty()) -// } diff --git a/modules/service/client/testutil/grpc_query_test.go b/modules/service/client/testutil/grpc_query_test.go deleted file mode 100644 index ec81fd12..00000000 --- a/modules/service/client/testutil/grpc_query_test.go +++ /dev/null @@ -1,385 +0,0 @@ -package testutil_test - -// import ( -// "context" -// "encoding/json" -// "fmt" -// "testing" -// "time" - -// "github.com/cosmos/gogoproto/proto" -// "github.com/stretchr/testify/suite" - -// "github.com/cosmos/cosmos-sdk/client/flags" -// "github.com/cosmos/cosmos-sdk/crypto/hd" -// "github.com/cosmos/cosmos-sdk/crypto/keyring" -// "github.com/cosmos/cosmos-sdk/testutil" -// sdk "github.com/cosmos/cosmos-sdk/types" - -// "mods.irisnet.org/simapp" -// servicecli "mods.irisnet.org/modules/service/client/cli" -// servicetestutil "mods.irisnet.org/modules/service/client/testutil" -// "mods.irisnet.org/modules/service/types" -// servicetypes "mods.irisnet.org/modules/service/types" -// ) - -// type IntegrationTestSuite struct { -// suite.Suite - -// network simapp.Network -// } - -// func (s *IntegrationTestSuite) SetupSuite() { -// s.T().Log("setting up integration test suite") - -// cfg := simapp.NewConfig() -// cfg.NumValidators = 1 - -// var serviceGenesisState servicetypes.GenesisState -// cfg.Codec.MustUnmarshalJSON(cfg.GenesisState[servicetypes.ModuleName], &serviceGenesisState) - -// serviceGenesisState.Params.ArbitrationTimeLimit = time.Duration(time.Second) -// serviceGenesisState.Params.ComplaintRetrospect = time.Duration(time.Second) -// cfg.GenesisState[servicetypes.ModuleName] = cfg.Codec.MustMarshalJSON(&serviceGenesisState) - -// s.network = simapp.SetupNetworkWithConfig(s.T(), cfg) -// } - -// func (s *IntegrationTestSuite) TearDownSuite() { -// s.T().Log("tearing down integration test suite") -// s.network.Cleanup() -// } - -// func TestIntegrationTestSuite(t *testing.T) { -// suite.Run(t, new(IntegrationTestSuite)) -// } - -// func (s *IntegrationTestSuite) TestService() { -// val := s.network.Validators[0] -// clientCtx := val.ClientCtx -// expectedCode := uint32(0) -// // --------------------------------------------------------------------------- - -// serviceName := "test-service" -// serviceDesc := "test-description" -// serviceAuthorDesc := "test-author-description" -// serviceTags := "tags1,tags2" -// serviceSchemas := `{"input":{"type":"object"},"output":{"type":"object"},"error":{"type":"object"}}` -// serviceDenom := sdk.DefaultBondDenom -// baseURL := val.APIAddress - -// serviceDeposit := fmt.Sprintf("50000%s", serviceDenom) -// servicePrices := fmt.Sprintf(`{"price": "50%s"}`, serviceDenom) -// qos := uint64(3) -// options := "{}" - -// author := val.Address -// provider := author - -// consumerInfo, _, _ := val.ClientCtx.Keyring.NewMnemonic( -// "NewValidator", -// keyring.English, -// sdk.FullFundraiserPath, -// keyring.DefaultBIP39Passphrase, -// hd.Secp256k1, -// ) - -// consumer, err := consumerInfo.GetAddress() -// s.Require().NoError(err) - -// reqServiceFee := fmt.Sprintf("50%s", serviceDenom) -// reqInput := `{"header":{},"body":{}}` -// respResult := `{"code":200,"message":""}` -// respOutput := `{"header":{},"body":{}}` -// timeout := qos - -// expectedEarnedFees := fmt.Sprintf("48%s", serviceDenom) - -// //------test GetCmdDefineService()------------- -// args := []string{ -// fmt.Sprintf("--%s=%s", servicecli.FlagName, serviceName), -// fmt.Sprintf("--%s=%s", servicecli.FlagDescription, serviceDesc), -// fmt.Sprintf("--%s=%s", servicecli.FlagTags, serviceTags), -// fmt.Sprintf("--%s=%s", servicecli.FlagAuthorDescription, serviceAuthorDesc), -// fmt.Sprintf("--%s=%s", servicecli.FlagSchemas, serviceSchemas), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult := servicetestutil.DefineServiceExec( -// s.T(), -// s.network, -// clientCtx, -// author.String(), -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// //------test GetCmdQueryServiceDefinition()------------- -// url := fmt.Sprintf("%s/irismod/service/definitions/%s", baseURL, serviceName) -// resp, err := testutil.GetRequest(url) -// respType := proto.Message(&servicetypes.QueryDefinitionResponse{}) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, respType)) -// serviceDefinitionResp := respType.(*servicetypes.QueryDefinitionResponse) -// s.Require().Equal(serviceName, serviceDefinitionResp.ServiceDefinition.Name) - -// //------test GetCmdBindService()------------- -// args = []string{ -// fmt.Sprintf("--%s=%s", servicecli.FlagServiceName, serviceName), -// fmt.Sprintf("--%s=%s", servicecli.FlagDeposit, serviceDeposit), -// fmt.Sprintf("--%s=%s", servicecli.FlagPricing, servicePrices), -// fmt.Sprintf("--%s=%d", servicecli.FlagQoS, qos), -// fmt.Sprintf("--%s=%s", servicecli.FlagOptions, options), -// fmt.Sprintf("--%s=%s", servicecli.FlagProvider, provider), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = servicetestutil.BindServiceExec( -// s.T(), -// s.network, -// clientCtx, -// provider.String(), -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// //------test GetCmdQueryServiceBinding()------------- -// url = fmt.Sprintf("%s/irismod/service/bindings/%s/%s", baseURL, serviceName, provider.String()) -// resp, err = testutil.GetRequest(url) -// respType = proto.Message(&servicetypes.QueryBindingResponse{}) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, respType)) -// serviceBindingResp := respType.(*servicetypes.QueryBindingResponse) -// s.Require().Equal(serviceName, serviceBindingResp.ServiceBinding.ServiceName) -// s.Require().Equal(provider.String(), serviceBindingResp.ServiceBinding.Provider) - -// //------test GetCmdQueryServiceBindings()------------- -// url = fmt.Sprintf("%s/irismod/service/bindings/%s", baseURL, serviceName) -// resp, err = testutil.GetRequest(url) -// respType = proto.Message(&servicetypes.QueryBindingsResponse{}) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, respType)) -// serviceBindings := respType.(*servicetypes.QueryBindingsResponse) -// s.Require().Len(serviceBindings.ServiceBindings, 1) - -// //------test GetCmdDisableServiceBinding()------------- -// args = []string{ -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = servicetestutil.DisableServiceExec( -// s.T(), -// s.network, -// clientCtx, -// serviceName, -// provider.String(), -// provider.String(), -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// url = fmt.Sprintf("%s/irismod/service/bindings/%s/%s", baseURL, serviceName, provider.String()) -// resp, err = testutil.GetRequest(url) -// respType = proto.Message(&servicetypes.QueryBindingResponse{}) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, respType)) -// serviceBindingResp = respType.(*servicetypes.QueryBindingResponse) -// s.Require().False(serviceBindingResp.ServiceBinding.Available) - -// //------test GetCmdRefundServiceDeposit()------------- -// args = []string{ -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = servicetestutil.RefundDepositExec( -// s.T(), -// s.network, -// clientCtx, -// serviceName, -// provider.String(), -// provider.String(), -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// url = fmt.Sprintf("%s/irismod/service/bindings/%s/%s", baseURL, serviceName, provider.String()) -// resp, err = testutil.GetRequest(url) -// respType = proto.Message(&servicetypes.QueryBindingResponse{}) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, respType)) -// serviceBindingResp = respType.(*servicetypes.QueryBindingResponse) -// s.Require().True(serviceBindingResp.ServiceBinding.Deposit.IsZero()) - -// //------test GetCmdEnableServiceBinding()------------- -// args = []string{ -// fmt.Sprintf("--%s=%s", servicecli.FlagDeposit, serviceDeposit), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = servicetestutil.EnableServiceExec( -// s.T(), -// s.network, -// clientCtx, -// serviceName, -// provider.String(), -// provider.String(), -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// url = fmt.Sprintf("%s/irismod/service/bindings/%s/%s", baseURL, serviceName, provider.String()) -// resp, err = testutil.GetRequest(url) -// respType = proto.Message(&servicetypes.QueryBindingResponse{}) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, respType)) -// serviceBindingResp = respType.(*servicetypes.QueryBindingResponse) -// s.Require().Equal(serviceDeposit, serviceBindingResp.ServiceBinding.Deposit.String()) - -// //------send token to consumer------------------------ -// amount := sdk.NewCoins( -// sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(50000000)), -// ) -// args = []string{ -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = simapp.MsgSendExec(s.T(), s.network, clientCtx, provider, consumer, amount, args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// //------test GetCmdCallService()------------- -// args = []string{ -// fmt.Sprintf("--%s=%s", servicecli.FlagServiceName, serviceName), -// fmt.Sprintf("--%s=%s", servicecli.FlagProviders, provider), -// fmt.Sprintf("--%s=%s", servicecli.FlagServiceFeeCap, reqServiceFee), -// fmt.Sprintf("--%s=%s", servicecli.FlagData, reqInput), -// fmt.Sprintf("--%s=%d", servicecli.FlagTimeout, timeout), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = servicetestutil.CallServiceExec( -// s.T(), -// s.network, -// clientCtx, -// consumer.String(), -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// requestContextId := s.network.GetAttribute( -// servicetypes.EventTypeCreateContext, -// servicetypes.AttributeKeyRequestContextID, -// txResult.Events, -// ) -// requestHeight := txResult.Height - -// blockResult, err := val.RPCClient.BlockResults(context.Background(), &requestHeight) -// s.Require().NoError(err) -// var compactRequest servicetypes.CompactRequest -// for _, event := range blockResult.EndBlockEvents { -// if event.Type == servicetypes.EventTypeNewBatchRequest { -// var found bool -// var requests []servicetypes.CompactRequest -// var requestsBz []byte -// for _, attribute := range event.Attributes { -// if string(attribute.Key) == types.AttributeKeyRequests { -// requestsBz = []byte(attribute.Value) -// } -// if string(attribute.Key) == types.AttributeKeyRequestContextID && -// string(attribute.GetValue()) == requestContextId { -// found = true -// } -// } -// s.Require().True(found) -// if found { -// err := json.Unmarshal(requestsBz, &requests) -// s.Require().NoError(err) -// } -// s.Require().Len(requests, 1) -// compactRequest = requests[0] -// } -// } -// s.Require().Equal(requestContextId, compactRequest.RequestContextId) - -// //------test GetCmdQueryServiceRequests()------------- -// url = fmt.Sprintf("%s/irismod/service/requests/%s/%s", baseURL, serviceName, provider.String()) -// resp, err = testutil.GetRequest(url) -// respType = proto.Message(&servicetypes.QueryRequestsResponse{}) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, respType)) -// requests := respType.(*servicetypes.QueryRequestsResponse).Requests -// s.Require().Len(requests, 1) -// s.Require().Equal(requestContextId, requests[0].RequestContextId) - -// //------test GetCmdRespondService()------------- -// request := requests[0] -// args = []string{ -// fmt.Sprintf("--%s=%s", servicecli.FlagRequestID, request.Id), -// fmt.Sprintf("--%s=%s", servicecli.FlagResult, respResult), -// fmt.Sprintf("--%s=%s", servicecli.FlagData, respOutput), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = servicetestutil.RespondServiceExec( -// s.T(), -// s.network, -// clientCtx, -// provider.String(), -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// //------test GetCmdQueryEarnedFees()------------- -// url = fmt.Sprintf("%s/irismod/service/fees/%s", baseURL, provider.String()) -// resp, err = testutil.GetRequest(url) -// respType = proto.Message(&servicetypes.QueryEarnedFeesResponse{}) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, respType)) -// earnedFees := respType.(*servicetypes.QueryEarnedFeesResponse).Fees -// s.Require().Equal(expectedEarnedFees, earnedFees.String()) -// } diff --git a/modules/service/client/testutil/test_helpers.go b/modules/service/client/testutil/test_helpers.go deleted file mode 100644 index 9dd952f0..00000000 --- a/modules/service/client/testutil/test_helpers.go +++ /dev/null @@ -1,328 +0,0 @@ -package testutil - -// import ( -// "fmt" -// "testing" - -// "github.com/cometbft/cometbft/libs/cli" - -// "github.com/cosmos/cosmos-sdk/client" -// "github.com/cosmos/cosmos-sdk/client/flags" - -// "mods.irisnet.org/simapp" -// servicecli "mods.irisnet.org/modules/service/client/cli" -// servicetypes "mods.irisnet.org/modules/service/types" -// ) - -// func DefineServiceExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// extraArgs ...string, -// ) *simapp.ResponseTx { -// args := []string{ -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, servicecli.GetCmdDefineService(), args) -// } - -// func BindServiceExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// extraArgs ...string, -// ) *simapp.ResponseTx { -// args := []string{ -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, servicecli.GetCmdBindService(), args) -// } - -// func UpdateBindingExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// extraArgs ...string, -// ) *simapp.ResponseTx { -// args := []string{ -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, servicecli.GetCmdUpdateServiceBinding(), args) -// } - -// func RefundDepositExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// serviceName, -// provider, -// from string, -// extraArgs ...string, -// ) *simapp.ResponseTx { -// args := []string{ -// serviceName, -// provider, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, servicecli.GetCmdRefundServiceDeposit(), args) -// } - -// func DisableServiceExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// serviceName, -// provider, -// from string, -// extraArgs ...string, -// ) *simapp.ResponseTx { -// args := []string{ -// serviceName, -// provider, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, servicecli.GetCmdDisableServiceBinding(), args) -// } - -// func EnableServiceExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// serviceName, -// provider, -// from string, -// extraArgs ...string, -// ) *simapp.ResponseTx { -// args := []string{ -// serviceName, -// provider, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, servicecli.GetCmdEnableServiceBinding(), args) -// } - -// func CallServiceExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// extraArgs ...string, -// ) *simapp.ResponseTx { -// args := []string{ -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, servicecli.GetCmdCallService(), args) -// } - -// func RespondServiceExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// extraArgs ...string, -// ) *simapp.ResponseTx { -// args := []string{ -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, servicecli.GetCmdRespondService(), args) -// } - -// func SetWithdrawAddrExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// withdrawalAddress, -// from string, -// extraArgs ...string, -// ) *simapp.ResponseTx { -// args := []string{ -// withdrawalAddress, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, servicecli.GetCmdSetWithdrawAddr(), args) -// } - -// func WithdrawEarnedFeesExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// provider, -// from string, -// extraArgs ...string, -// ) *simapp.ResponseTx { -// args := []string{ -// provider, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, servicecli.GetCmdWithdrawEarnedFees(), args) -// } - -// func QueryServiceDefinitionExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// serviceName string, -// extraArgs ...string, -// ) *servicetypes.ServiceDefinition { -// args := []string{ -// serviceName, -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) - -// response := &servicetypes.ServiceDefinition{} -// network.ExecQueryCmd(t, clientCtx, servicecli.GetCmdQueryServiceDefinition(), args, response) -// return response -// } - -// func QueryServiceBindingExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// serviceName, -// provider string, -// extraArgs ...string, -// ) *servicetypes.ServiceBinding { -// args := []string{ -// serviceName, -// provider, -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) - -// response := &servicetypes.ServiceBinding{} -// network.ExecQueryCmd(t, clientCtx, servicecli.GetCmdQueryServiceBinding(), args, response) -// return response -// } - -// func QueryServiceBindingsExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// serviceName string, -// extraArgs ...string, -// ) *servicetypes.QueryBindingsResponse { -// args := []string{ -// serviceName, -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) - -// response := &servicetypes.QueryBindingsResponse{} -// network.ExecQueryCmd(t, clientCtx, servicecli.GetCmdQueryServiceBindings(), args, response) -// return response -// } - -// func QueryServiceRequestsExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// serviceName, -// provider string, -// extraArgs ...string) *servicetypes.QueryRequestsResponse { -// args := []string{ -// serviceName, -// provider, -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) - -// response := &servicetypes.QueryRequestsResponse{} -// network.ExecQueryCmd(t, clientCtx, servicecli.GetCmdQueryServiceRequests(), args, response) -// return response -// } - -// func QueryServiceRequestsByReqCtx(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// requestContextID, -// batchCounter string, -// extraArgs ...string, -// ) *servicetypes.QueryRequestsResponse { -// args := []string{ -// requestContextID, -// batchCounter, -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) - -// response := &servicetypes.QueryRequestsResponse{} -// network.ExecQueryCmd(t, clientCtx, servicecli.GetCmdQueryServiceRequests(), args, response) -// return response - -// } - -// func QueryEarnedFeesExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// extraArgs ...string, -// ) *servicetypes.QueryEarnedFeesResponse { -// args := []string{ -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) - -// response := &servicetypes.QueryEarnedFeesResponse{} -// network.ExecQueryCmd(t, clientCtx, servicecli.GetCmdQueryEarnedFees(), args, response) -// return response -// } - -// func QueryRequestContextExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// contextId string, -// extraArgs ...string, -// ) *servicetypes.RequestContext { -// args := []string{ -// contextId, -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) - -// response := &servicetypes.RequestContext{} -// network.ExecQueryCmd(t, clientCtx, servicecli.GetCmdQueryRequestContext(), args, response) -// return response -// } - -// func QueryServiceRequestExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// requestId string, -// extraArgs ...string, -// ) *servicetypes.Request { -// args := []string{ -// requestId, -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) - -// response := &servicetypes.Request{} -// network.ExecQueryCmd(t, clientCtx, servicecli.GetCmdQueryServiceRequest(), args, response) -// return response -// } - -// func QueryServiceResponseExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// requestId string, -// extraArgs ...string, -// ) *servicetypes.Response { -// args := []string{ -// requestId, -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) - -// response := &servicetypes.Response{} -// network.ExecQueryCmd(t, clientCtx, servicecli.GetCmdQueryServiceResponse(), args, response) -// return response -// } diff --git a/modules/token/client/cli/cli_test.go b/modules/token/client/cli/cli_test.go deleted file mode 100644 index 3ecd145b..00000000 --- a/modules/token/client/cli/cli_test.go +++ /dev/null @@ -1,293 +0,0 @@ -package cli_test - -// import ( -// "encoding/json" -// "fmt" -// "testing" - -// "github.com/cometbft/cometbft/crypto" -// "github.com/stretchr/testify/suite" - -// "github.com/cosmos/cosmos-sdk/client/flags" -// sdk "github.com/cosmos/cosmos-sdk/types" - -// "mods.irisnet.org/simapp" -// tokencli "mods.irisnet.org/modules/token/client/cli" -// tokentestutil "mods.irisnet.org/modules/token/client/testutil" -// tokentypes "mods.irisnet.org/modules/token/types" -// ) - -// type IntegrationTestSuite struct { -// suite.Suite - -// network simapp.Network -// } - -// func (s *IntegrationTestSuite) SetupSuite() { -// s.T().Log("setting up integration test suite") - -// s.network = simapp.SetupNetwork(s.T()) -// } - -// func (s *IntegrationTestSuite) TearDownSuite() { -// s.T().Log("tearing down integration test suite") -// s.network.Cleanup() -// } - -// func TestIntegrationTestSuite(t *testing.T) { -// suite.Run(t, new(IntegrationTestSuite)) -// } - -// func (s *IntegrationTestSuite) TestToken() { -// val := s.network.Validators[0] -// clientCtx := val.ClientCtx -// // --------------------------------------------------------------------------- - -// from := val.Address -// symbol := "kitty" -// name := "Kitty Token" -// minUnit := "kitty" -// scale := 0 -// initialSupply := int64(100000000) -// maxSupply := int64(200000000) -// mintable := true - -// //------test GetCmdIssueToken()------------- -// args := []string{ -// fmt.Sprintf("--%s=%s", tokencli.FlagSymbol, symbol), -// fmt.Sprintf("--%s=%s", tokencli.FlagName, name), -// fmt.Sprintf("--%s=%s", tokencli.FlagMinUnit, minUnit), -// fmt.Sprintf("--%s=%d", tokencli.FlagScale, scale), -// fmt.Sprintf("--%s=%d", tokencli.FlagInitialSupply, initialSupply), -// fmt.Sprintf("--%s=%d", tokencli.FlagMaxSupply, maxSupply), -// fmt.Sprintf("--%s=%t", tokencli.FlagMintable, mintable), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } -// expectedCode := uint32(0) -// txResult := tokentestutil.IssueTokenExec(s.T(), s.network, clientCtx, from.String(), args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// tokenSymbol := s.network.GetAttribute( -// tokentypes.EventTypeIssueToken, -// tokentypes.AttributeKeySymbol, -// txResult.Events, -// ) - -// //------test GetCmdQueryTokens()------------- -// tokens := tokentestutil.QueryTokensExec(s.T(), s.network, clientCtx, from.String()) -// s.Require().Equal(1, len(tokens)) - -// //------test GetCmdQueryToken()------------- -// token := tokentestutil.QueryTokenExec(s.T(), s.network, clientCtx, tokenSymbol) -// s.Require().Equal(name, token.GetName()) -// s.Require().Equal(symbol, token.GetSymbol()) -// s.Require().Equal(uint64(initialSupply), token.GetInitialSupply()) - -// //------test GetCmdQueryFee()------------- -// queryFeeResponse := tokentestutil.QueryFeeExec(s.T(), s.network, clientCtx, symbol) -// expectedFeeResp := "{\"exist\":true,\"issue_fee\":{\"denom\":\"stake\",\"amount\":\"13015\"},\"mint_fee\":{\"denom\":\"stake\",\"amount\":\"1301\"}}" -// result, _ := json.Marshal(queryFeeResponse) -// s.Require().Equal(expectedFeeResp, string(result)) - -// //------test GetCmdQueryParams()------------- -// queryParamsResponse := tokentestutil.QueryParamsExec(s.T(), s.network, clientCtx) -// expectedParams := "{\"token_tax_rate\":\"0.400000000000000000\",\"issue_token_base_fee\":{\"denom\":\"stake\",\"amount\":\"60000\"},\"mint_token_fee_ratio\":\"0.100000000000000000\",\"enable_erc20\":true}" -// result, _ = json.Marshal(queryParamsResponse) -// s.Require().Equal(expectedParams, string(result)) - -// //------test GetCmdMintToken()------------- -// balance := simapp.QueryBalanceExec( -// s.T(), -// s.network, -// clientCtx, -// from.String(), -// symbol, -// ) -// initAmount := balance.Amount.Int64() -// mintAmount := int64(50000000) - -// args = []string{ -// fmt.Sprintf("--%s=%s", tokencli.FlagTo, from.String()), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } -// coinMintedStr := fmt.Sprintf("%d%s", mintAmount, symbol) - -// txResult = tokentestutil.MintTokenExec( -// s.T(), -// s.network, -// clientCtx, -// from.String(), -// coinMintedStr, -// args..., -// ) -// s.Require().Equal(expectedCode, txResult.Code) - -// balance = simapp.QueryBalanceExec( -// s.T(), -// s.network, -// clientCtx, -// from.String(), -// symbol, -// ) -// exceptedAmount := initAmount + mintAmount -// s.Require().Equal(exceptedAmount, balance.Amount.Int64()) - -// //------test GetCmdBurnToken()------------- - -// burnAmount := int64(2000000) - -// args = []string{ -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// coinBurntStr := fmt.Sprintf("%d%s", burnAmount, symbol) -// txResult = tokentestutil.BurnTokenExec( -// s.T(), -// s.network, -// clientCtx, -// from.String(), -// coinBurntStr, -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// balance = simapp.QueryBalanceExec( -// s.T(), -// s.network, -// clientCtx, -// from.String(), -// symbol, -// ) -// exceptedAmount = exceptedAmount - burnAmount -// s.Require().Equal(exceptedAmount, balance.Amount.Int64()) - -// //------test GetCmdEditToken()------------- -// newName := "Wd Token" -// newMaxSupply := 200000000 -// newMintable := false - -// args = []string{ -// fmt.Sprintf("--%s=%s", tokencli.FlagName, newName), -// fmt.Sprintf("--%s=%d", tokencli.FlagMaxSupply, newMaxSupply), -// fmt.Sprintf("--%s=%t", tokencli.FlagMintable, newMintable), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = tokentestutil.EditTokenExec( -// s.T(), -// s.network, -// clientCtx, -// from.String(), -// symbol, -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// token2 := tokentestutil.QueryTokenExec(s.T(), s.network, clientCtx, tokenSymbol) -// s.Require().Equal(newName, token2.GetName()) -// s.Require().Equal(uint64(newMaxSupply), token2.GetMaxSupply()) -// s.Require().Equal(newMintable, token2.GetMintable()) - -// //------test GetCmdTransferTokenOwner()------------- -// to := sdk.AccAddress(crypto.AddressHash([]byte("dgsbl"))) - -// args = []string{ -// fmt.Sprintf("--%s=%s", tokencli.FlagTo, to.String()), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } - -// txResult = tokentestutil.TransferTokenOwnerExec( -// s.T(), -// s.network, -// clientCtx, -// from.String(), -// symbol, -// args...) -// s.Require().Equal(expectedCode, txResult.Code) - -// token3 := tokentestutil.QueryTokenExec(s.T(), s.network, clientCtx, tokenSymbol) -// s.Require().Equal(to, token3.GetOwner()) -// // --------------------------------------------------------------------------- - -// //------test GetCmdSwapToErc20()------------- -// // args = []string{ -// // fmt.Sprintf("--%s=%s", tokencli.FlagTo, to.String()), - -// // fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// // fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// // fmt.Sprintf( -// // "--%s=%s", -// // flags.FlagFees, -// // sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// // ), -// // } - -// // txResult = tokentestutil.SwapToERC20Exec( -// // s.T(), -// // s.network, -// // clientCtx, -// // from.String(), -// // sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(1))).String(), -// // args...) - -// // TODO assert -// // s.Require().Equal(expectedCode, txResult.Code) -// // --------------------------------------------------------------------------- - -// //------test GetCmdSwapFromErc20()------------- -// // args = []string{ -// // fmt.Sprintf("--%s=%s", tokencli.FlagTo, to.String()), - -// // fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// // fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// // fmt.Sprintf( -// // "--%s=%s", -// // flags.FlagFees, -// // sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// // ), -// // } - -// // txResult = tokentestutil.SwapFromERC20Exec( -// // s.T(), -// // s.network, -// // clientCtx, -// // from.String(), -// // sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(1))).String(), -// // args...) - -// // TODO assert -// // s.Require().Equal(expectedCode, txResult.Code) -// // --------------------------------------------------------------------------- -// } diff --git a/modules/token/client/testutil/grpc_query_test.go b/modules/token/client/testutil/grpc_query_test.go deleted file mode 100644 index bf529965..00000000 --- a/modules/token/client/testutil/grpc_query_test.go +++ /dev/null @@ -1,129 +0,0 @@ -package testutil_test - -// import ( -// "encoding/json" -// "fmt" -// "testing" - -// "github.com/cosmos/gogoproto/proto" -// "github.com/stretchr/testify/suite" - -// "github.com/cosmos/cosmos-sdk/client/flags" -// "github.com/cosmos/cosmos-sdk/testutil" -// sdk "github.com/cosmos/cosmos-sdk/types" - -// "mods.irisnet.org/simapp" -// tokencli "mods.irisnet.org/modules/token/client/cli" -// tokentestutil "mods.irisnet.org/modules/token/client/testutil" -// tokentypes "mods.irisnet.org/modules/token/types" -// v1 "mods.irisnet.org/modules/token/types/v1" -// ) - -// type IntegrationTestSuite struct { -// suite.Suite - -// network simapp.Network -// } - -// func (s *IntegrationTestSuite) SetupSuite() { -// s.T().Log("setting up integration test suite") - -// s.network = simapp.SetupNetwork(s.T()) -// } - -// func (s *IntegrationTestSuite) TearDownSuite() { -// s.T().Log("tearing down integration test suite") -// s.network.Cleanup() -// } - -// func TestIntegrationTestSuite(t *testing.T) { -// suite.Run(t, new(IntegrationTestSuite)) -// } - -// func (s *IntegrationTestSuite) TestToken() { -// val := s.network.Validators[0] -// clientCtx := val.ClientCtx -// // --------------------------------------------------------------------------- - -// from := val.Address -// symbol := "kitty" -// name := "Kitty Token" -// minUnit := "kitty" -// scale := 0 -// initialSupply := int64(100000000) -// maxSupply := int64(200000000) -// mintable := true -// baseURL := val.APIAddress - -// //------test GetCmdIssueToken()------------- -// args := []string{ -// fmt.Sprintf("--%s=%s", tokencli.FlagSymbol, symbol), -// fmt.Sprintf("--%s=%s", tokencli.FlagName, name), -// fmt.Sprintf("--%s=%s", tokencli.FlagMinUnit, minUnit), -// fmt.Sprintf("--%s=%d", tokencli.FlagScale, scale), -// fmt.Sprintf("--%s=%d", tokencli.FlagInitialSupply, initialSupply), -// fmt.Sprintf("--%s=%d", tokencli.FlagMaxSupply, maxSupply), -// fmt.Sprintf("--%s=%t", tokencli.FlagMintable, mintable), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync), -// fmt.Sprintf( -// "--%s=%s", -// flags.FlagFees, -// sdk.NewCoins(sdk.NewCoin(s.network.BondDenom, sdk.NewInt(10))).String(), -// ), -// } -// txResult := tokentestutil.IssueTokenExec(s.T(), s.network, clientCtx, from.String(), args...) - -// tokenSymbol := s.network.GetAttribute( -// tokentypes.EventTypeIssueToken, -// tokentypes.AttributeKeySymbol, -// txResult.Events, -// ) - -// //------test GetCmdQueryTokens()------------- -// url := fmt.Sprintf("%s/irismod/token/v1/tokens", baseURL) -// resp, err := testutil.GetRequest(url) -// respType := proto.Message(&v1.QueryTokensResponse{}) -// s.Require().NoError(err) -// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(resp, respType)) -// tokensResp := respType.(*v1.QueryTokensResponse) -// s.Require().Equal(2, len(tokensResp.Tokens)) - -// //------test GetCmdQueryToken()------------- -// url = fmt.Sprintf("%s/irismod/token/v1/tokens/%s", baseURL, tokenSymbol) -// resp, err = testutil.GetRequest(url) -// respType = proto.Message(&v1.QueryTokenResponse{}) -// var token v1.TokenI -// s.Require().NoError(err) -// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(resp, respType)) -// tokenResp := respType.(*v1.QueryTokenResponse) -// err = clientCtx.InterfaceRegistry.UnpackAny(tokenResp.Token, &token) -// s.Require().NoError(err) -// s.Require().Equal(name, token.GetName()) -// s.Require().Equal(symbol, token.GetSymbol()) -// s.Require().Equal(uint64(initialSupply), token.GetInitialSupply()) - -// //------test GetCmdQueryFee()------------- -// url = fmt.Sprintf("%s/irismod/token/v1/tokens/%s/fees", baseURL, tokenSymbol) -// resp, err = testutil.GetRequest(url) -// respType = proto.Message(&v1.QueryFeesResponse{}) -// s.Require().NoError(err) -// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(resp, respType)) -// feeResp := respType.(*v1.QueryFeesResponse) -// expectedFeeResp := "{\"exist\":true,\"issue_fee\":{\"denom\":\"stake\",\"amount\":\"13015\"},\"mint_fee\":{\"denom\":\"stake\",\"amount\":\"1301\"}}" -// result, _ := json.Marshal(feeResp) -// s.Require().Equal(expectedFeeResp, string(result)) - -// //------test GetCmdQueryParams()------------- -// url = fmt.Sprintf("%s/irismod/token/v1/params", baseURL) -// resp, err = testutil.GetRequest(url) -// respType = proto.Message(&v1.QueryParamsResponse{}) -// s.Require().NoError(err) -// s.Require().NoError(clientCtx.Codec.UnmarshalJSON(resp, respType)) -// paramsResp := respType.(*v1.QueryParamsResponse) -// s.Require().NoError(err) -// expectedParams := "{\"token_tax_rate\":\"0.400000000000000000\",\"issue_token_base_fee\":{\"denom\":\"stake\",\"amount\":\"60000\"},\"mint_token_fee_ratio\":\"0.100000000000000000\",\"enable_erc20\":true}" -// result, _ = json.Marshal(paramsResp.Params) -// s.Require().Equal(expectedParams, string(result)) -// } diff --git a/modules/token/client/testutil/test_helpers.go b/modules/token/client/testutil/test_helpers.go deleted file mode 100644 index 29bdb46a..00000000 --- a/modules/token/client/testutil/test_helpers.go +++ /dev/null @@ -1,200 +0,0 @@ -package testutil - -// import ( -// "fmt" -// "testing" - -// "github.com/cometbft/cometbft/libs/cli" -// "github.com/cosmos/gogoproto/proto" -// "github.com/stretchr/testify/require" - -// "github.com/cosmos/cosmos-sdk/client" -// "github.com/cosmos/cosmos-sdk/client/flags" -// codectypes "github.com/cosmos/cosmos-sdk/codec/types" -// clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" - -// "mods.irisnet.org/simapp" -// tokencli "mods.irisnet.org/modules/token/client/cli" -// v1 "mods.irisnet.org/modules/token/types/v1" -// ) - -// func IssueTokenExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// extraArgs ...string, -// ) *simapp.ResponseTx { -// args := []string{ -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, tokencli.GetCmdIssueToken(), args) -// } - -// func EditTokenExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// symbol string, -// extraArgs ...string, -// ) *simapp.ResponseTx { -// args := []string{ -// symbol, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, tokencli.GetCmdEditToken(), args) -// } - -// func MintTokenExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// coinStr string, -// extraArgs ...string, -// ) *simapp.ResponseTx { -// args := []string{ -// coinStr, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, tokencli.GetCmdMintToken(), args) -// } - -// func BurnTokenExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// coinStr string, -// extraArgs ...string, -// ) *simapp.ResponseTx { -// args := []string{ -// coinStr, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, tokencli.GetCmdBurnToken(), args) -// } - -// func TransferTokenOwnerExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// symbol string, -// extraArgs ...string, -// ) *simapp.ResponseTx { -// args := []string{ -// symbol, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, tokencli.GetCmdTransferTokenOwner(), args) -// } - -// func SwapToERC20Exec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// coinStr string, -// extraArgs ...string, -// ) *simapp.ResponseTx { -// args := []string{ -// coinStr, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, tokencli.GetCmdSwapToErc20(), args) -// } - -// func SwapFromERC20Exec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// from string, -// coinStr string, -// extraArgs ...string, -// ) *simapp.ResponseTx { -// args := []string{ -// coinStr, -// fmt.Sprintf("--%s=%s", flags.FlagFrom, from), -// } -// args = append(args, extraArgs...) - -// return network.ExecTxCmdWithResult(t, clientCtx, tokencli.GetCmdSwapFromErc20(), args) -// } - -// func QueryTokenExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// denom string, -// extraArgs ...string, -// ) v1.TokenI { -// args := []string{ -// denom, -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) - -// respType := proto.Message(&codectypes.Any{}) -// network.ExecQueryCmd(t, clientCtx, tokencli.GetCmdQueryToken(), args, respType) - -// var token v1.TokenI -// err := clientCtx.InterfaceRegistry.UnpackAny(respType.(*codectypes.Any), &token) -// require.NoError(t, err, "QueryTokenExec failed") -// return token -// } - -// func QueryTokensExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// owner string, -// extraArgs ...string, -// ) []v1.TokenI { -// args := []string{ -// owner, -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) -// tokens := []v1.TokenI{} -// buf, err := clitestutil.ExecTestCLICmd(clientCtx, tokencli.GetCmdQueryTokens(), args) -// require.NoError(t, err, "QueryTokensExec failed") -// require.NoError(t, clientCtx.LegacyAmino.UnmarshalJSON(buf.Bytes(), &tokens)) -// return tokens -// } - -// func QueryFeeExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// symbol string, -// extraArgs ...string, -// ) *v1.QueryFeesResponse { -// args := []string{ -// symbol, -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) - -// response := &v1.QueryFeesResponse{} -// network.ExecQueryCmd(t, clientCtx, tokencli.GetCmdQueryFee(), args, response) -// return response -// } - -// func QueryParamsExec(t *testing.T, -// network simapp.Network, -// clientCtx client.Context, -// extraArgs ...string, -// ) *v1.Params { -// args := []string{ -// fmt.Sprintf("--%s=json", cli.OutputFlag), -// } -// args = append(args, extraArgs...) - -// response := &v1.Params{} -// network.ExecQueryCmd(t, clientCtx, tokencli.GetCmdQueryParams(), args, response) -// return response -// }