Skip to content

Commit

Permalink
op-e2e: Extend timeout for waiting for claims when first running cann…
Browse files Browse the repository at this point in the history
  • Loading branch information
ajsutton authored Feb 13, 2024
1 parent a00a3a1 commit 061f0b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion op-e2e/e2eutils/disputegame/claim_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ func (c *ClaimHelper) Depth() types.Depth {
// WaitForCounterClaim waits for the claim to be countered by another claim being posted.
// It returns a helper for the claim that countered this one.
func (c *ClaimHelper) WaitForCounterClaim(ctx context.Context, ignoreClaims ...*ClaimHelper) *ClaimHelper {
counterIdx, counterClaim := c.game.waitForClaim(ctx, fmt.Sprintf("failed to find claim with parent idx %v", c.index), func(claimIdx int64, claim ContractClaim) bool {
timeout := defaultTimeout
if c.IsOutputRootLeaf(ctx) {
// This is the first claim we need to run cannon on, so give it more time
timeout = timeout * 2
}
counterIdx, counterClaim := c.game.waitForClaim(ctx, timeout, fmt.Sprintf("failed to find claim with parent idx %v", c.index), func(claimIdx int64, claim ContractClaim) bool {
return int64(claim.ParentIndex) == c.index && !containsClaim(claimIdx, ignoreClaims)
})
return newClaimHelper(c.game, counterIdx, counterClaim)
Expand Down
6 changes: 4 additions & 2 deletions op-e2e/e2eutils/disputegame/output_game_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ func (g *OutputGameHelper) MaxDepth(ctx context.Context) types.Depth {
return types.Depth(depth.Uint64())
}

func (g *OutputGameHelper) waitForClaim(ctx context.Context, errorMsg string, predicate func(claimIdx int64, claim ContractClaim) bool) (int64, ContractClaim) {
timedCtx, cancel := context.WithTimeout(ctx, defaultTimeout)
func (g *OutputGameHelper) waitForClaim(ctx context.Context, timeout time.Duration, errorMsg string, predicate func(claimIdx int64, claim ContractClaim) bool) (int64, ContractClaim) {
timedCtx, cancel := context.WithTimeout(ctx, timeout)
defer cancel()
var matchedClaim ContractClaim
var matchClaimIdx int64
Expand Down Expand Up @@ -255,6 +255,7 @@ func (g *OutputGameHelper) getClaim(ctx context.Context, claimIdx int64) Contrac
func (g *OutputGameHelper) WaitForClaimAtDepth(ctx context.Context, depth types.Depth) {
g.waitForClaim(
ctx,
defaultTimeout,
fmt.Sprintf("Could not find claim depth %v", depth),
func(_ int64, claim ContractClaim) bool {
pos := types.NewPositionFromGIndex(claim.Position)
Expand All @@ -266,6 +267,7 @@ func (g *OutputGameHelper) WaitForClaimAtMaxDepth(ctx context.Context, countered
maxDepth := g.MaxDepth(ctx)
g.waitForClaim(
ctx,
defaultTimeout,
fmt.Sprintf("Could not find claim depth %v with countered=%v", maxDepth, countered),
func(_ int64, claim ContractClaim) bool {
pos := types.NewPositionFromGIndex(claim.Position)
Expand Down

0 comments on commit 061f0b8

Please sign in to comment.