Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
83de09b5
Unverified
Commit
83de09b5
authored
Feb 26, 2024
by
Adrian Sutton
Committed by
GitHub
Feb 25, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-challenger: Use opts pattern for claim builder (#9650)
parent
3179d49f
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
255 additions
and
257 deletions
+255
-257
agent_test.go
op-challenger/game/fault/agent_test.go
+1
-1
game_solver_test.go
op-challenger/game/fault/solver/game_solver_test.go
+50
-50
solver_test.go
op-challenger/game/fault/solver/solver_test.go
+29
-29
claim_builder.go
op-challenger/game/fault/test/claim_builder.go
+73
-61
game_builder.go
op-challenger/game/fault/test/game_builder.go
+12
-27
seq_builder.go
op-challenger/game/fault/test/seq_builder.go
+6
-6
split_test.go
op-challenger/game/fault/trace/split/split_test.go
+35
-35
resolver_test.go
op-dispute-mon/mon/resolution/resolver_test.go
+49
-48
No files found.
op-challenger/game/fault/agent_test.go
View file @
83de09b5
...
@@ -61,7 +61,7 @@ func TestLoadClaimsWhenGameNotResolvable(t *testing.T) {
...
@@ -61,7 +61,7 @@ func TestLoadClaimsWhenGameNotResolvable(t *testing.T) {
claimBuilder
:=
test
.
NewClaimBuilder
(
t
,
depth
,
alphabet
.
NewTraceProvider
(
big
.
NewInt
(
0
),
depth
))
claimBuilder
:=
test
.
NewClaimBuilder
(
t
,
depth
,
alphabet
.
NewTraceProvider
(
big
.
NewInt
(
0
),
depth
))
claimLoader
.
claims
=
[]
types
.
Claim
{
claimLoader
.
claims
=
[]
types
.
Claim
{
claimBuilder
.
CreateRootClaim
(
true
),
claimBuilder
.
CreateRootClaim
(),
}
}
require
.
NoError
(
t
,
agent
.
Act
(
context
.
Background
()))
require
.
NoError
(
t
,
agent
.
Act
(
context
.
Background
()))
...
...
op-challenger/game/fault/solver/game_solver_test.go
View file @
83de09b5
...
@@ -55,32 +55,32 @@ func TestCalculateNextActions(t *testing.T) {
...
@@ -55,32 +55,32 @@ func TestCalculateNextActions(t *testing.T) {
name
:
"DoNotPerformDuplicateMoves"
,
name
:
"DoNotPerformDuplicateMoves"
,
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
// Expected move has already been made.
// Expected move has already been made.
builder
.
Seq
()
.
Attack
Correct
()
builder
.
Seq
()
.
Attack
()
},
},
},
},
{
{
name
:
"RespondToAllClaimsAtDisagreeingLevel"
,
name
:
"RespondToAllClaimsAtDisagreeingLevel"
,
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
honestClaim
:=
builder
.
Seq
()
.
Attack
Correct
()
honestClaim
:=
builder
.
Seq
()
.
Attack
()
honestClaim
.
Attack
Correct
()
.
ExpectDefend
()
honestClaim
.
Attack
()
.
ExpectDefend
()
honestClaim
.
Defend
Correct
()
.
ExpectDefend
()
honestClaim
.
Defend
()
.
ExpectDefend
()
honestClaim
.
Attack
(
common
.
Hash
{
0xaa
}
)
.
ExpectAttack
()
honestClaim
.
Attack
(
faulttest
.
WithValue
(
common
.
Hash
{
0xaa
})
)
.
ExpectAttack
()
honestClaim
.
Attack
(
common
.
Hash
{
0xbb
}
)
.
ExpectAttack
()
honestClaim
.
Attack
(
faulttest
.
WithValue
(
common
.
Hash
{
0xbb
})
)
.
ExpectAttack
()
honestClaim
.
Defend
(
common
.
Hash
{
0xcc
}
)
.
ExpectAttack
()
honestClaim
.
Defend
(
faulttest
.
WithValue
(
common
.
Hash
{
0xcc
})
)
.
ExpectAttack
()
honestClaim
.
Defend
(
common
.
Hash
{
0xdd
}
)
.
ExpectAttack
()
honestClaim
.
Defend
(
faulttest
.
WithValue
(
common
.
Hash
{
0xdd
})
)
.
ExpectAttack
()
},
},
},
},
{
{
name
:
"StepAtMaxDepth"
,
name
:
"StepAtMaxDepth"
,
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
lastHonestClaim
:=
builder
.
Seq
()
.
lastHonestClaim
:=
builder
.
Seq
()
.
Attack
Correct
()
.
Attack
()
.
Attack
Correct
()
.
Attack
()
.
Defend
Correct
()
.
Defend
()
.
Defend
Correct
()
.
Defend
()
.
Defend
Correct
()
Defend
()
lastHonestClaim
.
Attack
Correct
()
.
ExpectStepDefend
()
lastHonestClaim
.
Attack
()
.
ExpectStepDefend
()
lastHonestClaim
.
Attack
(
common
.
Hash
{
0xdd
}
)
.
ExpectStepAttack
()
lastHonestClaim
.
Attack
(
faulttest
.
WithValue
(
common
.
Hash
{
0xdd
})
)
.
ExpectStepAttack
()
},
},
},
},
{
{
...
@@ -91,23 +91,23 @@ func TestCalculateNextActions(t *testing.T) {
...
@@ -91,23 +91,23 @@ func TestCalculateNextActions(t *testing.T) {
// Dishonest actor counters their own claims to set up a situation with an invalid prestate
// Dishonest actor counters their own claims to set up a situation with an invalid prestate
// The honest actor should ignore path created by the dishonest actor, only supporting its own attack on the root claim
// The honest actor should ignore path created by the dishonest actor, only supporting its own attack on the root claim
honestMove
:=
builder
.
Seq
()
.
Attack
Correct
()
// This expected action is the winning move.
honestMove
:=
builder
.
Seq
()
.
Attack
()
// This expected action is the winning move.
dishonestMove
:=
honestMove
.
Attack
(
maliciousStateHash
)
dishonestMove
:=
honestMove
.
Attack
(
faulttest
.
WithValue
(
maliciousStateHash
)
)
// The expected action by the honest actor
// The expected action by the honest actor
dishonestMove
.
ExpectAttack
()
dishonestMove
.
ExpectAttack
()
// The honest actor will ignore this poisoned path
// The honest actor will ignore this poisoned path
dishonestMove
.
dishonestMove
.
Defend
(
maliciousStateHash
)
.
Defend
(
faulttest
.
WithValue
(
maliciousStateHash
)
)
.
Attack
(
maliciousStateHash
)
Attack
(
faulttest
.
WithValue
(
maliciousStateHash
)
)
},
},
},
},
{
{
name
:
"Freeloader-ValidClaimAtInvalidAttackPosition"
,
name
:
"Freeloader-ValidClaimAtInvalidAttackPosition"
,
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
builder
.
Seq
()
.
builder
.
Seq
()
.
Attack
Correct
()
.
// Honest response to invalid root
Attack
()
.
// Honest response to invalid root
Defend
Correct
()
.
ExpectDefend
()
.
// Defender agrees at this point, we should defend
Defend
()
.
ExpectDefend
()
.
// Defender agrees at this point, we should defend
Attack
Correct
()
.
ExpectDefend
()
// Freeloader attacks instead of defends
Attack
()
.
ExpectDefend
()
// Freeloader attacks instead of defends
},
},
runCondition
:
RunFreeloadersCountered
,
runCondition
:
RunFreeloadersCountered
,
},
},
...
@@ -115,9 +115,9 @@ func TestCalculateNextActions(t *testing.T) {
...
@@ -115,9 +115,9 @@ func TestCalculateNextActions(t *testing.T) {
name
:
"Freeloader-InvalidClaimAtInvalidAttackPosition"
,
name
:
"Freeloader-InvalidClaimAtInvalidAttackPosition"
,
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
builder
.
Seq
()
.
builder
.
Seq
()
.
Attack
Correct
()
.
// Honest response to invalid root
Attack
()
.
// Honest response to invalid root
Defend
Correct
()
.
ExpectDefend
()
.
// Defender agrees at this point, we should defend
Defend
()
.
ExpectDefend
()
.
// Defender agrees at this point, we should defend
Attack
(
common
.
Hash
{
0xbb
}
)
.
ExpectAttack
()
// Freeloader attacks with wrong claim instead of defends
Attack
(
faulttest
.
WithValue
(
common
.
Hash
{
0xbb
})
)
.
ExpectAttack
()
// Freeloader attacks with wrong claim instead of defends
},
},
runCondition
:
RunFreeloadersCountered
,
runCondition
:
RunFreeloadersCountered
,
},
},
...
@@ -125,9 +125,9 @@ func TestCalculateNextActions(t *testing.T) {
...
@@ -125,9 +125,9 @@ func TestCalculateNextActions(t *testing.T) {
name
:
"Freeloader-InvalidClaimAtValidDefensePosition"
,
name
:
"Freeloader-InvalidClaimAtValidDefensePosition"
,
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
builder
.
Seq
()
.
builder
.
Seq
()
.
Attack
Correct
()
.
// Honest response to invalid root
Attack
()
.
// Honest response to invalid root
Defend
Correct
()
.
ExpectDefend
()
.
// Defender agrees at this point, we should defend
Defend
()
.
ExpectDefend
()
.
// Defender agrees at this point, we should defend
Defend
(
common
.
Hash
{
0xbb
}
)
.
ExpectAttack
()
// Freeloader defends with wrong claim, we should attack
Defend
(
faulttest
.
WithValue
(
common
.
Hash
{
0xbb
})
)
.
ExpectAttack
()
// Freeloader defends with wrong claim, we should attack
},
},
runCondition
:
RunFreeloadersCountered
,
runCondition
:
RunFreeloadersCountered
,
},
},
...
@@ -135,9 +135,9 @@ func TestCalculateNextActions(t *testing.T) {
...
@@ -135,9 +135,9 @@ func TestCalculateNextActions(t *testing.T) {
name
:
"Freeloader-InvalidClaimAtValidAttackPosition"
,
name
:
"Freeloader-InvalidClaimAtValidAttackPosition"
,
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
builder
.
Seq
()
.
builder
.
Seq
()
.
Attack
Correct
()
.
// Honest response to invalid root
Attack
()
.
// Honest response to invalid root
Defend
(
common
.
Hash
{
0xaa
}
)
.
ExpectAttack
()
.
// Defender disagrees at this point, we should attack
Defend
(
faulttest
.
WithValue
(
common
.
Hash
{
0xaa
})
)
.
ExpectAttack
()
.
// Defender disagrees at this point, we should attack
Attack
(
common
.
Hash
{
0xbb
}
)
.
ExpectAttack
()
// Freeloader attacks with wrong claim instead of defends
Attack
(
faulttest
.
WithValue
(
common
.
Hash
{
0xbb
})
)
.
ExpectAttack
()
// Freeloader attacks with wrong claim instead of defends
},
},
runCondition
:
RunFreeloadersCountered
,
runCondition
:
RunFreeloadersCountered
,
},
},
...
@@ -145,18 +145,18 @@ func TestCalculateNextActions(t *testing.T) {
...
@@ -145,18 +145,18 @@ func TestCalculateNextActions(t *testing.T) {
name
:
"Freeloader-InvalidClaimAtInvalidDefensePosition"
,
name
:
"Freeloader-InvalidClaimAtInvalidDefensePosition"
,
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
builder
.
Seq
()
.
builder
.
Seq
()
.
Attack
Correct
()
.
// Honest response to invalid root
Attack
()
.
// Honest response to invalid root
Defend
(
common
.
Hash
{
0xaa
}
)
.
ExpectAttack
()
.
// Defender disagrees at this point, we should attack
Defend
(
faulttest
.
WithValue
(
common
.
Hash
{
0xaa
})
)
.
ExpectAttack
()
.
// Defender disagrees at this point, we should attack
Defend
(
common
.
Hash
{
0xbb
}
)
// Freeloader defends with wrong claim but we must not respond to avoid poisoning
Defend
(
faulttest
.
WithValue
(
common
.
Hash
{
0xbb
})
)
// Freeloader defends with wrong claim but we must not respond to avoid poisoning
},
},
},
},
{
{
name
:
"Freeloader-ValidClaimAtInvalidAttackPosition-RespondingToDishonestButCorrectAttack"
,
name
:
"Freeloader-ValidClaimAtInvalidAttackPosition-RespondingToDishonestButCorrectAttack"
,
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
builder
.
Seq
()
.
builder
.
Seq
()
.
Attack
Correct
()
.
// Honest response to invalid root
Attack
()
.
// Honest response to invalid root
Attack
Correct
()
.
ExpectDefend
()
.
// Defender attacks with correct value, we should defend
Attack
()
.
ExpectDefend
()
.
// Defender attacks with correct value, we should defend
Attack
Correct
()
.
ExpectDefend
()
// Freeloader attacks with wrong claim, we should defend
Attack
()
.
ExpectDefend
()
// Freeloader attacks with wrong claim, we should defend
},
},
runCondition
:
RunFreeloadersCountered
,
runCondition
:
RunFreeloadersCountered
,
},
},
...
@@ -164,10 +164,10 @@ func TestCalculateNextActions(t *testing.T) {
...
@@ -164,10 +164,10 @@ func TestCalculateNextActions(t *testing.T) {
name
:
"Freeloader-DoNotCounterOwnClaim"
,
name
:
"Freeloader-DoNotCounterOwnClaim"
,
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
builder
.
Seq
()
.
builder
.
Seq
()
.
Attack
Correct
()
.
// Honest response to invalid root
Attack
()
.
// Honest response to invalid root
Attack
Correct
()
.
ExpectDefend
()
.
// Defender attacks with correct value, we should defend
Attack
()
.
ExpectDefend
()
.
// Defender attacks with correct value, we should defend
Attack
Correct
()
.
// Freeloader attacks instead, we should defend
Attack
()
.
// Freeloader attacks instead, we should defend
Defend
Correct
()
// We do defend and we shouldn't counter our own claim
Defend
()
// We do defend and we shouldn't counter our own claim
},
},
runCondition
:
RunFreeloadersCountered
,
runCondition
:
RunFreeloadersCountered
,
},
},
...
@@ -175,11 +175,11 @@ func TestCalculateNextActions(t *testing.T) {
...
@@ -175,11 +175,11 @@ func TestCalculateNextActions(t *testing.T) {
name
:
"Freeloader-ContinueDefendingAgainstFreeloader"
,
name
:
"Freeloader-ContinueDefendingAgainstFreeloader"
,
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
builder
.
Seq
()
.
// invalid root
builder
.
Seq
()
.
// invalid root
Attack
Correct
()
.
// Honest response to invalid root
Attack
()
.
// Honest response to invalid root
Attack
Correct
()
.
ExpectDefend
()
.
// Defender attacks with correct value, we should defend
Attack
()
.
ExpectDefend
()
.
// Defender attacks with correct value, we should defend
Attack
Correct
()
.
// Freeloader attacks instead, we should defend
Attack
()
.
// Freeloader attacks instead, we should defend
Defend
Correct
()
.
// We do defend
Defend
()
.
// We do defend
Attack
(
common
.
Hash
{
0xaa
})
.
// freeloader attacks our defense, we should attack
Attack
(
faulttest
.
WithValue
(
common
.
Hash
{
0xaa
}))
.
// freeloader attacks our defense, we should attack
ExpectAttack
()
ExpectAttack
()
},
},
runCondition
:
RunFreeloadersCountered
,
runCondition
:
RunFreeloadersCountered
,
...
@@ -188,9 +188,9 @@ func TestCalculateNextActions(t *testing.T) {
...
@@ -188,9 +188,9 @@ func TestCalculateNextActions(t *testing.T) {
name
:
"Freeloader-FreeloaderCountersRootClaim"
,
name
:
"Freeloader-FreeloaderCountersRootClaim"
,
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
builder
.
Seq
()
.
builder
.
Seq
()
.
ExpectAttack
()
.
// Honest response to invalid root
ExpectAttack
()
.
// Honest response to invalid root
Attack
(
common
.
Hash
{
0xaa
}
)
.
// freeloader
Attack
(
faulttest
.
WithValue
(
common
.
Hash
{
0xaa
})
)
.
// freeloader
ExpectAttack
()
// Honest response to freeloader
ExpectAttack
()
// Honest response to freeloader
},
},
runCondition
:
RunFreeloadersCountered
,
runCondition
:
RunFreeloadersCountered
,
},
},
...
@@ -210,7 +210,7 @@ func TestCalculateNextActions(t *testing.T) {
...
@@ -210,7 +210,7 @@ func TestCalculateNextActions(t *testing.T) {
t
.
Skip
(
"Freeloader countering enabled"
)
t
.
Skip
(
"Freeloader countering enabled"
)
}
}
}
}
builder
:=
claimBuilder
.
GameBuilder
(
test
.
rootClaimCorrect
)
builder
:=
claimBuilder
.
GameBuilder
(
faulttest
.
WithInvalidValue
(
!
test
.
rootClaimCorrect
)
)
test
.
setupGame
(
builder
)
test
.
setupGame
(
builder
)
game
:=
builder
.
Game
game
:=
builder
.
Game
logClaims
(
t
,
game
)
logClaims
(
t
,
game
)
...
...
op-challenger/game/fault/solver/solver_test.go
View file @
83de09b5
...
@@ -41,9 +41,9 @@ func TestAttemptStep(t *testing.T) {
...
@@ -41,9 +41,9 @@ func TestAttemptStep(t *testing.T) {
expectedOracleData
:
claimBuilder
.
CorrectOracleData
(
common
.
Big0
),
expectedOracleData
:
claimBuilder
.
CorrectOracleData
(
common
.
Big0
),
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
builder
.
Seq
()
.
builder
.
Seq
()
.
Attack
(
common
.
Hash
{
0xaa
}
)
.
Attack
(
faulttest
.
WithValue
(
common
.
Hash
{
0xaa
})
)
.
Attack
Correct
()
.
Attack
()
.
Attack
(
common
.
Hash
{
0xbb
}
)
Attack
(
faulttest
.
WithValue
(
common
.
Hash
{
0xbb
})
)
},
},
},
},
{
{
...
@@ -54,9 +54,9 @@ func TestAttemptStep(t *testing.T) {
...
@@ -54,9 +54,9 @@ func TestAttemptStep(t *testing.T) {
expectedOracleData
:
claimBuilder
.
CorrectOracleData
(
big
.
NewInt
(
1
)),
expectedOracleData
:
claimBuilder
.
CorrectOracleData
(
big
.
NewInt
(
1
)),
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
builder
.
Seq
()
.
builder
.
Seq
()
.
Attack
(
common
.
Hash
{
0xaa
}
)
.
Attack
(
faulttest
.
WithValue
(
common
.
Hash
{
0xaa
})
)
.
Attack
Correct
()
.
Attack
()
.
Attack
Correct
()
Attack
()
},
},
},
},
{
{
...
@@ -67,9 +67,9 @@ func TestAttemptStep(t *testing.T) {
...
@@ -67,9 +67,9 @@ func TestAttemptStep(t *testing.T) {
expectedOracleData
:
claimBuilder
.
CorrectOracleData
(
big
.
NewInt
(
4
)),
expectedOracleData
:
claimBuilder
.
CorrectOracleData
(
big
.
NewInt
(
4
)),
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
builder
.
Seq
()
.
builder
.
Seq
()
.
Attack
Correct
()
.
Attack
()
.
Defend
Correct
()
.
Defend
()
.
Attack
(
common
.
Hash
{
0xaa
}
)
Attack
(
faulttest
.
WithValue
(
common
.
Hash
{
0xaa
})
)
},
},
},
},
{
{
...
@@ -80,9 +80,9 @@ func TestAttemptStep(t *testing.T) {
...
@@ -80,9 +80,9 @@ func TestAttemptStep(t *testing.T) {
expectedOracleData
:
claimBuilder
.
CorrectOracleData
(
big
.
NewInt
(
5
)),
expectedOracleData
:
claimBuilder
.
CorrectOracleData
(
big
.
NewInt
(
5
)),
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
builder
.
Seq
()
.
builder
.
Seq
()
.
Attack
Correct
()
.
Attack
()
.
Defend
Correct
()
.
Defend
()
.
Attack
Correct
()
Attack
()
},
},
},
},
{
{
...
@@ -93,9 +93,9 @@ func TestAttemptStep(t *testing.T) {
...
@@ -93,9 +93,9 @@ func TestAttemptStep(t *testing.T) {
expectedOracleData
:
claimBuilder
.
CorrectOracleData
(
lastLeafTraceIndex
),
expectedOracleData
:
claimBuilder
.
CorrectOracleData
(
lastLeafTraceIndex
),
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
builder
.
Seq
()
.
builder
.
Seq
()
.
Attack
Correct
()
.
Attack
()
.
Defend
Correct
()
.
Defend
()
.
Defend
(
common
.
Hash
{
0xaa
}
)
Defend
(
faulttest
.
WithValue
(
common
.
Hash
{
0xaa
})
)
},
},
},
},
{
{
...
@@ -106,15 +106,15 @@ func TestAttemptStep(t *testing.T) {
...
@@ -106,15 +106,15 @@ func TestAttemptStep(t *testing.T) {
expectedOracleData
:
claimBuilder
.
CorrectOracleData
(
lastLeafTraceIndexPlusOne
),
expectedOracleData
:
claimBuilder
.
CorrectOracleData
(
lastLeafTraceIndexPlusOne
),
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
builder
.
Seq
()
.
builder
.
Seq
()
.
Attack
Correct
()
.
Attack
()
.
Defend
Correct
()
.
Defend
()
.
Defend
Correct
()
Defend
()
},
},
},
},
{
{
name
:
"CannotStepNonLeaf"
,
name
:
"CannotStepNonLeaf"
,
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
builder
.
Seq
()
.
Attack
Correct
()
.
AttackCorrect
()
builder
.
Seq
()
.
Attack
()
.
Attack
()
},
},
expectedErr
:
ErrStepNonLeafNode
,
expectedErr
:
ErrStepNonLeafNode
,
agreeWithOutputRoot
:
true
,
agreeWithOutputRoot
:
true
,
...
@@ -123,9 +123,9 @@ func TestAttemptStep(t *testing.T) {
...
@@ -123,9 +123,9 @@ func TestAttemptStep(t *testing.T) {
name
:
"CannotStepAgreedNode"
,
name
:
"CannotStepAgreedNode"
,
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
builder
.
Seq
()
.
builder
.
Seq
()
.
Attack
Correct
()
.
Attack
()
.
Attack
(
common
.
Hash
{
0xaa
}
)
.
Attack
(
faulttest
.
WithValue
(
common
.
Hash
{
0xaa
})
)
.
Attack
Correct
()
Attack
()
},
},
expectedErr
:
ErrStepIgnoreInvalidPath
,
expectedErr
:
ErrStepIgnoreInvalidPath
,
agreeWithOutputRoot
:
true
,
agreeWithOutputRoot
:
true
,
...
@@ -134,9 +134,9 @@ func TestAttemptStep(t *testing.T) {
...
@@ -134,9 +134,9 @@ func TestAttemptStep(t *testing.T) {
name
:
"CannotStepInvalidPath"
,
name
:
"CannotStepInvalidPath"
,
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
builder
.
Seq
()
.
builder
.
Seq
()
.
Attack
(
common
.
Hash
{
0xaa
}
)
.
Attack
(
faulttest
.
WithValue
(
common
.
Hash
{
0xaa
})
)
.
Attack
(
common
.
Hash
{
0xbb
}
)
.
Attack
(
faulttest
.
WithValue
(
common
.
Hash
{
0xbb
})
)
.
Attack
(
common
.
Hash
{
0xcc
}
)
Attack
(
faulttest
.
WithValue
(
common
.
Hash
{
0xcc
})
)
},
},
expectedErr
:
ErrStepIgnoreInvalidPath
,
expectedErr
:
ErrStepIgnoreInvalidPath
,
agreeWithOutputRoot
:
true
,
agreeWithOutputRoot
:
true
,
...
@@ -149,9 +149,9 @@ func TestAttemptStep(t *testing.T) {
...
@@ -149,9 +149,9 @@ func TestAttemptStep(t *testing.T) {
expectedOracleData
:
claimBuilder
.
CorrectOracleData
(
big
.
NewInt
(
4
)),
expectedOracleData
:
claimBuilder
.
CorrectOracleData
(
big
.
NewInt
(
4
)),
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
setupGame
:
func
(
builder
*
faulttest
.
GameBuilder
)
{
builder
.
Seq
()
.
builder
.
Seq
()
.
Attack
Correct
()
.
Attack
()
.
Defend
Correct
()
.
Defend
()
.
Defend
Correct
()
Defend
()
},
},
expectedErr
:
ErrStepIgnoreInvalidPath
,
expectedErr
:
ErrStepIgnoreInvalidPath
,
agreeWithOutputRoot
:
true
,
agreeWithOutputRoot
:
true
,
...
@@ -161,7 +161,7 @@ func TestAttemptStep(t *testing.T) {
...
@@ -161,7 +161,7 @@ func TestAttemptStep(t *testing.T) {
for
_
,
tableTest
:=
range
tests
{
for
_
,
tableTest
:=
range
tests
{
tableTest
:=
tableTest
tableTest
:=
tableTest
t
.
Run
(
tableTest
.
name
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
tableTest
.
name
,
func
(
t
*
testing
.
T
)
{
builder
:=
claimBuilder
.
GameBuilder
(
!
tableTest
.
agreeWithOutputRoot
)
builder
:=
claimBuilder
.
GameBuilder
(
faulttest
.
WithInvalidValue
(
tableTest
.
agreeWithOutputRoot
)
)
tableTest
.
setupGame
(
builder
)
tableTest
.
setupGame
(
builder
)
alphabetSolver
:=
newClaimSolver
(
maxDepth
,
trace
.
NewSimpleTraceAccessor
(
claimBuilder
.
CorrectTraceProvider
()))
alphabetSolver
:=
newClaimSolver
(
maxDepth
,
trace
.
NewSimpleTraceAccessor
(
claimBuilder
.
CorrectTraceProvider
()))
game
:=
builder
.
Game
game
:=
builder
.
Game
...
...
op-challenger/game/fault/test/claim_builder.go
View file @
83de09b5
...
@@ -12,6 +12,55 @@ import (
...
@@ -12,6 +12,55 @@ import (
var
DefaultClaimant
=
common
.
Address
{
0x09
,
0x23
,
0x34
,
0x45
,
0x13
,
0xb3
}
var
DefaultClaimant
=
common
.
Address
{
0x09
,
0x23
,
0x34
,
0x45
,
0x13
,
0xb3
}
type
claimCfg
struct
{
value
common
.
Hash
invalidValue
bool
claimant
common
.
Address
parentIdx
int
}
func
newClaimCfg
(
opts
...
ClaimOpt
)
*
claimCfg
{
cfg
:=
&
claimCfg
{}
for
_
,
opt
:=
range
opts
{
opt
.
Apply
(
cfg
)
}
return
cfg
}
type
ClaimOpt
interface
{
Apply
(
cfg
*
claimCfg
)
}
type
claimOptFn
func
(
cfg
*
claimCfg
)
func
(
c
claimOptFn
)
Apply
(
cfg
*
claimCfg
)
{
c
(
cfg
)
}
func
WithValue
(
value
common
.
Hash
)
ClaimOpt
{
return
claimOptFn
(
func
(
cfg
*
claimCfg
)
{
cfg
.
value
=
value
})
}
func
WithInvalidValue
(
invalid
bool
)
ClaimOpt
{
return
claimOptFn
(
func
(
cfg
*
claimCfg
)
{
cfg
.
invalidValue
=
invalid
})
}
func
WithClaimant
(
claimant
common
.
Address
)
ClaimOpt
{
return
claimOptFn
(
func
(
cfg
*
claimCfg
)
{
cfg
.
claimant
=
claimant
})
}
func
WithParent
(
claim
types
.
Claim
)
ClaimOpt
{
return
claimOptFn
(
func
(
cfg
*
claimCfg
)
{
cfg
.
parentIdx
=
claim
.
ContractIndex
})
}
// ClaimBuilder is a test utility to enable creating claims in a wide range of situations
// ClaimBuilder is a test utility to enable creating claims in a wide range of situations
type
ClaimBuilder
struct
{
type
ClaimBuilder
struct
{
require
*
require
.
Assertions
require
*
require
.
Assertions
...
@@ -67,81 +116,44 @@ func (c *ClaimBuilder) incorrectClaim(pos types.Position) common.Hash {
...
@@ -67,81 +116,44 @@ func (c *ClaimBuilder) incorrectClaim(pos types.Position) common.Hash {
return
common
.
BigToHash
(
pos
.
TraceIndex
(
c
.
maxDepth
))
return
common
.
BigToHash
(
pos
.
TraceIndex
(
c
.
maxDepth
))
}
}
func
(
c
*
ClaimBuilder
)
claim
(
pos
types
.
Position
,
correct
bool
)
common
.
Hash
{
func
(
c
*
ClaimBuilder
)
claim
(
pos
types
.
Position
,
opts
...
ClaimOpt
)
types
.
Claim
{
if
correct
{
cfg
:=
newClaimCfg
(
opts
...
)
return
c
.
CorrectClaimAtPosition
(
pos
)
}
else
{
return
c
.
incorrectClaim
(
pos
)
}
}
func
(
c
*
ClaimBuilder
)
CreateRootClaim
(
correct
bool
)
types
.
Claim
{
value
:=
c
.
claim
(
types
.
NewPositionFromGIndex
(
big
.
NewInt
(
1
)),
correct
)
claim
:=
types
.
Claim
{
claim
:=
types
.
Claim
{
ClaimData
:
types
.
ClaimData
{
ClaimData
:
types
.
ClaimData
{
Value
:
value
,
Position
:
pos
,
Position
:
types
.
NewPosition
(
0
,
common
.
Big0
),
},
},
Claimant
:
DefaultClaimant
,
Claimant
:
DefaultClaimant
,
}
}
if
cfg
.
claimant
!=
(
common
.
Address
{})
{
claim
.
Claimant
=
cfg
.
claimant
}
if
cfg
.
value
!=
(
common
.
Hash
{})
{
claim
.
Value
=
cfg
.
value
}
else
if
cfg
.
invalidValue
{
claim
.
Value
=
c
.
incorrectClaim
(
pos
)
}
else
{
claim
.
Value
=
c
.
CorrectClaimAtPosition
(
pos
)
}
claim
.
ParentContractIndex
=
cfg
.
parentIdx
return
claim
return
claim
}
}
func
(
c
*
ClaimBuilder
)
CreateLeafClaim
(
traceIndex
*
big
.
Int
,
correct
bool
)
types
.
Claim
{
func
(
c
*
ClaimBuilder
)
CreateRootClaim
(
opts
...
ClaimOpt
)
types
.
Claim
{
pos
:=
types
.
NewPosition
(
c
.
maxDepth
,
traceIndex
)
pos
:=
types
.
NewPositionFromGIndex
(
big
.
NewInt
(
1
))
return
types
.
Claim
{
return
c
.
claim
(
pos
,
opts
...
)
ClaimData
:
types
.
ClaimData
{
Value
:
c
.
claim
(
pos
,
correct
),
Position
:
pos
,
},
Claimant
:
DefaultClaimant
,
}
}
}
func
(
c
*
ClaimBuilder
)
AttackClaim
(
claim
types
.
Claim
,
correct
bool
)
types
.
Claim
{
func
(
c
*
ClaimBuilder
)
CreateLeafClaim
(
traceIndex
*
big
.
Int
,
opts
...
ClaimOpt
)
types
.
Claim
{
pos
:=
claim
.
Position
.
Attack
()
pos
:=
types
.
NewPosition
(
c
.
maxDepth
,
traceIndex
)
return
types
.
Claim
{
return
c
.
claim
(
pos
,
opts
...
)
ClaimData
:
types
.
ClaimData
{
Value
:
c
.
claim
(
pos
,
correct
),
Position
:
pos
,
},
ParentContractIndex
:
claim
.
ContractIndex
,
Claimant
:
DefaultClaimant
,
}
}
}
func
(
c
*
ClaimBuilder
)
AttackClaim
WithValue
(
claim
types
.
Claim
,
value
common
.
Hash
)
types
.
Claim
{
func
(
c
*
ClaimBuilder
)
AttackClaim
(
claim
types
.
Claim
,
opts
...
ClaimOpt
)
types
.
Claim
{
pos
:=
claim
.
Position
.
Attack
()
pos
:=
claim
.
Position
.
Attack
()
return
types
.
Claim
{
return
c
.
claim
(
pos
,
append
([]
ClaimOpt
{
WithParent
(
claim
)},
opts
...
)
...
)
ClaimData
:
types
.
ClaimData
{
Value
:
value
,
Position
:
pos
,
},
ParentContractIndex
:
claim
.
ContractIndex
,
Claimant
:
DefaultClaimant
,
}
}
}
func
(
c
*
ClaimBuilder
)
DefendClaim
(
claim
types
.
Claim
,
correct
bool
)
types
.
Claim
{
func
(
c
*
ClaimBuilder
)
DefendClaim
(
claim
types
.
Claim
,
opts
...
ClaimOpt
)
types
.
Claim
{
pos
:=
claim
.
Position
.
Defend
()
pos
:=
claim
.
Position
.
Defend
()
return
types
.
Claim
{
return
c
.
claim
(
pos
,
append
([]
ClaimOpt
{
WithParent
(
claim
)},
opts
...
)
...
)
ClaimData
:
types
.
ClaimData
{
Value
:
c
.
claim
(
pos
,
correct
),
Position
:
pos
,
},
ParentContractIndex
:
claim
.
ContractIndex
,
Claimant
:
DefaultClaimant
,
}
}
func
(
c
*
ClaimBuilder
)
DefendClaimWithValue
(
claim
types
.
Claim
,
value
common
.
Hash
)
types
.
Claim
{
pos
:=
claim
.
Position
.
Defend
()
return
types
.
Claim
{
ClaimData
:
types
.
ClaimData
{
Value
:
value
,
Position
:
pos
,
},
ParentContractIndex
:
claim
.
ContractIndex
,
Claimant
:
DefaultClaimant
,
}
}
}
op-challenger/game/fault/test/game_builder.go
View file @
83de09b5
...
@@ -13,10 +13,10 @@ type GameBuilder struct {
...
@@ -13,10 +13,10 @@ type GameBuilder struct {
ExpectedActions
[]
types
.
Action
ExpectedActions
[]
types
.
Action
}
}
func
(
c
*
ClaimBuilder
)
GameBuilder
(
root
Correct
bool
)
*
GameBuilder
{
func
(
c
*
ClaimBuilder
)
GameBuilder
(
root
Opts
...
ClaimOpt
)
*
GameBuilder
{
return
&
GameBuilder
{
return
&
GameBuilder
{
builder
:
c
,
builder
:
c
,
Game
:
types
.
NewGameState
([]
types
.
Claim
{
c
.
CreateRootClaim
(
root
Correct
)},
c
.
maxDepth
),
Game
:
types
.
NewGameState
([]
types
.
Claim
{
c
.
CreateRootClaim
(
root
Opts
...
)},
c
.
maxDepth
),
}
}
}
}
...
@@ -46,8 +46,8 @@ func (s *GameBuilderSeq) addClaimToGame(claim *types.Claim) {
...
@@ -46,8 +46,8 @@ func (s *GameBuilderSeq) addClaimToGame(claim *types.Claim) {
s
.
gameBuilder
.
Game
=
types
.
NewGameState
(
claims
,
s
.
builder
.
maxDepth
)
s
.
gameBuilder
.
Game
=
types
.
NewGameState
(
claims
,
s
.
builder
.
maxDepth
)
}
}
func
(
s
*
GameBuilderSeq
)
Attack
Correct
(
)
*
GameBuilderSeq
{
func
(
s
*
GameBuilderSeq
)
Attack
(
opts
...
ClaimOpt
)
*
GameBuilderSeq
{
claim
:=
s
.
builder
.
AttackClaim
(
s
.
lastClaim
,
true
)
claim
:=
s
.
builder
.
AttackClaim
(
s
.
lastClaim
,
opts
...
)
s
.
addClaimToGame
(
&
claim
)
s
.
addClaimToGame
(
&
claim
)
return
&
GameBuilderSeq
{
return
&
GameBuilderSeq
{
gameBuilder
:
s
.
gameBuilder
,
gameBuilder
:
s
.
gameBuilder
,
...
@@ -56,8 +56,8 @@ func (s *GameBuilderSeq) AttackCorrect() *GameBuilderSeq {
...
@@ -56,8 +56,8 @@ func (s *GameBuilderSeq) AttackCorrect() *GameBuilderSeq {
}
}
}
}
func
(
s
*
GameBuilderSeq
)
Attack
(
value
common
.
Hash
)
*
GameBuilderSeq
{
func
(
s
*
GameBuilderSeq
)
Defend
(
opts
...
ClaimOpt
)
*
GameBuilderSeq
{
claim
:=
s
.
builder
.
AttackClaimWithValue
(
s
.
lastClaim
,
value
)
claim
:=
s
.
builder
.
DefendClaim
(
s
.
lastClaim
,
opts
...
)
s
.
addClaimToGame
(
&
claim
)
s
.
addClaimToGame
(
&
claim
)
return
&
GameBuilderSeq
{
return
&
GameBuilderSeq
{
gameBuilder
:
s
.
gameBuilder
,
gameBuilder
:
s
.
gameBuilder
,
...
@@ -66,29 +66,14 @@ func (s *GameBuilderSeq) Attack(value common.Hash) *GameBuilderSeq {
...
@@ -66,29 +66,14 @@ func (s *GameBuilderSeq) Attack(value common.Hash) *GameBuilderSeq {
}
}
}
}
func
(
s
*
GameBuilderSeq
)
DefendCorrect
()
*
GameBuilderSeq
{
func
(
s
*
GameBuilderSeq
)
Step
(
opts
...
ClaimOpt
)
{
claim
:=
s
.
builder
.
DefendClaim
(
s
.
lastClaim
,
true
)
cfg
:=
newClaimCfg
(
opts
...
)
s
.
addClaimToGame
(
&
claim
)
claimant
:=
DefaultClaimant
return
&
GameBuilderSeq
{
if
cfg
.
claimant
!=
(
common
.
Address
{})
{
gameBuilder
:
s
.
gameBuilder
,
claimant
=
cfg
.
claimant
builder
:
s
.
builder
,
lastClaim
:
claim
,
}
}
}
func
(
s
*
GameBuilderSeq
)
Defend
(
value
common
.
Hash
)
*
GameBuilderSeq
{
claim
:=
s
.
builder
.
DefendClaimWithValue
(
s
.
lastClaim
,
value
)
s
.
addClaimToGame
(
&
claim
)
return
&
GameBuilderSeq
{
gameBuilder
:
s
.
gameBuilder
,
builder
:
s
.
builder
,
lastClaim
:
claim
,
}
}
func
(
s
*
GameBuilderSeq
)
Step
()
{
claims
:=
s
.
gameBuilder
.
Game
.
Claims
()
claims
:=
s
.
gameBuilder
.
Game
.
Claims
()
claims
[
len
(
claims
)
-
1
]
.
CounteredBy
=
DefaultC
laimant
claims
[
len
(
claims
)
-
1
]
.
CounteredBy
=
c
laimant
s
.
gameBuilder
.
Game
=
types
.
NewGameState
(
claims
,
s
.
builder
.
maxDepth
)
s
.
gameBuilder
.
Game
=
types
.
NewGameState
(
claims
,
s
.
builder
.
maxDepth
)
}
}
...
...
op-challenger/game/fault/test/seq_builder.go
View file @
83de09b5
...
@@ -12,24 +12,24 @@ type SequenceBuilder struct {
...
@@ -12,24 +12,24 @@ type SequenceBuilder struct {
// Seq starts building a claim by following a sequence of attack and defend moves from the root
// Seq starts building a claim by following a sequence of attack and defend moves from the root
// The returned SequenceBuilder can be used to add additional moves. e.g:
// The returned SequenceBuilder can be used to add additional moves. e.g:
// claim := Seq(true).Attack(false).Attack(true).Defend(true).Get()
// claim := Seq(true).Attack(false).Attack(true).Defend(true).Get()
func
(
c
*
ClaimBuilder
)
Seq
(
root
Correct
bool
)
*
SequenceBuilder
{
func
(
c
*
ClaimBuilder
)
Seq
(
root
Opts
...
ClaimOpt
)
*
SequenceBuilder
{
claim
:=
c
.
CreateRootClaim
(
root
Correct
)
claim
:=
c
.
CreateRootClaim
(
root
Opts
...
)
return
&
SequenceBuilder
{
return
&
SequenceBuilder
{
builder
:
c
,
builder
:
c
,
lastClaim
:
claim
,
lastClaim
:
claim
,
}
}
}
}
func
(
s
*
SequenceBuilder
)
Attack
(
correct
bool
)
*
SequenceBuilder
{
func
(
s
*
SequenceBuilder
)
Attack
(
opts
...
ClaimOpt
)
*
SequenceBuilder
{
claim
:=
s
.
builder
.
AttackClaim
(
s
.
lastClaim
,
correct
)
claim
:=
s
.
builder
.
AttackClaim
(
s
.
lastClaim
,
opts
...
)
return
&
SequenceBuilder
{
return
&
SequenceBuilder
{
builder
:
s
.
builder
,
builder
:
s
.
builder
,
lastClaim
:
claim
,
lastClaim
:
claim
,
}
}
}
}
func
(
s
*
SequenceBuilder
)
Defend
(
correct
bool
)
*
SequenceBuilder
{
func
(
s
*
SequenceBuilder
)
Defend
(
opts
...
ClaimOpt
)
*
SequenceBuilder
{
claim
:=
s
.
builder
.
DefendClaim
(
s
.
lastClaim
,
correct
)
claim
:=
s
.
builder
.
DefendClaim
(
s
.
lastClaim
,
opts
...
)
return
&
SequenceBuilder
{
return
&
SequenceBuilder
{
builder
:
s
.
builder
,
builder
:
s
.
builder
,
lastClaim
:
claim
,
lastClaim
:
claim
,
...
...
op-challenger/game/fault/trace/split/split_test.go
View file @
83de09b5
...
@@ -147,12 +147,12 @@ func TestBottomProviderAttackingTopLeaf(t *testing.T) {
...
@@ -147,12 +147,12 @@ func TestBottomProviderAttackingTopLeaf(t *testing.T) {
// If the ref is the leaf of the top claim, ensure we respect whether the test is setup
// If the ref is the leaf of the top claim, ensure we respect whether the test is setup
// to attack or defend the top leaf claim.
// to attack or defend the top leaf claim.
if
ref
.
Depth
()
!=
splitDepth
||
!
pos
.
RightOf
(
ref
.
Position
)
{
if
ref
.
Depth
()
!=
splitDepth
||
!
pos
.
RightOf
(
ref
.
Position
)
{
gameBuilder
.
SeqFrom
(
ref
)
.
Attack
Correct
()
gameBuilder
.
SeqFrom
(
ref
)
.
Attack
()
attackRef
:=
latestClaim
(
gameBuilder
)
attackRef
:=
latestClaim
(
gameBuilder
)
testDescendantClaims
(
attackRef
,
attackRef
.
Position
)
testDescendantClaims
(
attackRef
,
attackRef
.
Position
)
}
}
if
ref
.
Depth
()
!=
splitDepth
||
pos
.
RightOf
(
ref
.
Position
)
{
if
ref
.
Depth
()
!=
splitDepth
||
pos
.
RightOf
(
ref
.
Position
)
{
gameBuilder
.
SeqFrom
(
ref
)
.
Defend
Correct
()
gameBuilder
.
SeqFrom
(
ref
)
.
Defend
()
defendRef
:=
latestClaim
(
gameBuilder
)
defendRef
:=
latestClaim
(
gameBuilder
)
testDescendantClaims
(
defendRef
,
defendRef
.
Position
)
testDescendantClaims
(
defendRef
,
defendRef
.
Position
)
}
}
...
@@ -164,10 +164,10 @@ func TestBottomProviderAttackingTopLeaf(t *testing.T) {
...
@@ -164,10 +164,10 @@ func TestBottomProviderAttackingTopLeaf(t *testing.T) {
func
attackTopLeafGIndex8
(
_
*
testing
.
T
,
gameBuilder
*
test
.
GameBuilder
)
(
ref
types
.
Claim
,
pos
types
.
Position
,
expectPre
types
.
Claim
,
expectPost
types
.
Claim
)
{
func
attackTopLeafGIndex8
(
_
*
testing
.
T
,
gameBuilder
*
test
.
GameBuilder
)
(
ref
types
.
Claim
,
pos
types
.
Position
,
expectPre
types
.
Claim
,
expectPost
types
.
Claim
)
{
// Generate claims down to the top provider's leaf
// Generate claims down to the top provider's leaf
seq
:=
gameBuilder
.
Seq
()
// gindex 1, trace 7
seq
:=
gameBuilder
.
Seq
()
// gindex 1, trace 7
seq
=
seq
.
Attack
Correct
()
// gindex 2, trace 3
seq
=
seq
.
Attack
()
// gindex 2, trace 3
seq
=
seq
.
Attack
Correct
()
// gindex 4, trace 1
seq
=
seq
.
Attack
()
// gindex 4, trace 1
seq
.
Attack
Correct
()
// gindex 8, trace 0
seq
.
Attack
()
// gindex 8, trace 0
expectPost
=
latestClaim
(
gameBuilder
)
expectPost
=
latestClaim
(
gameBuilder
)
// No pre-claim as the first output root is being challenged.
// No pre-claim as the first output root is being challenged.
...
@@ -180,11 +180,11 @@ func attackTopLeafGIndex8(_ *testing.T, gameBuilder *test.GameBuilder) (ref type
...
@@ -180,11 +180,11 @@ func attackTopLeafGIndex8(_ *testing.T, gameBuilder *test.GameBuilder) (ref type
func
defendTopLeafGIndex8
(
_
*
testing
.
T
,
gameBuilder
*
test
.
GameBuilder
)
(
ref
types
.
Claim
,
pos
types
.
Position
,
expectPre
types
.
Claim
,
expectPost
types
.
Claim
)
{
func
defendTopLeafGIndex8
(
_
*
testing
.
T
,
gameBuilder
*
test
.
GameBuilder
)
(
ref
types
.
Claim
,
pos
types
.
Position
,
expectPre
types
.
Claim
,
expectPost
types
.
Claim
)
{
// Generate claims down to the top provider's leaf
// Generate claims down to the top provider's leaf
seq
:=
gameBuilder
.
Seq
()
// gindex 1, trace 7
seq
:=
gameBuilder
.
Seq
()
// gindex 1, trace 7
seq
=
seq
.
Attack
Correct
()
// gindex 2, trace 3
seq
=
seq
.
Attack
()
// gindex 2, trace 3
seq
=
seq
.
Attack
Correct
()
// gindex 4, trace 1
seq
=
seq
.
Attack
()
// gindex 4, trace 1
expectPost
=
latestClaim
(
gameBuilder
)
expectPost
=
latestClaim
(
gameBuilder
)
seq
.
Attack
Correct
()
// gindex 8, trace 0
seq
.
Attack
()
// gindex 8, trace 0
expectPre
=
latestClaim
(
gameBuilder
)
expectPre
=
latestClaim
(
gameBuilder
)
ref
=
latestClaim
(
gameBuilder
)
ref
=
latestClaim
(
gameBuilder
)
...
@@ -193,11 +193,11 @@ func defendTopLeafGIndex8(_ *testing.T, gameBuilder *test.GameBuilder) (ref type
...
@@ -193,11 +193,11 @@ func defendTopLeafGIndex8(_ *testing.T, gameBuilder *test.GameBuilder) (ref type
}
}
func
attackTopLeafGIndex10
(
_
*
testing
.
T
,
gameBuilder
*
test
.
GameBuilder
)
(
ref
types
.
Claim
,
pos
types
.
Position
,
expectPre
types
.
Claim
,
expectPost
types
.
Claim
)
{
func
attackTopLeafGIndex10
(
_
*
testing
.
T
,
gameBuilder
*
test
.
GameBuilder
)
(
ref
types
.
Claim
,
pos
types
.
Position
,
expectPre
types
.
Claim
,
expectPost
types
.
Claim
)
{
seq
:=
gameBuilder
.
Seq
()
// gindex 1, trace 7
seq
:=
gameBuilder
.
Seq
()
// gindex 1, trace 7
seq
=
seq
.
Attack
Correct
()
// gindex 2, trace 3
seq
=
seq
.
Attack
()
// gindex 2, trace 3
seq
=
seq
.
Attack
Correct
()
// gindex 4, trace 1
seq
=
seq
.
Attack
()
// gindex 4, trace 1
expectPre
=
latestClaim
(
gameBuilder
)
expectPre
=
latestClaim
(
gameBuilder
)
seq
.
Defend
Correct
()
// gindex 10, trace 2
seq
.
Defend
()
// gindex 10, trace 2
expectPost
=
latestClaim
(
gameBuilder
)
expectPost
=
latestClaim
(
gameBuilder
)
ref
=
latestClaim
(
gameBuilder
)
ref
=
latestClaim
(
gameBuilder
)
...
@@ -206,11 +206,11 @@ func attackTopLeafGIndex10(_ *testing.T, gameBuilder *test.GameBuilder) (ref typ
...
@@ -206,11 +206,11 @@ func attackTopLeafGIndex10(_ *testing.T, gameBuilder *test.GameBuilder) (ref typ
}
}
func
defendTopLeafGIndex10
(
_
*
testing
.
T
,
gameBuilder
*
test
.
GameBuilder
)
(
ref
types
.
Claim
,
pos
types
.
Position
,
expectPre
types
.
Claim
,
expectPost
types
.
Claim
)
{
func
defendTopLeafGIndex10
(
_
*
testing
.
T
,
gameBuilder
*
test
.
GameBuilder
)
(
ref
types
.
Claim
,
pos
types
.
Position
,
expectPre
types
.
Claim
,
expectPost
types
.
Claim
)
{
seq
:=
gameBuilder
.
Seq
()
// gindex 1, trace 7
seq
:=
gameBuilder
.
Seq
()
// gindex 1, trace 7
seq
=
seq
.
Attack
Correct
()
// gindex 2, trace 3
seq
=
seq
.
Attack
()
// gindex 2, trace 3
expectPost
=
latestClaim
(
gameBuilder
)
expectPost
=
latestClaim
(
gameBuilder
)
seq
=
seq
.
Attack
Correct
()
// gindex 4, trace 1
seq
=
seq
.
Attack
()
// gindex 4, trace 1
seq
.
Defend
Correct
()
// gindex 10, trace 2
seq
.
Defend
()
// gindex 10, trace 2
expectPre
=
latestClaim
(
gameBuilder
)
expectPre
=
latestClaim
(
gameBuilder
)
ref
=
latestClaim
(
gameBuilder
)
ref
=
latestClaim
(
gameBuilder
)
...
@@ -219,11 +219,11 @@ func defendTopLeafGIndex10(_ *testing.T, gameBuilder *test.GameBuilder) (ref typ
...
@@ -219,11 +219,11 @@ func defendTopLeafGIndex10(_ *testing.T, gameBuilder *test.GameBuilder) (ref typ
}
}
func
attackTopLeafGIndex12
(
_
*
testing
.
T
,
gameBuilder
*
test
.
GameBuilder
)
(
ref
types
.
Claim
,
pos
types
.
Position
,
expectPre
types
.
Claim
,
expectPost
types
.
Claim
)
{
func
attackTopLeafGIndex12
(
_
*
testing
.
T
,
gameBuilder
*
test
.
GameBuilder
)
(
ref
types
.
Claim
,
pos
types
.
Position
,
expectPre
types
.
Claim
,
expectPost
types
.
Claim
)
{
seq
:=
gameBuilder
.
Seq
()
// gindex 1, trace 7
seq
:=
gameBuilder
.
Seq
()
// gindex 1, trace 7
seq
=
seq
.
Attack
Correct
()
// gindex 2, trace 3
seq
=
seq
.
Attack
()
// gindex 2, trace 3
expectPre
=
latestClaim
(
gameBuilder
)
expectPre
=
latestClaim
(
gameBuilder
)
seq
=
seq
.
Defend
Correct
()
// gindex 6, trace 5
seq
=
seq
.
Defend
()
// gindex 6, trace 5
seq
.
Attack
Correct
()
// gindex 12, trace 4
seq
.
Attack
()
// gindex 12, trace 4
expectPost
=
latestClaim
(
gameBuilder
)
expectPost
=
latestClaim
(
gameBuilder
)
ref
=
latestClaim
(
gameBuilder
)
ref
=
latestClaim
(
gameBuilder
)
...
@@ -232,11 +232,11 @@ func attackTopLeafGIndex12(_ *testing.T, gameBuilder *test.GameBuilder) (ref typ
...
@@ -232,11 +232,11 @@ func attackTopLeafGIndex12(_ *testing.T, gameBuilder *test.GameBuilder) (ref typ
}
}
func
defendTopLeafGIndex12
(
_
*
testing
.
T
,
gameBuilder
*
test
.
GameBuilder
)
(
ref
types
.
Claim
,
pos
types
.
Position
,
expectPre
types
.
Claim
,
expectPost
types
.
Claim
)
{
func
defendTopLeafGIndex12
(
_
*
testing
.
T
,
gameBuilder
*
test
.
GameBuilder
)
(
ref
types
.
Claim
,
pos
types
.
Position
,
expectPre
types
.
Claim
,
expectPost
types
.
Claim
)
{
seq
:=
gameBuilder
.
Seq
()
// gindex 1, trace 7
seq
:=
gameBuilder
.
Seq
()
// gindex 1, trace 7
seq
=
seq
.
Attack
Correct
()
// gindex 2, trace 3
seq
=
seq
.
Attack
()
// gindex 2, trace 3
seq
=
seq
.
Defend
Correct
()
// gindex 6, trace 5
seq
=
seq
.
Defend
()
// gindex 6, trace 5
expectPost
=
latestClaim
(
gameBuilder
)
expectPost
=
latestClaim
(
gameBuilder
)
seq
.
Attack
Correct
()
// gindex 12, trace 4
seq
.
Attack
()
// gindex 12, trace 4
expectPre
=
latestClaim
(
gameBuilder
)
expectPre
=
latestClaim
(
gameBuilder
)
ref
=
latestClaim
(
gameBuilder
)
ref
=
latestClaim
(
gameBuilder
)
...
@@ -245,11 +245,11 @@ func defendTopLeafGIndex12(_ *testing.T, gameBuilder *test.GameBuilder) (ref typ
...
@@ -245,11 +245,11 @@ func defendTopLeafGIndex12(_ *testing.T, gameBuilder *test.GameBuilder) (ref typ
}
}
func
attackTopLeafGIndex14
(
_
*
testing
.
T
,
gameBuilder
*
test
.
GameBuilder
)
(
ref
types
.
Claim
,
pos
types
.
Position
,
expectPre
types
.
Claim
,
expectPost
types
.
Claim
)
{
func
attackTopLeafGIndex14
(
_
*
testing
.
T
,
gameBuilder
*
test
.
GameBuilder
)
(
ref
types
.
Claim
,
pos
types
.
Position
,
expectPre
types
.
Claim
,
expectPost
types
.
Claim
)
{
seq
:=
gameBuilder
.
Seq
()
// gindex 1, trace 7
seq
:=
gameBuilder
.
Seq
()
// gindex 1, trace 7
seq
=
seq
.
Attack
Correct
()
// gindex 2, trace 3
seq
=
seq
.
Attack
()
// gindex 2, trace 3
seq
=
seq
.
Defend
Correct
()
// gindex 6, trace 5
seq
=
seq
.
Defend
()
// gindex 6, trace 5
expectPre
=
latestClaim
(
gameBuilder
)
expectPre
=
latestClaim
(
gameBuilder
)
seq
.
Defend
Correct
()
// gindex 14, trace 6
seq
.
Defend
()
// gindex 14, trace 6
expectPost
=
latestClaim
(
gameBuilder
)
expectPost
=
latestClaim
(
gameBuilder
)
ref
=
latestClaim
(
gameBuilder
)
ref
=
latestClaim
(
gameBuilder
)
...
@@ -260,9 +260,9 @@ func attackTopLeafGIndex14(_ *testing.T, gameBuilder *test.GameBuilder) (ref typ
...
@@ -260,9 +260,9 @@ func attackTopLeafGIndex14(_ *testing.T, gameBuilder *test.GameBuilder) (ref typ
func
defendTopLeafGIndex14
(
_
*
testing
.
T
,
gameBuilder
*
test
.
GameBuilder
)
(
ref
types
.
Claim
,
pos
types
.
Position
,
expectPre
types
.
Claim
,
expectPost
types
.
Claim
)
{
func
defendTopLeafGIndex14
(
_
*
testing
.
T
,
gameBuilder
*
test
.
GameBuilder
)
(
ref
types
.
Claim
,
pos
types
.
Position
,
expectPre
types
.
Claim
,
expectPost
types
.
Claim
)
{
seq
:=
gameBuilder
.
Seq
()
// gindex 1, trace 7
seq
:=
gameBuilder
.
Seq
()
// gindex 1, trace 7
expectPost
=
latestClaim
(
gameBuilder
)
expectPost
=
latestClaim
(
gameBuilder
)
seq
=
seq
.
Attack
Correct
()
// gindex 2, trace 3
seq
=
seq
.
Attack
()
// gindex 2, trace 3
seq
=
seq
.
Defend
Correct
()
// gindex 6, trace 5
seq
=
seq
.
Defend
()
// gindex 6, trace 5
seq
.
Defend
Correct
()
// gindex 14, trace 6
seq
.
Defend
()
// gindex 14, trace 6
expectPre
=
latestClaim
(
gameBuilder
)
expectPre
=
latestClaim
(
gameBuilder
)
ref
=
latestClaim
(
gameBuilder
)
ref
=
latestClaim
(
gameBuilder
)
...
@@ -277,7 +277,7 @@ func latestClaim(gameBuilder *test.GameBuilder) types.Claim {
...
@@ -277,7 +277,7 @@ func latestClaim(gameBuilder *test.GameBuilder) types.Claim {
func
createClaimsToDepth
(
gameBuilder
*
test
.
GameBuilder
,
depth
int
)
{
func
createClaimsToDepth
(
gameBuilder
*
test
.
GameBuilder
,
depth
int
)
{
seq
:=
gameBuilder
.
Seq
()
seq
:=
gameBuilder
.
Seq
()
for
i
:=
0
;
i
<
depth
;
i
++
{
for
i
:=
0
;
i
<
depth
;
i
++
{
seq
=
seq
.
Attack
Correct
()
seq
=
seq
.
Attack
()
}
}
}
}
...
@@ -314,7 +314,7 @@ func setupAlphabetSplitSelector(t *testing.T) (*alphabet.AlphabetTraceProvider,
...
@@ -314,7 +314,7 @@ func setupAlphabetSplitSelector(t *testing.T) (*alphabet.AlphabetTraceProvider,
selector
:=
NewSplitProviderSelector
(
top
,
splitDepth
,
bottomCreator
)
selector
:=
NewSplitProviderSelector
(
top
,
splitDepth
,
bottomCreator
)
claimBuilder
:=
test
.
NewAlphabetClaimBuilder
(
t
,
big
.
NewInt
(
0
),
gameDepth
)
claimBuilder
:=
test
.
NewAlphabetClaimBuilder
(
t
,
big
.
NewInt
(
0
),
gameDepth
)
gameBuilder
:=
claimBuilder
.
GameBuilder
(
true
)
gameBuilder
:=
claimBuilder
.
GameBuilder
()
return
top
,
selector
,
gameBuilder
return
top
,
selector
,
gameBuilder
}
}
...
...
op-dispute-mon/mon/resolution/resolver_test.go
View file @
83de09b5
...
@@ -21,7 +21,7 @@ func TestResolver_Resolve(t *testing.T) {
...
@@ -21,7 +21,7 @@ func TestResolver_Resolve(t *testing.T) {
})
})
t
.
Run
(
"SingleRootClaim"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"SingleRootClaim"
,
func
(
t
*
testing
.
T
)
{
builder
:=
test
.
NewAlphabetClaimBuilder
(
t
,
big
.
NewInt
(
10
),
4
)
.
GameBuilder
(
true
)
builder
:=
test
.
NewAlphabetClaimBuilder
(
t
,
big
.
NewInt
(
10
),
4
)
.
GameBuilder
()
tree
:=
transform
.
CreateBidirectionalTree
(
builder
.
Game
.
Claims
())
tree
:=
transform
.
CreateBidirectionalTree
(
builder
.
Game
.
Claims
())
tree
.
Claims
[
0
]
.
Claim
.
CounteredBy
=
common
.
Address
{}
tree
.
Claims
[
0
]
.
Claim
.
CounteredBy
=
common
.
Address
{}
status
:=
Resolve
(
tree
)
status
:=
Resolve
(
tree
)
...
@@ -29,45 +29,45 @@ func TestResolver_Resolve(t *testing.T) {
...
@@ -29,45 +29,45 @@ func TestResolver_Resolve(t *testing.T) {
})
})
t
.
Run
(
"ManyClaims_ChallengerWon"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"ManyClaims_ChallengerWon"
,
func
(
t
*
testing
.
T
)
{
builder
:=
test
.
NewAlphabetClaimBuilder
(
t
,
big
.
NewInt
(
10
),
5
)
.
GameBuilder
(
true
)
builder
:=
test
.
NewAlphabetClaimBuilder
(
t
,
big
.
NewInt
(
10
),
5
)
.
GameBuilder
()
builder
.
Seq
()
.
// Defender winning
builder
.
Seq
()
.
// Defender winning
Attack
Correct
()
.
// Challenger winning
Attack
()
.
// Challenger winning
Attack
Correct
()
.
// Defender winning
Attack
()
.
// Defender winning
Defend
Correct
()
.
// Challenger winning
Defend
()
.
// Challenger winning
Defend
Correct
()
.
// Defender winning
Defend
()
.
// Defender winning
Attack
Correct
()
// Challenger winning
Attack
()
// Challenger winning
tree
:=
transform
.
CreateBidirectionalTree
(
builder
.
Game
.
Claims
())
tree
:=
transform
.
CreateBidirectionalTree
(
builder
.
Game
.
Claims
())
status
:=
Resolve
(
tree
)
status
:=
Resolve
(
tree
)
require
.
Equal
(
t
,
gameTypes
.
GameStatusChallengerWon
,
status
)
require
.
Equal
(
t
,
gameTypes
.
GameStatusChallengerWon
,
status
)
})
})
t
.
Run
(
"ManyClaims_DefenderWon"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"ManyClaims_DefenderWon"
,
func
(
t
*
testing
.
T
)
{
builder
:=
test
.
NewAlphabetClaimBuilder
(
t
,
big
.
NewInt
(
10
),
5
)
.
GameBuilder
(
true
)
builder
:=
test
.
NewAlphabetClaimBuilder
(
t
,
big
.
NewInt
(
10
),
5
)
.
GameBuilder
()
builder
.
Seq
()
.
// Defender winning
builder
.
Seq
()
.
// Defender winning
Attack
Correct
()
.
// Challenger winning
Attack
()
.
// Challenger winning
Attack
Correct
()
.
// Defender winning
Attack
()
.
// Defender winning
Defend
Correct
()
.
// Challenger winning
Defend
()
.
// Challenger winning
Defend
Correct
()
// Defender winning
Defend
()
// Defender winning
tree
:=
transform
.
CreateBidirectionalTree
(
builder
.
Game
.
Claims
())
tree
:=
transform
.
CreateBidirectionalTree
(
builder
.
Game
.
Claims
())
status
:=
Resolve
(
tree
)
status
:=
Resolve
(
tree
)
require
.
Equal
(
t
,
gameTypes
.
GameStatusDefenderWon
,
status
)
require
.
Equal
(
t
,
gameTypes
.
GameStatusDefenderWon
,
status
)
})
})
t
.
Run
(
"MultipleBranches_ChallengerWon"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"MultipleBranches_ChallengerWon"
,
func
(
t
*
testing
.
T
)
{
builder
:=
test
.
NewAlphabetClaimBuilder
(
t
,
big
.
NewInt
(
10
),
5
)
.
GameBuilder
(
true
)
builder
:=
test
.
NewAlphabetClaimBuilder
(
t
,
big
.
NewInt
(
10
),
5
)
.
GameBuilder
()
forkPoint
:=
builder
.
Seq
()
.
// Defender winning
forkPoint
:=
builder
.
Seq
()
.
// Defender winning
Attack
Correct
()
.
// Challenger winning
Attack
()
.
// Challenger winning
Attack
Correct
()
// Defender winning
Attack
()
// Defender winning
forkPoint
.
forkPoint
.
Defend
Correct
()
.
// Challenger winning
Defend
()
.
// Challenger winning
Defend
Correct
()
.
// Defender winning
Defend
()
.
// Defender winning
Attack
Correct
()
// Challenger winning
Attack
()
// Challenger winning
forkPoint
.
Defend
(
common
.
Hash
{
0xbb
}
)
.
// Challenger winning
forkPoint
.
Defend
(
test
.
WithValue
(
common
.
Hash
{
0xbb
})
)
.
// Challenger winning
DefendCorrect
()
.
// Defender winning
Defend
()
.
// Defender winning
AttackCorrect
()
.
// Challenger winning
Attack
()
.
// Challenger winning
Step
()
// Defender winning
Step
()
// Defender winning
forkPoint
.
Defend
(
common
.
Hash
{
0xcc
}
)
.
// Challenger winning
forkPoint
.
Defend
(
test
.
WithValue
(
common
.
Hash
{
0xcc
})
)
.
// Challenger winning
DefendCorrect
()
// Defender winning
Defend
()
// Defender winning
tree
:=
transform
.
CreateBidirectionalTree
(
builder
.
Game
.
Claims
())
tree
:=
transform
.
CreateBidirectionalTree
(
builder
.
Game
.
Claims
())
status
:=
Resolve
(
tree
)
status
:=
Resolve
(
tree
)
// First fork has an uncountered claim with challenger winning so that invalidates the parent and wins the game
// First fork has an uncountered claim with challenger winning so that invalidates the parent and wins the game
...
@@ -75,19 +75,20 @@ func TestResolver_Resolve(t *testing.T) {
...
@@ -75,19 +75,20 @@ func TestResolver_Resolve(t *testing.T) {
})
})
t
.
Run
(
"MultipleBranches_DefenderWon"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"MultipleBranches_DefenderWon"
,
func
(
t
*
testing
.
T
)
{
builder
:=
test
.
NewAlphabetClaimBuilder
(
t
,
big
.
NewInt
(
10
),
5
)
.
GameBuilder
(
true
)
builder
:=
test
.
NewAlphabetClaimBuilder
(
t
,
big
.
NewInt
(
10
),
5
)
.
GameBuilder
()
forkPoint
:=
builder
.
Seq
()
.
// Defender winning
forkPoint
:=
builder
.
Seq
()
.
// Defender winning
Attack
Correct
()
.
// Challenger winning
Attack
()
.
// Challenger winning
Attack
Correct
()
// Defender winning
Attack
()
// Defender winning
forkPoint
.
forkPoint
.
DefendCorrect
()
.
// Challenger winning
Defend
()
.
// Challenger winning
DefendCorrect
()
// Defender winning
Defend
()
// Defender winning
forkPoint
.
Defend
(
common
.
Hash
{
0xbb
})
.
// Challenger winning
forkPoint
.
Defend
(
test
.
WithValue
(
common
.
Hash
{
0xbb
}))
.
// Challenger winning
DefendCorrect
()
.
// Defender winning
Defend
()
.
// Defender winning
AttackCorrect
()
.
// Challenger winning
Attack
()
.
// Challenger winning
Step
()
// Defender winning
Step
()
// Defender winning
forkPoint
.
Defend
(
common
.
Hash
{
0xcc
})
.
// Challenger winning
forkPoint
.
Defend
(
test
.
WithValue
(
common
.
Hash
{
0xcc
}))
.
// Challenger winning
DefendCorrect
()
// Defender winning
Defend
()
// Defender winning
tree
:=
transform
.
CreateBidirectionalTree
(
builder
.
Game
.
Claims
())
tree
:=
transform
.
CreateBidirectionalTree
(
builder
.
Game
.
Claims
())
status
:=
Resolve
(
tree
)
status
:=
Resolve
(
tree
)
// Defender won all forks
// Defender won all forks
...
@@ -95,13 +96,13 @@ func TestResolver_Resolve(t *testing.T) {
...
@@ -95,13 +96,13 @@ func TestResolver_Resolve(t *testing.T) {
})
})
t
.
Run
(
"SteppedClaimed_ChallengerWon"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"SteppedClaimed_ChallengerWon"
,
func
(
t
*
testing
.
T
)
{
builder
:=
test
.
NewAlphabetClaimBuilder
(
t
,
big
.
NewInt
(
10
),
4
)
.
GameBuilder
(
true
)
builder
:=
test
.
NewAlphabetClaimBuilder
(
t
,
big
.
NewInt
(
10
),
4
)
.
GameBuilder
()
builder
.
Seq
()
.
// Defender winning
builder
.
Seq
()
.
// Defender winning
Attack
Correct
()
.
// Challenger winning
Attack
()
.
// Challenger winning
Attack
Correct
()
.
// Defender winning
Attack
()
.
// Defender winning
Defend
Correct
()
.
// Challenger winning
Defend
()
.
// Challenger winning
Defend
Correct
()
.
// Defender winning
Defend
()
.
// Defender winning
Step
()
// Challenger winning
Step
()
// Challenger winning
claims
:=
builder
.
Game
.
Claims
()
claims
:=
builder
.
Game
.
Claims
()
// Successful step so mark as countered
// Successful step so mark as countered
claims
[
len
(
claims
)
-
1
]
.
CounteredBy
=
common
.
Address
{
0xaa
}
claims
[
len
(
claims
)
-
1
]
.
CounteredBy
=
common
.
Address
{
0xaa
}
...
@@ -111,14 +112,14 @@ func TestResolver_Resolve(t *testing.T) {
...
@@ -111,14 +112,14 @@ func TestResolver_Resolve(t *testing.T) {
})
})
t
.
Run
(
"SteppedClaimed_DefenderWon"
,
func
(
t
*
testing
.
T
)
{
t
.
Run
(
"SteppedClaimed_DefenderWon"
,
func
(
t
*
testing
.
T
)
{
builder
:=
test
.
NewAlphabetClaimBuilder
(
t
,
big
.
NewInt
(
10
),
5
)
.
GameBuilder
(
true
)
builder
:=
test
.
NewAlphabetClaimBuilder
(
t
,
big
.
NewInt
(
10
),
5
)
.
GameBuilder
()
builder
.
Seq
()
.
// Defender winning
builder
.
Seq
()
.
// Defender winning
Attack
Correct
()
.
// Challenger winning
Attack
()
.
// Challenger winning
Attack
Correct
()
.
// Defender winning
Attack
()
.
// Defender winning
Defend
Correct
()
.
// Challenger winning
Defend
()
.
// Challenger winning
Defend
Correct
()
.
// Defender winning
Defend
()
.
// Defender winning
Attack
Correct
()
.
// Challenger winning
Attack
()
.
// Challenger winning
Step
()
// Defender winning
Step
()
// Defender winning
claims
:=
builder
.
Game
.
Claims
()
claims
:=
builder
.
Game
.
Claims
()
// Successful step so mark as countered
// Successful step so mark as countered
claims
[
len
(
claims
)
-
1
]
.
CounteredBy
=
common
.
Address
{
0xaa
}
claims
[
len
(
claims
)
-
1
]
.
CounteredBy
=
common
.
Address
{
0xaa
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment