Skip to content

Commit c5fc25f

Browse files
committed
op-e2e: Apply initializer methods and exposed fields
1 parent 81afe2c commit c5fc25f

File tree

7 files changed

+351
-387
lines changed

7 files changed

+351
-387
lines changed

op-e2e/e2eutils/disputegame/claim_helper.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,45 +23,45 @@ type ClaimHelper struct {
2323

2424
func newClaimHelper(game *OutputGameHelper, idx int64, claim ContractClaim) *ClaimHelper {
2525
return &ClaimHelper{
26-
require: game.require,
26+
require: game.Require,
2727
game: game,
28-
index: idx,
29-
parentIndex: claim.ParentIndex,
30-
position: types.NewPositionFromGIndex(claim.Position),
28+
Index: idx,
29+
ParentIndex: claim.ParentIndex,
30+
Position: types.NewPositionFromGIndex(claim.Position),
3131
claim: claim.Claim,
3232
}
3333
}
3434

3535
func (c *ClaimHelper) AgreesWithOutputRoot() bool {
36-
return c.position.Depth()%2 == 0
36+
return c.Position.Depth()%2 == 0
3737
}
3838

3939
func (c *ClaimHelper) IsRootClaim() bool {
40-
return c.position.IsRootPosition()
40+
return c.Position.IsRootPosition()
4141
}
4242

4343
func (c *ClaimHelper) IsOutputRoot(ctx context.Context) bool {
4444
splitDepth := c.game.SplitDepth(ctx)
45-
return c.position.Depth() <= splitDepth
45+
return c.Position.Depth() <= splitDepth
4646
}
4747

4848
func (c *ClaimHelper) IsOutputRootLeaf(ctx context.Context) bool {
4949
splitDepth := c.game.SplitDepth(ctx)
50-
return c.position.Depth() == splitDepth
50+
return c.Position.Depth() == splitDepth
5151
}
5252

5353
func (c *ClaimHelper) IsBottomGameRoot(ctx context.Context) bool {
5454
splitDepth := c.game.SplitDepth(ctx)
55-
return c.position.Depth() == splitDepth+1
55+
return c.Position.Depth() == splitDepth+1
5656
}
5757

5858
func (c *ClaimHelper) IsMaxDepth(ctx context.Context) bool {
5959
maxDepth := c.game.MaxDepth(ctx)
60-
return c.position.Depth() == maxDepth
60+
return c.Position.Depth() == maxDepth
6161
}
6262

6363
func (c *ClaimHelper) Depth() types.Depth {
64-
return c.position.Depth()
64+
return c.Position.Depth()
6565
}
6666

6767
// WaitForCounterClaim waits for the claim to be countered by another claim being posted.
@@ -72,8 +72,8 @@ func (c *ClaimHelper) WaitForCounterClaim(ctx context.Context, ignoreClaims ...*
7272
// This is the first claim we need to run cannon on, so give it more time
7373
timeout = timeout * 2
7474
}
75-
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 {
76-
return int64(claim.ParentIndex) == c.index && !containsClaim(claimIdx, ignoreClaims)
75+
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 {
76+
return int64(claim.ParentIndex) == c.Index && !containsClaim(claimIdx, ignoreClaims)
7777
})
7878
return newClaimHelper(c.game, counterIdx, counterClaim)
7979
}
@@ -83,28 +83,28 @@ func (c *ClaimHelper) WaitForCountered(ctx context.Context) {
8383
timedCtx, cancel := context.WithTimeout(ctx, defaultTimeout)
8484
defer cancel()
8585
err := wait.For(timedCtx, time.Second, func() (bool, error) {
86-
latestData := c.game.getClaim(ctx, c.index)
86+
latestData := c.game.getClaim(ctx, c.Index)
8787
return latestData.CounteredBy != common.Address{}, nil
8888
})
8989
if err != nil { // Avoid waiting time capturing game data when there's no error
90-
c.require.NoErrorf(err, "Claim %v was not countered\n%v", c.index, c.game.gameData(ctx))
90+
c.require.NoErrorf(err, "Claim %v was not countered\n%v", c.Index, c.game.GameData(ctx))
9191
}
9292
}
9393

