Browse Source

e2e: evidence test refactor (#7146)

I've seen this failure a few times and this change seems like it
reduces the number of times that we're waiting (and can therefore hit
a timeout.)
e2e-limit-experiment
Sam Kleinman 3 years ago
committed by GitHub
parent
commit
88bdd328ed
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 24 deletions
  1. +19
    -24
      test/e2e/runner/evidence.go

+ 19
- 24
test/e2e/runner/evidence.go View File

@ -33,14 +33,10 @@ func InjectEvidence(ctx context.Context, r *rand.Rand, testnet *e2e.Testnet, amo
var targetNode *e2e.Node
for _, idx := range r.Perm(len(testnet.Nodes)) {
targetNode = testnet.Nodes[idx]
if targetNode.Mode == e2e.ModeSeed || targetNode.Mode == e2e.ModeLight {
targetNode = nil
continue
if !testnet.Nodes[idx].Stateless() {
targetNode = testnet.Nodes[idx]
break
}
break
}
if targetNode == nil {
@ -55,15 +51,14 @@ func InjectEvidence(ctx context.Context, r *rand.Rand, testnet *e2e.Testnet, amo
}
// request the latest block and validator set from the node
blockRes, err := client.Block(context.Background(), nil)
blockRes, err := client.Block(ctx, nil)
if err != nil {
return err
}
evidenceHeight := blockRes.Block.Height
waitHeight := blockRes.Block.Height + 3
evidenceHeight := blockRes.Block.Height - 3
nValidators := 100
valRes, err := client.Validators(context.Background(), &evidenceHeight, nil, &nValidators)
valRes, err := client.Validators(ctx, &evidenceHeight, nil, &nValidators)
if err != nil {
return err
}
@ -79,12 +74,8 @@ func InjectEvidence(ctx context.Context, r *rand.Rand, testnet *e2e.Testnet, amo
return err
}
wctx, cancel := context.WithTimeout(ctx, time.Minute)
defer cancel()
// wait for the node to reach the height above the forged height so that
// it is able to validate the evidence
_, err = waitForNode(wctx, targetNode, waitHeight)
// request the latest block and validator set from the node
blockRes, err = client.Block(ctx, &evidenceHeight)
if err != nil {
return err
}
@ -104,24 +95,28 @@ func InjectEvidence(ctx context.Context, r *rand.Rand, testnet *e2e.Testnet, amo
return err
}
_, err := client.BroadcastEvidence(context.Background(), ev)
_, err := client.BroadcastEvidence(ctx, ev)
if err != nil {
return err
}
}
wctx, cancel = context.WithTimeout(ctx, 30*time.Second)
logger.Info("Finished sending evidence",
"node", testnet.Name,
"amount", amount,
"height", evidenceHeight,
)
wctx, cancel := context.WithTimeout(ctx, time.Minute)
defer cancel()
// wait for the node to reach the height above the forged height so that
// it is able to validate the evidence
_, err = waitForNode(wctx, targetNode, blockRes.Block.Height+2)
// wait for the node to make progress after submitting
// evidence (3 (forged height) + 1 (progress))
_, err = waitForNode(wctx, targetNode, evidenceHeight+4)
if err != nil {
return err
}
logger.Info(fmt.Sprintf("Finished sending evidence (height %d)", blockRes.Block.Height+2))
return nil
}


Loading…
Cancel
Save