Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyaoy committed Oct 21, 2024
1 parent 8ef78fb commit 756af23
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 61 deletions.
48 changes: 15 additions & 33 deletions protocol/testing/e2e/gov/prices_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,15 @@ import (

var (
GENESIS_MARKET_PARAM = pricestypes.MarketParam{
Id: 0,
Pair: "btc-adv4tnt",
Exponent: -8,
MinExchanges: 2,
MinPriceChangePpm: 1_000,
ExchangeConfigJson: "{}",
Id: 0,
Pair: "btc-adv4tnt",
MinPriceChangePpm: 1_000,
}

MODIFIED_MARKET_PARAM = pricestypes.MarketParam{
Id: GENESIS_MARKET_PARAM.Id,
Pair: GENESIS_MARKET_PARAM.Pair,
Exponent: GENESIS_MARKET_PARAM.Exponent, // exponent cannot be updated
MinExchanges: 3,
MinPriceChangePpm: 2_002,
ExchangeConfigJson: `{"exchanges":[{"exchangeName":"Bitfinex","ticker":"tBTCUSD"}]}`,
Id: GENESIS_MARKET_PARAM.Id,
Pair: GENESIS_MARKET_PARAM.Pair,
MinPriceChangePpm: 2_002,
}
)

Expand All @@ -57,12 +51,9 @@ func TestUpdateMarketParam(t *testing.T) {
msg: &pricestypes.MsgUpdateMarketParam{
Authority: lib.GovModuleAddress.String(),
MarketParam: pricestypes.MarketParam{
Id: MODIFIED_MARKET_PARAM.Id + 1, // id does not exist
Pair: MODIFIED_MARKET_PARAM.Pair,
Exponent: MODIFIED_MARKET_PARAM.Exponent,
MinExchanges: MODIFIED_MARKET_PARAM.MinExchanges,
MinPriceChangePpm: MODIFIED_MARKET_PARAM.MinPriceChangePpm,
ExchangeConfigJson: MODIFIED_MARKET_PARAM.ExchangeConfigJson,
Id: MODIFIED_MARKET_PARAM.Id + 1, // id does not exist
Pair: MODIFIED_MARKET_PARAM.Pair,
MinPriceChangePpm: MODIFIED_MARKET_PARAM.MinPriceChangePpm,
},
},
expectedProposalStatus: govtypesv1.ProposalStatus_PROPOSAL_STATUS_FAILED,
Expand All @@ -71,12 +62,9 @@ func TestUpdateMarketParam(t *testing.T) {
msg: &pricestypes.MsgUpdateMarketParam{
Authority: lib.GovModuleAddress.String(),
MarketParam: pricestypes.MarketParam{
Id: MODIFIED_MARKET_PARAM.Id,
Pair: "nonexistent-pair",
Exponent: MODIFIED_MARKET_PARAM.Exponent,
MinExchanges: MODIFIED_MARKET_PARAM.MinExchanges,
MinPriceChangePpm: MODIFIED_MARKET_PARAM.MinPriceChangePpm,
ExchangeConfigJson: MODIFIED_MARKET_PARAM.ExchangeConfigJson,
Id: MODIFIED_MARKET_PARAM.Id,
Pair: "nonexistent-pair",
MinPriceChangePpm: MODIFIED_MARKET_PARAM.MinPriceChangePpm,
},
},
expectedProposalStatus: govtypesv1.ProposalStatus_PROPOSAL_STATUS_FAILED,
Expand All @@ -85,12 +73,9 @@ func TestUpdateMarketParam(t *testing.T) {
msg: &pricestypes.MsgUpdateMarketParam{
Authority: lib.GovModuleAddress.String(),
MarketParam: pricestypes.MarketParam{
Id: MODIFIED_MARKET_PARAM.Id,
Pair: "", // invalid
Exponent: MODIFIED_MARKET_PARAM.Exponent,
MinExchanges: MODIFIED_MARKET_PARAM.MinExchanges,
MinPriceChangePpm: MODIFIED_MARKET_PARAM.MinPriceChangePpm,
ExchangeConfigJson: MODIFIED_MARKET_PARAM.ExchangeConfigJson,
Id: MODIFIED_MARKET_PARAM.Id,
Pair: "", // invalid
MinPriceChangePpm: MODIFIED_MARKET_PARAM.MinPriceChangePpm,
},
},
expectCheckTxFails: true,
Expand Down Expand Up @@ -149,10 +134,7 @@ func TestUpdateMarketParam(t *testing.T) {
marketParamPrice := pricestest.GenerateMarketParamPrice(
pricestest.WithId(GENESIS_MARKET_PARAM.Id),
pricestest.WithPair(GENESIS_MARKET_PARAM.Pair),
pricestest.WithExponent(GENESIS_MARKET_PARAM.Exponent),
pricestest.WithMinExchanges(GENESIS_MARKET_PARAM.MinExchanges),
pricestest.WithMinPriceChangePpm(GENESIS_MARKET_PARAM.MinPriceChangePpm),
pricestest.WithExchangeConfigJson(GENESIS_MARKET_PARAM.ExchangeConfigJson),
)
genesisState.MarketParams = []pricestypes.MarketParam{marketParamPrice.Param}
genesisState.MarketPrices = []pricestypes.MarketPrice{marketParamPrice.Price}
Expand Down
28 changes: 0 additions & 28 deletions protocol/x/prices/keeper/msg_server_update_market_param_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,6 @@ func TestUpdateMarketParam(t *testing.T) {
},
expectedErr: "Pair cannot be empty",
},
"Failure: update to 0 min exchanges": {
msg: &pricestypes.MsgUpdateMarketParam{
Authority: lib.GovModuleAddress.String(),
MarketParam: pricestypes.MarketParam{
Id: testMarketParam.Id,
Pair: testMarketParam.Pair,
Exponent: testMarketParam.Exponent,
MinExchanges: 0, // invalid
MinPriceChangePpm: testMarketParam.MinPriceChangePpm,
ExchangeConfigJson: testMarketParam.ExchangeConfigJson,
},
},
expectedErr: "Min exchanges must be greater than zero",
},
"Failure: update to 0 min price change ppm": {
msg: &pricestypes.MsgUpdateMarketParam{
Authority: lib.GovModuleAddress.String(),
Expand All @@ -108,20 +94,6 @@ func TestUpdateMarketParam(t *testing.T) {
},
expectedErr: "Invalid input",
},
"Failure: update to invalid exchange config json": {
msg: &pricestypes.MsgUpdateMarketParam{
Authority: lib.GovModuleAddress.String(),
MarketParam: pricestypes.MarketParam{
Id: testMarketParam.Id,
Pair: testMarketParam.Pair,
Exponent: testMarketParam.Exponent,
MinExchanges: testMarketParam.MinExchanges,
MinPriceChangePpm: testMarketParam.MinPriceChangePpm,
ExchangeConfigJson: `{{"exchanges":[{"exchangeName":"XYZ","ticker":"PIKACHU"}]}`, // invalid json
},
},
expectedErr: "Invalid input",
},
"Failure: new pair name does not exist in marketmap": {
msg: &pricestypes.MsgUpdateMarketParam{
Authority: lib.GovModuleAddress.String(),
Expand Down

0 comments on commit 756af23

Please sign in to comment.