Commit 061f0b8b authored by Adrian Sutton's avatar Adrian Sutton Committed by GitHub

op-e2e: Extend timeout for waiting for claims when first running cannon (#9500)

parent a00a3a11
...@@ -68,7 +68,12 @@ func (c *ClaimHelper) Depth() types.Depth { ...@@ -68,7 +68,12 @@ func (c *ClaimHelper) Depth() types.Depth {
// WaitForCounterClaim waits for the claim to be countered by another claim being posted. // WaitForCounterClaim waits for the claim to be countered by another claim being posted.
// It returns a helper for the claim that countered this one. // It returns a helper for the claim that countered this one.
func (c *ClaimHelper) WaitForCounterClaim(ctx context.Context, ignoreClaims ...*ClaimHelper) *ClaimHelper { 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 int64(claim.ParentIndex) == c.index && !containsClaim(claimIdx, ignoreClaims)
}) })
return newClaimHelper(c.game, counterIdx, counterClaim) return newClaimHelper(c.game, counterIdx, counterClaim)
......
...@@ -172,8 +172,8 @@ func (g *OutputGameHelper) MaxDepth(ctx context.Context) types.Depth { ...@@ -172,8 +172,8 @@ func (g *OutputGameHelper) MaxDepth(ctx context.Context) types.Depth {
return types.Depth(depth.Uint64()) return types.Depth(depth.Uint64())
} }
func (g *OutputGameHelper) waitForClaim(ctx context.Context, errorMsg string, predicate func(claimIdx int64, claim ContractClaim) bool) (int64, ContractClaim) { 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, defaultTimeout) timedCtx, cancel := context.WithTimeout(ctx, timeout)
defer cancel() defer cancel()
var matchedClaim ContractClaim var matchedClaim ContractClaim
var matchClaimIdx int64 var matchClaimIdx int64
...@@ -255,6 +255,7 @@ func (g *OutputGameHelper) getClaim(ctx context.Context, claimIdx int64) Contrac ...@@ -255,6 +255,7 @@ func (g *OutputGameHelper) getClaim(ctx context.Context, claimIdx int64) Contrac
func (g *OutputGameHelper) WaitForClaimAtDepth(ctx context.Context, depth types.Depth) { func (g *OutputGameHelper) WaitForClaimAtDepth(ctx context.Context, depth types.Depth) {
g.waitForClaim( g.waitForClaim(
ctx, ctx,
defaultTimeout,
fmt.Sprintf("Could not find claim depth %v", depth), fmt.Sprintf("Could not find claim depth %v", depth),
func(_ int64, claim ContractClaim) bool { func(_ int64, claim ContractClaim) bool {
pos := types.NewPositionFromGIndex(claim.Position) pos := types.NewPositionFromGIndex(claim.Position)
...@@ -266,6 +267,7 @@ func (g *OutputGameHelper) WaitForClaimAtMaxDepth(ctx context.Context, countered ...@@ -266,6 +267,7 @@ func (g *OutputGameHelper) WaitForClaimAtMaxDepth(ctx context.Context, countered
maxDepth := g.MaxDepth(ctx) maxDepth := g.MaxDepth(ctx)
g.waitForClaim( g.waitForClaim(
ctx, ctx,
defaultTimeout,
fmt.Sprintf("Could not find claim depth %v with countered=%v", maxDepth, countered), fmt.Sprintf("Could not find claim depth %v with countered=%v", maxDepth, countered),
func(_ int64, claim ContractClaim) bool { func(_ int64, claim ContractClaim) bool {
pos := types.NewPositionFromGIndex(claim.Position) pos := types.NewPositionFromGIndex(claim.Position)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment