Skip to content

Commit

Permalink
allow ability to add new cpps without new denoms
Browse files Browse the repository at this point in the history
  • Loading branch information
rbajollari committed Oct 13, 2023
1 parent df12261 commit af3131e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
6 changes: 4 additions & 2 deletions x/oracle/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,10 @@ func (ms msgServer) GovAddDenoms(
plan.Changes.CurrencyDeviationThresholds = append(plan.Changes.CurrencyDeviationThresholds, cdt)
}

// also update RewardBand key
plan.Keys = append(plan.Keys, string(types.KeyRewardBands))
// also update RewardBand key if new denoms are getting added
if len(msg.DenomList) != 0 {
plan.Keys = append(plan.Keys, string(types.KeyRewardBands))
}

// validate plan construction before scheduling
err := plan.ValidateBasic()
Expand Down
48 changes: 48 additions & 0 deletions x/oracle/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,27 @@ func (s *IntegrationTestSuite) TestMsgServer_GovAddDenom() {
Threshold: "2.0",
},
}
currencyPairProviders2 := oracletypes.CurrencyPairProvidersList{
{
BaseDenom: "FOOBAR",
QuoteDenom: "BAR",
PairAddress: []oracletypes.PairAddressProvider{
{
Address: "address2",
AddressProvider: "provider2",
},
},
Providers: []string{
"provider2",
},
},
}
currencyDeviationThresholds2 := oracletypes.CurrencyDeviationThresholdList{
{
BaseDenom: "FOOBAR",
Threshold: "2.0",
},
}

testCases := []struct {
name string
Expand Down Expand Up @@ -604,6 +625,22 @@ func (s *IntegrationTestSuite) TestMsgServer_GovAddDenom() {
false,
"",
},
{
"valid currency pair providers and currency deviation thresholds addition with no new denoms",
&types.MsgGovAddDenoms{
Authority: govAccAddr,
Title: "test",
Description: "test",
Height: 9,
DenomList: types.DenomList{},
Mandatory: true,

CurrencyPairProviders: currencyPairProviders2,
CurrencyDeviationThresholds: currencyDeviationThresholds2,
},
false,
"",
},
{
"invalid multiple addition",
&types.MsgGovAddDenoms{
Expand Down Expand Up @@ -784,6 +821,17 @@ func (s *IntegrationTestSuite) TestMsgServer_GovAddDenom() {
band, err := rwb.GetBandFromDenom("REWARD")
s.Require().Equal(band, sdk.NewDecWithPrec(2, 3))
s.Require().NoError(err)

case "valid currency pair providers and currency deviation thresholds addition with no new denoms":
cpp := s.app.OracleKeeper.CurrencyPairProviders(s.ctx)
for i := range currencyPairProviders2 {
s.Require().Contains(cpp, currencyPairProviders2[i])
}

cdt := s.app.OracleKeeper.CurrencyDeviationThresholds(s.ctx)
for i := range currencyDeviationThresholds2 {
s.Require().Contains(cdt, currencyDeviationThresholds2[i])
}
}
}
})
Expand Down

0 comments on commit af3131e

Please sign in to comment.