-
Notifications
You must be signed in to change notification settings - Fork 715
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: Add an interchaintest for double signing evidence (#3415)
- Loading branch information
1 parent
1ba35f5
commit 23f666b
Showing
1 changed file
with
62 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package delegator_test | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/cosmos/gaia/v21/tests/interchain/chainsuite" | ||
"github.com/cosmos/gaia/v21/tests/interchain/delegator" | ||
"github.com/strangelove-ventures/interchaintest/v8" | ||
"github.com/strangelove-ventures/interchaintest/v8/testutil" | ||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
type EvidenceSuite struct { | ||
*delegator.Suite | ||
} | ||
|
||
func (s *EvidenceSuite) TestDoubleSigning() { | ||
from, to := 0, 3 | ||
privkey, err := s.Chain.Validators[from].PrivValFileContent(s.GetContext()) | ||
s.Require().NoError(err) | ||
s.Require().NoError(s.Chain.Validators[to].OverwritePrivValFile(s.GetContext(), privkey)) | ||
|
||
s.Require().NoError(s.Chain.StopAllNodes(s.GetContext())) | ||
|
||
s.Require().NoError(s.Chain.Validators[to].CreateNodeContainer(s.GetContext())) | ||
s.Require().NoError(s.Chain.Validators[to].StartContainer(s.GetContext())) | ||
time.Sleep(10 * time.Second) | ||
s.Require().NoError(s.Chain.Validators[from].CreateNodeContainer(s.GetContext())) | ||
s.Require().NoError(s.Chain.Validators[from].StartContainer(s.GetContext())) | ||
time.Sleep(10 * time.Second) | ||
|
||
for i := 0; i < len(s.Chain.Validators); i++ { | ||
if i == from || i == to { | ||
continue | ||
} | ||
s.Require().NoError(s.Chain.Validators[i].CreateNodeContainer(s.GetContext())) | ||
s.Require().NoError(s.Chain.Validators[i].StartContainer(s.GetContext())) | ||
} | ||
s.Require().NoError(testutil.WaitForBlocks(s.GetContext(), 5, s.Chain)) | ||
|
||
evidence, err := s.Chain.QueryJSON(s.GetContext(), "evidence", "evidence", "list") | ||
s.Require().NoError(err) | ||
s.Require().NotEmpty(evidence.Array()) | ||
valcons := evidence.Get("0.value.consensus_address").String() | ||
s.Require().NotEmpty(valcons) | ||
s.Require().Equal(s.Chain.ValidatorWallets[from].ValConsAddress, valcons) | ||
} | ||
|
||
func TestEvidence(t *testing.T) { | ||
nodes := 4 | ||
s := &EvidenceSuite{ | ||
Suite: &delegator.Suite{Suite: chainsuite.NewSuite(chainsuite.SuiteConfig{ | ||
UpgradeOnSetup: true, | ||
ChainSpec: &interchaintest.ChainSpec{ | ||
NumValidators: &nodes, | ||
}, | ||
})}, | ||
} | ||
suite.Run(t, s) | ||
|
||
} |