Skip to content

Commit

Permalink
refactor TestAddNewSymbolToBandOracleRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
DongLieu committed Nov 13, 2024
1 parent e35ba2d commit 39bb8b9
Showing 1 changed file with 13 additions and 27 deletions.
40 changes: 13 additions & 27 deletions x/oracle/keeper/band_oracle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,36 +429,22 @@ func (s *KeeperTestSuite) TestAddNewSymbolToBandOracleRequest() {
42: {"ATOM", "OSMO"},
52: {"USD", "EUR", "JPY"},
}
)

// 42-1.ATOM
err := s.k.AddNewSymbolToBandOracleRequest(s.Ctx, symbolScript[42][0], 42)
s.Require().NoError(err)
// 42-2.OSMO
err = s.k.AddNewSymbolToBandOracleRequest(s.Ctx, symbolScript[42][1], 42)
s.Require().NoError(err)

// 42-1.ATOM duplicate test
err = s.k.AddNewSymbolToBandOracleRequest(s.Ctx, symbolScript[42][0], 42)
s.Require().NoError(err)

// 52-1.USD
err = s.k.AddNewSymbolToBandOracleRequest(s.Ctx, symbolScript[52][0], 52)
s.Require().NoError(err)

// 52-2.EUR
err = s.k.AddNewSymbolToBandOracleRequest(s.Ctx, symbolScript[52][1], 52)
s.Require().NoError(err)

// 52-3.JPY
err = s.k.AddNewSymbolToBandOracleRequest(s.Ctx, symbolScript[52][2], 52)
s.Require().NoError(err)
setSymbolScript = func() {
for oracleScriptId, symbols := range symbolScript {
for _, symbol := range symbols {
err := s.k.AddNewSymbolToBandOracleRequest(s.Ctx, symbol, oracleScriptId)
s.Require().NoError(err)
}
}
}
)

// 52-1.USD duplicate test
err = s.k.AddNewSymbolToBandOracleRequest(s.Ctx, symbolScript[52][0], 52)
s.Require().NoError(err)
setSymbolScript()
// duplicate AddNewSymbolToBandOracleRequest test
setSymbolScript()

err = s.k.IteratorOracleRequests(s.Ctx, func(bandOracleRequest types.BandOracleRequest) bool {
err := s.k.IteratorOracleRequests(s.Ctx, func(bandOracleRequest types.BandOracleRequest) bool {
expSymbols, ok := symbolScript[bandOracleRequest.OracleScriptId]
s.Require().True(ok)
s.Require().Equal(len(expSymbols), len(bandOracleRequest.Symbols))
Expand Down

0 comments on commit 39bb8b9

Please sign in to comment.