-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from tellor-io/salt
Add e2e and oracle keeper tests
- Loading branch information
Showing
21 changed files
with
1,712 additions
and
21 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,3 +52,4 @@ enum VoteEnum { | |
VOTE_SUPPORT = 1; | ||
VOTE_AGAINST = 2; | ||
} | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package keeper_test | ||
|
||
func (s *KeeperTestSuite) TestRewardVoters() { | ||
// require := s.Require() | ||
|
||
// s.disputeKeeper.RewardVoters(s.ctx, ) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package keeper_test | ||
|
||
import ( | ||
oracletypes "github.com/tellor-io/layer/x/oracle/types" | ||
) | ||
|
||
// TODO: fix all of these to match bytes | ||
|
||
func (s *KeeperTestSuite) TestGetCycleList() { | ||
// require := s.Require() | ||
|
||
// list, err := s.oracleKeeper.GetCyclelist(s.ctx) | ||
// require.NoError(err) | ||
// require.Contains(list, ethQueryData[2:]) | ||
// require.Contains(list, btcQueryData[2:]) | ||
// require.Contains(list, trbQueryData[2:]) | ||
} | ||
|
||
func (s *KeeperTestSuite) TestRotateQueries() { | ||
require := s.Require() | ||
|
||
// todo: match the bytes | ||
list, err := s.oracleKeeper.GetCyclelist(s.ctx) | ||
require.NoError(err) | ||
|
||
// first query from cycle list (trb) | ||
firstQuery, err := s.oracleKeeper.GetCurrentQueryInCycleList(s.ctx) | ||
require.NoError(err) | ||
require.Contains(list, firstQuery) | ||
// require.Equal(firstQuery, trbQueryData[2:]) | ||
|
||
// second query from cycle list (eth) | ||
err = s.oracleKeeper.RotateQueries(s.ctx) | ||
require.NoError(err) | ||
secondQuery, err := s.oracleKeeper.GetCurrentQueryInCycleList(s.ctx) | ||
require.NoError(err) | ||
require.Contains(list, secondQuery) | ||
// require.Equal(secondQuery, ethQueryData[2:]) | ||
|
||
// third query from cycle list (btc) | ||
err = s.oracleKeeper.RotateQueries(s.ctx) | ||
require.NoError(err) | ||
thirdQuery, err := s.oracleKeeper.GetCurrentQueryInCycleList(s.ctx) | ||
require.NoError(err) | ||
require.Contains(list, thirdQuery) | ||
// require.Equal(thirdQuery, btcQueryData[2:]) | ||
|
||
// Rotate through a couple times | ||
for i := 0; i < 10; i++ { | ||
query, err := s.oracleKeeper.GetCurrentQueryInCycleList(s.ctx) | ||
require.NoError(err) | ||
err = s.oracleKeeper.RotateQueries(s.ctx) | ||
require.NoError(err) | ||
require.Contains(list, query) | ||
} | ||
} | ||
|
||
func (s *KeeperTestSuite) TestInitCycleListQuery() { | ||
// require := s.Require() | ||
|
||
// startingList, err := s.oracleKeeper.GetCyclelist(s.ctx) | ||
// require.NoError(err) | ||
// require.Contains(startingList, ethQueryData) | ||
// require.Contains(startingList, btcQueryData) | ||
// require.Contains(startingList, trbQueryData) | ||
// newQueryData := "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000953706f745072696365000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003657469000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000037573640000000000000000000000000000000000000000000000000000000000" | ||
|
||
// s.oracleKeeper.InitCycleListQuery(s.ctx, []string{newQueryData}) | ||
// newList, err := s.oracleKeeper.GetCyclelist(s.ctx) | ||
// fmt.Println(newList) | ||
// require.NoError(err) | ||
// require.Contains(newList, newQueryData) | ||
} | ||
|
||
func (s *KeeperTestSuite) TestGenesisCycleList() { | ||
require := s.Require() | ||
|
||
err := s.oracleKeeper.GenesisCycleList(s.ctx, oracletypes.InitialCycleList()) | ||
require.NoError(err) | ||
|
||
cycleList, err := s.oracleKeeper.GetCyclelist(s.ctx) | ||
require.NoError(err) | ||
_ = cycleList | ||
// require.Contains(cycleList, ethQueryData[2:]) | ||
// require.Contains(cycleList, btcQueryData[2:]) | ||
// require.Contains(cycleList, trbQueryData[2:]) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package keeper_test | ||
|
||
func (s *KeeperTestSuite) TestTip() { | ||
// require := s.Require() | ||
|
||
// queryData := "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000953706F745072696365000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003657468000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000037573640000000000000000000000000000000000000000000000000000000000" | ||
// tip := sdk.NewCoin("loya", math.NewInt(1000)) | ||
// msg := types.MsgTip{ | ||
// Tipper: Addr.String(), | ||
// QueryData: queryData, | ||
// Amount: tip, | ||
// } | ||
// _, err := s.msgServer.Tip(s.ctx, &msg) | ||
// require.NoError(err) | ||
|
||
} | ||
|
||
func (s *KeeperTestSuite) TestTipWithInvalidDenom() { | ||
// require := s.Require() | ||
|
||
// queryData := "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000953706F745072696365000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003657468000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000037573640000000000000000000000000000000000000000000000000000000000" | ||
// tip := sdk.NewCoin("invalidDenom", math.NewInt(1000)) | ||
// msg := types.MsgTip{ | ||
// Tipper: Addr.String(), | ||
// QueryData: queryData, | ||
// Amount: tip, | ||
// } | ||
// _, err := s.msgServer.Tip(s.ctx, &msg) | ||
// require.ErrorContains(err, "invalid request") | ||
} | ||
|
||
func (s *KeeperTestSuite) TestTipWithZeroAmount() { | ||
// require := s.Require() | ||
|
||
// queryData := "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000953706F745072696365000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003657468000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000037573640000000000000000000000000000000000000000000000000000000000" | ||
// tip := sdk.NewCoin("loya", math.NewInt(0)) | ||
// msg := types.MsgTip{ | ||
// Tipper: Addr.String(), | ||
// QueryData: queryData, | ||
// Amount: tip, | ||
// } | ||
// _, err := s.msgServer.Tip(s.ctx, &msg) | ||
// require.ErrorContains(err, "invalid request") | ||
} | ||
|
||
func (s *KeeperTestSuite) TestTipWithNegativeAmount() { | ||
// require := s.Require() | ||
|
||
// queryData := "0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000953706F745072696365000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000C0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000003657468000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000037573640000000000000000000000000000000000000000000000000000000000" | ||
// require.Panics(func() { | ||
// tip := sdk.NewCoin("loya", math.NewInt(-1000)) | ||
// msg := types.MsgTip{ | ||
// Tipper: Addr.String(), | ||
// QueryData: queryData, | ||
// Amount: tip, | ||
// } | ||
// _, _ = s.msgServer.Tip(s.ctx, &msg) | ||
// }, "negative coin amount should panic") | ||
} | ||
|
||
func (s *KeeperTestSuite) TestTipWithInvalidQueryData() { | ||
// require := s.Require() | ||
|
||
// queryData := "badQueryData" | ||
// tip := sdk.NewCoin("loya", math.NewInt(1000)) | ||
// msg := types.MsgTip{ | ||
// Tipper: Addr.String(), | ||
// QueryData: queryData, | ||
// Amount: tip, | ||
// } | ||
// _, err := s.msgServer.Tip(s.ctx, &msg) | ||
// require.Error(err) | ||
// require.Panics(func() { _, _ = s.msgServer.Tip(s.ctx, &msg) }, "invalid query data should panic") | ||
} |
Oops, something went wrong.