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
a1a0df72
Unverified
Commit
a1a0df72
authored
Sep 08, 2023
by
Adrian Sutton
Committed by
GitHub
Sep 07, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-e2e: Add call to step that verifies it is reject when matching the original claim. (#7133)
parent
ac5f8063
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
2 deletions
+32
-2
game_helper.go
op-e2e/e2eutils/disputegame/game_helper.go
+13
-0
honest_helper.go
op-e2e/e2eutils/disputegame/honest_helper.go
+15
-0
faultproof_test.go
op-e2e/faultproof_test.go
+4
-2
No files found.
op-e2e/e2eutils/disputegame/game_helper.go
View file @
a1a0df72
...
...
@@ -156,6 +156,19 @@ func (g *FaultGameHelper) Defend(ctx context.Context, claimIdx int64, claim comm
g
.
require
.
NoError
(
err
,
"Defend transaction was not OK"
)
}
type
ErrWithData
interface
{
ErrorData
()
interface
{}
}
// StepFails attempts to call step and verifies that it fails with ValidStep()
func
(
g
*
FaultGameHelper
)
StepFails
(
claimIdx
int64
,
isAttack
bool
,
stateData
[]
byte
,
proof
[]
byte
)
{
g
.
t
.
Logf
(
"Attempting step against claim %v isAttack: %v"
,
claimIdx
,
isAttack
)
_
,
err
:=
g
.
game
.
Step
(
g
.
opts
,
big
.
NewInt
(
claimIdx
),
isAttack
,
stateData
,
proof
)
errData
,
ok
:=
err
.
(
ErrWithData
)
g
.
require
.
Truef
(
ok
,
"Error should provide ErrorData method: %v"
,
err
)
g
.
require
.
Equal
(
"0xfb4e40dd"
,
errData
.
ErrorData
(),
"Revert reason should be abi encoded ValidStep()"
)
}
func
(
g
*
FaultGameHelper
)
gameData
(
ctx
context
.
Context
)
string
{
opts
:=
&
bind
.
CallOpts
{
Context
:
ctx
}
maxDepth
:=
int
(
g
.
MaxDepth
(
ctx
))
...
...
op-e2e/e2eutils/disputegame/honest_helper.go
View file @
a1a0df72
...
...
@@ -42,3 +42,18 @@ func (h *HonestHelper) Defend(ctx context.Context, claimIdx int64) {
h
.
game
.
require
.
NoErrorf
(
err
,
"Get correct claim at trace index %v"
,
traceIdx
)
h
.
game
.
Defend
(
ctx
,
claimIdx
,
value
)
}
func
(
h
*
HonestHelper
)
StepFails
(
ctx
context
.
Context
,
claimIdx
int64
,
isAttack
bool
)
{
ctx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
2
*
time
.
Minute
)
defer
cancel
()
claim
:=
h
.
game
.
getClaim
(
ctx
,
claimIdx
)
pos
:=
types
.
NewPositionFromGIndex
(
claim
.
Position
.
Uint64
())
traceIdx
:=
pos
.
TraceIndex
(
int
(
h
.
game
.
MaxDepth
(
ctx
)))
if
!
isAttack
{
// If we're defending, then the step will be from the trace to the next one
traceIdx
+=
1
}
prestate
,
proofData
,
_
,
err
:=
h
.
correctTrace
.
GetStepData
(
ctx
,
traceIdx
)
h
.
require
.
NoError
(
err
,
"Get step data"
)
h
.
game
.
StepFails
(
claimIdx
,
isAttack
,
prestate
,
proofData
)
}
op-e2e/faultproof_test.go
View file @
a1a0df72
...
...
@@ -360,7 +360,7 @@ func TestCannonProposedOutputRootInvalid(t *testing.T) {
InitParallel
(
t
)
ctx
:=
context
.
Background
()
sys
,
l1Client
,
game
,
correctTrace
:=
setupDisputeGameForInvalidOutputRoot
(
t
,
common
.
Hash
{
0xab
})
sys
,
l1Client
,
game
,
correctTrace
:=
setupDisputeGameForInvalidOutputRoot
(
t
,
common
.
Hash
{
0x
01
,
0x
ab
})
t
.
Cleanup
(
sys
.
Close
)
maxDepth
:=
game
.
MaxDepth
(
ctx
)
...
...
@@ -385,7 +385,9 @@ func TestCannonProposedOutputRootInvalid(t *testing.T) {
game
.
WaitForClaimAtMaxDepth
(
ctx
,
false
)
// It's on us to call step if we want to win but shouldn't be possible
// Need to add support for this to the helper
correctTrace
.
StepFails
(
ctx
,
maxDepth
,
true
)
// Defending should fail too
correctTrace
.
StepFails
(
ctx
,
maxDepth
,
false
)
// Time travel past when the game will be resolvable.
sys
.
TimeTravelClock
.
AdvanceTime
(
game
.
GameDuration
(
ctx
))
...
...
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