9494
func (c *ClaimHelper) RequireCorrectOutputRoot(ctx context.Context) {
9595
c.require.True(c.IsOutputRoot(ctx), "Should not expect a valid output root in the bottom game")
96-
expected, err := c.game.correctOutputProvider.Get(ctx, c.position)
96+
expected, err := c.game.CorrectOutputProvider.Get(ctx, c.Position)
9797
c.require.NoError(err, "Failed to get correct output root")
98-
c.require.Equalf(expected, c.claim, "Should have correct output root in claim %v and position %v", c.index, c.position)
98+
c.require.Equalf(expected, c.claim, "Should have correct output root in claim %v and position %v", c.Index, c.Position)
9999
}
100100

101101
func (c *ClaimHelper) Attack(ctx context.Context, value common.Hash, opts ...MoveOpt) *ClaimHelper {
102-
c.game.Attack(ctx, c.index, value, opts...)
102+
c.game.Attack(ctx, c.Index, value, opts...)
103103
return c.WaitForCounterClaim(ctx)
104104
}
105105

106106
func (c *ClaimHelper) Defend(ctx context.Context, value common.Hash, opts ...MoveOpt) *ClaimHelper {
107-
c.game.Defend(ctx, c.index, value, opts...)
107+
c.game.Defend(ctx, c.Index, value, opts...)
108108
return c.WaitForCounterClaim(ctx)
109109
}
110110

@@ -115,19 +115,19 @@ func (c *ClaimHelper) RequireDifferentClaimValue(other *ClaimHelper) {
115115
func (c *ClaimHelper) RequireOnlyCounteredBy(ctx context.Context, expected ...*ClaimHelper) {
116116
claims := c.game.getAllClaims(ctx)
117117
for idx, claim := range claims {
118-
if int64(claim.ParentIndex) != c.index {
118+
if int64(claim.ParentIndex) != c.Index {
119119
// Doesn't counter this claim, so ignore
120120
continue
121121
}
122122
if !containsClaim(int64(idx), expected) {
123123
// Found a countering claim not in the expected list. Fail.
124-
c.require.FailNowf("Found unexpected countering claim", "Parent claim index: %v Game state:\n%v", c.index, c.game.gameData(ctx))
124+
c.require.FailNowf("Found unexpected countering claim", "Parent claim index: %v Game state:\n%v", c.Index, c.game.GameData(ctx))
125125
}
126126
}
127127
}
128128

129129
func containsClaim(claimIdx int64, haystack []*ClaimHelper) bool {
130130
return slices.ContainsFunc(haystack, func(candidate *ClaimHelper) bool {
131-
return candidate.index == claimIdx
131+
return candidate.Index == claimIdx
132132
})
133133
}

op-e2e/e2eutils/disputegame/dishonest_helper.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (d *DishonestHelper) ExhaustDishonestClaims(ctx context.Context, rootClaim
3939
}
4040

4141
d.LogGameData(ctx)
42-
d.OutputGameHelper.t.Logf("Dishonest moves against claimIndex %d", claimIndex)
42+
d.OutputGameHelper.T.Logf("Dishonest moves against claimIndex %d", claimIndex)
4343
agreeWithLevel := d.defender == (pos.Depth()%2 == 0)
4444
if !agreeWithLevel {
4545
d.OutputHonestHelper.Attack(ctx, claimIndex, WithIgnoreDuplicates())
@@ -53,7 +53,7 @@ func (d *DishonestHelper) ExhaustDishonestClaims(ctx context.Context, rootClaim
5353
}
5454
}
5555

56-
numClaimsSeen := rootClaim.index
56+
numClaimsSeen := rootClaim.Index
5757
for {
5858
// Use a short timeout since we don't know the challenger will respond,
5959
// and this is only designed for the alphabet game where the response should be fast.
@@ -63,7 +63,7 @@ func (d *DishonestHelper) ExhaustDishonestClaims(ctx context.Context, rootClaim
6363
// There's nothing to respond to.
6464
break
6565
}
66-
d.OutputGameHelper.require.NoError(err)
66+
d.OutputGameHelper.Require.NoError(err)
6767

6868
for ; numClaimsSeen < newCount; numClaimsSeen++ {
6969
claimData := d.getClaim(ctx, numClaimsSeen)

0 commit comments

Comments
 (0)