@@ -23,45 +23,45 @@ type ClaimHelper struct {
2323
2424func 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
3535func (c * ClaimHelper ) AgreesWithOutputRoot () bool {
36- return c .position .Depth ()% 2 == 0
36+ return c .Position .Depth ()% 2 == 0
3737}
3838
3939func (c * ClaimHelper ) IsRootClaim () bool {
40- return c .position .IsRootPosition ()
40+ return c .Position .IsRootPosition ()
4141}
4242
4343func (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
4848func (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
5353func (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
5858func (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
6363func (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
9494func (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
101101func (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
106106func (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) {
115115func (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
129129func 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}
0 commit comments