-
Notifications
You must be signed in to change notification settings - Fork 680
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
feat(e2e): add e2e tests for the evidence module #1779
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
bfb1843
add tests for evidence
Pantani dfa7902
query evidence by hash
Pantani 25a1819
Merge branch 'main' into feat/e2e-evidence
Pantani 3f75f5f
fix some typos
Pantani 5c5a7bd
Merge remote-tracking branch 'origin/main' into feat/e2e-evidence
Pantani fc1da9d
Merge remote-tracking branch 'origin/main' into feat/e2e-evidence
Pantani ecf8f00
use global constants to avoid duplicated string
Pantani c8c4c05
add constant for the query command
Pantani 9a7f1c5
build url inline
Pantani 7a1e120
Merge branch 'main' into feat/e2e-evidence
Pantani 41a6a01
Merge branch 'main' into feat/e2e-evidence
Pantani b08fc7e
Merge branch 'main' into feat/e2e-evidence
okwme File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,29 @@ | ||
package e2e | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/cosmos/cosmos-sdk/x/evidence/exported" | ||
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" | ||
) | ||
|
||
func (s *IntegrationTestSuite) TestEvidence() { | ||
s.Run("test evidence queries", func() { | ||
var ( | ||
valIdx = 0 | ||
chain = s.chainA | ||
chainAPI = fmt.Sprintf("http://%s", s.valResources[chain.id][valIdx].GetHostPort("1317/tcp")) | ||
) | ||
res, err := queryAllEvidence(chainAPI) | ||
s.Require().NoError(err) | ||
s.Require().Equal(numberOfEvidences, len(res.Evidence)) | ||
for _, evidence := range res.Evidence { | ||
var exportedEvidence exported.Evidence | ||
err := cdc.UnpackAny(evidence, &exportedEvidence) | ||
s.Require().NoError(err) | ||
eq, ok := exportedEvidence.(*evidencetypes.Equivocation) | ||
s.Require().True(ok) | ||
s.execQueryEvidence(chain, valIdx, eq.Hash().String()) | ||
} | ||
}) | ||
} |
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,30 @@ | ||
package e2e | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" | ||
) | ||
|
||
func (s *IntegrationTestSuite) execQueryEvidence(c *chain, valIdx int, hash string) (res evidencetypes.Equivocation) { | ||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute) | ||
defer cancel() | ||
|
||
s.T().Logf("querying evidence %s on chain %s", hash, c.id) | ||
|
||
gaiaCommand := []string{ | ||
gaiadBinary, | ||
queryCommand, | ||
evidencetypes.ModuleName, | ||
hash, | ||
} | ||
|
||
s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, func(stdOut []byte, stdErr []byte) bool { | ||
// TODO parse evidence after fix the SDK | ||
// https://github.com/cosmos/cosmos-sdk/issues/13444 | ||
// s.Require().NoError(yaml.Unmarshal(stdOut, &res)) | ||
return true | ||
}) | ||
return res | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A more complicated scenario would be to have blocks with the following:
... and check for those as well. Future todo?