diff --git a/tests/integration/connect_setup.go b/tests/integration/connect_setup.go index 385f6dd9a..99f1ee0df 100644 --- a/tests/integration/connect_setup.go +++ b/tests/integration/connect_setup.go @@ -305,6 +305,33 @@ func QueryCurrencyPair(chain *cosmos.CosmosChain, cp connecttypes.CurrencyPair, return res.Price, int64(res.Nonce), nil } +// QueryMarket queries a market from the market map. +func QueryMarket(chain *cosmos.CosmosChain, cp connecttypes.CurrencyPair) (mmtypes.Market, error) { + grpcAddr := chain.GetHostGRPCAddress() + + // create the client + cc, err := grpc.Dial(grpcAddr, grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + return mmtypes.Market{}, err + } + defer cc.Close() + + // create the mm client + client := mmtypes.NewQueryClient(cc) + + ctx := context.Background() + + // query the currency pairs + res, err := client.Market(ctx, &mmtypes.MarketRequest{ + CurrencyPair: cp, + }) + if err != nil { + return mmtypes.Market{}, err + } + + return res.Market, nil +} + // SubmitProposal creates and submits a proposal to the chain func SubmitProposal(chain *cosmos.CosmosChain, deposit sdk.Coin, submitter string, msgs ...sdk.Msg) (string, error) { // build the proposal @@ -375,9 +402,9 @@ func (s *ConnectIntegrationSuite) AddCurrencyPairs(chain *cosmos.CosmosChain, us } } - msg := &mmtypes.MsgCreateMarkets{ - Authority: s.user.FormattedAddress(), - CreateMarkets: creates, + msg := &mmtypes.MsgUpsertMarkets{ + Authority: s.user.FormattedAddress(), + Markets: creates, } tx := CreateTx(s.T(), s.chain, user, gasPrice, msg) @@ -398,6 +425,35 @@ func (s *ConnectIntegrationSuite) AddCurrencyPairs(chain *cosmos.CosmosChain, us return nil } +func (s *ConnectIntegrationSuite) RemoveMarket(chain *cosmos.CosmosChain, user cosmos.User, + markets []connecttypes.CurrencyPair) error { + marketString := make([]string, len(markets)) + for i, market := range markets { + marketString[i] = market.String() + } + + msg := &mmtypes.MsgRemoveMarkets{ + Admin: s.user.FormattedAddress(), + Markets: marketString, + } + + tx := CreateTx(s.T(), s.chain, s.user, gasPrice, msg) + + // get an rpc endpoint for the chain + client := chain.Nodes()[0].Client + // broadcast the tx + resp, err := client.BroadcastTxCommit(context.Background(), tx) + if err != nil { + return err + } + + if resp.TxResult.Code != abcitypes.CodeTypeOK { + return fmt.Errorf(resp.TxResult.Log) + } + + return nil +} + func (s *ConnectIntegrationSuite) UpdateCurrencyPair(chain *cosmos.CosmosChain, markets []mmtypes.Market) error { msg := &mmtypes.MsgUpsertMarkets{ Authority: s.user.FormattedAddress(), diff --git a/tests/integration/connect_suite.go b/tests/integration/connect_suite.go index 01b6479db..4fd4a6640 100644 --- a/tests/integration/connect_suite.go +++ b/tests/integration/connect_suite.go @@ -386,6 +386,15 @@ func (s *ConnectOracleIntegrationSuite) TestOracleModule() { disabledTicker(disabledCP), }...)) + market, err := QueryMarket(s.chain, disabledCP) + s.Require().NoError(err) + s.Require().NotNil(market) + + s.Require().NoError(s.RemoveMarket(s.chain, s.user, []connecttypes.CurrencyPair{disabledCP})) + + // check removed + _, err = QueryMarket(s.chain, disabledCP) + s.Require().Error(err) }) }