Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove internal dep on historical info in testing package #7305

Merged
merged 7 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 58 additions & 58 deletions modules/light-clients/07-tendermint/misbehaviour_handle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

err = path.EndpointA.UpdateClient()
suite.Require().NoError(err)
Expand All @@ -63,8 +63,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

misbehaviour = &ibctm.Misbehaviour{
Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.ProposedHeader.Height+3, trustedHeight, suite.chainB.ProposedHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers),
Expand All @@ -78,8 +78,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

misbehaviour = &ibctm.Misbehaviour{
Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.ProposedHeader.Height+3, trustedHeight, suite.chainB.ProposedHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers),
Expand All @@ -93,8 +93,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

misbehaviour = &ibctm.Misbehaviour{
Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.ProposedHeader.Height+1, trustedHeight, suite.chainB.ProposedHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers),
Expand All @@ -107,17 +107,17 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() {
trustedHeight1, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals1, err := suite.chainB.GetTrustedValidators(int64(trustedHeight1.RevisionHeight))
suite.Require().NoError(err)
trustedVals1, ok := suite.chainB.TrustedValidators[trustedHeight1.RevisionHeight]
suite.Require().True(ok)

err = path.EndpointA.UpdateClient()
suite.Require().NoError(err)

trustedHeight2, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals2, err := suite.chainB.GetTrustedValidators(int64(trustedHeight2.RevisionHeight))
suite.Require().NoError(err)
trustedVals2, ok := suite.chainB.TrustedValidators[trustedHeight2.RevisionHeight]
suite.Require().True(ok)

misbehaviour = &ibctm.Misbehaviour{
Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.ProposedHeader.Height, trustedHeight1, suite.chainB.ProposedHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals1, suite.chainB.Signers),
Expand All @@ -131,8 +131,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

err = path.EndpointA.UpdateClient()
suite.Require().NoError(err)
Expand All @@ -156,8 +156,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

height, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)
Expand All @@ -176,8 +176,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

// increment revision of chainID
err = path.EndpointB.UpgradeChain()
Expand All @@ -198,8 +198,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

err = path.EndpointA.UpdateClient()
suite.Require().NoError(err)
Expand All @@ -223,8 +223,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

err = path.EndpointA.UpdateClient()
suite.Require().NoError(err)
Expand Down Expand Up @@ -260,8 +260,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

misbehaviour = &ibctm.Misbehaviour{
Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.ProposedHeader.Height, trustedHeight.Increment().(clienttypes.Height), suite.chainB.ProposedHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers),
Expand All @@ -279,8 +279,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

err = path.EndpointA.UpdateClient()
suite.Require().NoError(err)
Expand All @@ -301,8 +301,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

err = path.EndpointA.UpdateClient()
suite.Require().NoError(err)
Expand All @@ -321,8 +321,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

err = path.EndpointA.UpdateClient()
suite.Require().NoError(err)
Expand All @@ -341,8 +341,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

err = path.EndpointA.UpdateClient()
suite.Require().NoError(err)
Expand Down Expand Up @@ -418,8 +418,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

err = path.EndpointA.UpdateClient()
suite.Require().NoError(err)
Expand All @@ -439,8 +439,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

misbehaviour = &ibctm.Misbehaviour{
Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.ProposedHeader.Height+3, trustedHeight, suite.chainB.ProposedHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers),
Expand All @@ -454,8 +454,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

misbehaviour = &ibctm.Misbehaviour{
Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.ProposedHeader.Height+3, trustedHeight, suite.chainB.ProposedHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers),
Expand All @@ -469,8 +469,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

misbehaviour = &ibctm.Misbehaviour{
Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.ProposedHeader.Height+1, trustedHeight, suite.chainB.ProposedHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers),
Expand All @@ -483,17 +483,17 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() {
trustedHeight1, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals1, err := suite.chainB.GetTrustedValidators(int64(trustedHeight1.RevisionHeight))
suite.Require().NoError(err)
trustedVals1, ok := suite.chainB.TrustedValidators[trustedHeight1.RevisionHeight]
suite.Require().True(ok)

err = path.EndpointA.UpdateClient()
suite.Require().NoError(err)

trustedHeight2, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals2, err := suite.chainB.GetTrustedValidators(int64(trustedHeight2.RevisionHeight))
suite.Require().NoError(err)
trustedVals2, ok := suite.chainB.TrustedValidators[trustedHeight2.RevisionHeight]
suite.Require().True(ok)

misbehaviour = &ibctm.Misbehaviour{
Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.ProposedHeader.Height, trustedHeight1, suite.chainB.ProposedHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals1, suite.chainB.Signers),
Expand All @@ -507,8 +507,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

err = path.EndpointA.UpdateClient()
suite.Require().NoError(err)
Expand All @@ -532,8 +532,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

err = path.EndpointA.UpdateClient()
suite.Require().NoError(err)
Expand Down Expand Up @@ -569,8 +569,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

misbehaviour = &ibctm.Misbehaviour{
Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.ProposedHeader.Height, trustedHeight.Increment().(clienttypes.Height), suite.chainB.ProposedHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers),
Expand All @@ -588,8 +588,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

err = path.EndpointA.UpdateClient()
suite.Require().NoError(err)
Expand All @@ -610,8 +610,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

err = path.EndpointA.UpdateClient()
suite.Require().NoError(err)
Expand All @@ -630,8 +630,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

err = path.EndpointA.UpdateClient()
suite.Require().NoError(err)
Expand All @@ -650,8 +650,8 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() {
trustedHeight, ok := path.EndpointA.GetClientLatestHeight().(clienttypes.Height)
suite.Require().True(ok)

trustedVals, err := suite.chainB.GetTrustedValidators(int64(trustedHeight.RevisionHeight))
suite.Require().NoError(err)
trustedVals, ok := suite.chainB.TrustedValidators[trustedHeight.RevisionHeight]
suite.Require().True(ok)

err = path.EndpointA.UpdateClient()
suite.Require().NoError(err)
Expand Down
Loading
Loading