-
Notifications
You must be signed in to change notification settings - Fork 693
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
Changes from 2 commits
bfb1843
dfa7902
25a1819
3f75f5f
5c5a7bd
fc1da9d
ecf8f00
c8c4c05
9a7f1c5
7a1e120
41a6a01
b08fc7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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("teste query evidences", func() { | ||
Pantani marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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()) | ||
} | ||
}) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import ( | |
"cosmossdk.io/math" | ||
"github.com/cosmos/cosmos-sdk/client/flags" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" | ||
"github.com/ory/dockertest/v3/docker" | ||
) | ||
|
||
|
@@ -602,6 +603,28 @@ func (s *IntegrationTestSuite) registerICA(owner, connectionID string) { | |
s.T().Logf("%s reigstered an interchain account on chain %s from chain %s", owner, s.chainB.id, s.chainA.id) | ||
Pantani marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
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, | ||
"q", | ||
"evidence", | ||
hash, | ||
} | ||
|
||
s.executeGaiaTxCommand(ctx, c, gaiaCommand, valIdx, func(stdOut []byte, stdErr []byte) bool { | ||
Pantani marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: we might want to rename or rework There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I agree! I also moved the other API queries to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah sounds great 👍 |
||
// 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 | ||
} | ||
|
||
func (s *IntegrationTestSuite) executeGaiaTxCommand(ctx context.Context, c *chain, gaiaCommand []string, valIdx int, validation func([]byte, []byte) bool) { | ||
if validation == nil { | ||
validation = s.defaultExecValidation(s.chainA, 0) | ||
|
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?