e2e: more reliable method for selecting node to inject evidence (#6880)

In retrospect my previous implementation of this node, could get
unlucky and never find the correct node. This method is more reliable.
This commit is contained in:
Sam Kleinman
2021-08-31 17:56:06 -04:00
committed by GitHub
parent c4df8a3840
commit 7169d26ddf

View File

@@ -32,8 +32,9 @@ func InjectEvidence(testnet *e2e.Testnet, amount int) error {
// select a random node
var targetNode *e2e.Node
for i := 0; i < len(testnet.Nodes)-1; i++ {
targetNode = testnet.Nodes[rand.Intn(len(testnet.Nodes))] // nolint: gosec
for _, idx := range rand.Perm(len(testnet.Nodes)) {
targetNode = testnet.Nodes[idx]
if targetNode.Mode == e2e.ModeSeed {
targetNode = nil
continue