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
16bf8454
Unverified
Commit
16bf8454
authored
Mar 22, 2024
by
Adrian Sutton
Committed by
GitHub
Mar 22, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-challenger: Check for simulation failed error in correct place (#9947)
parent
b57a2634
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
7 deletions
+24
-7
claimer.go
op-challenger/game/fault/claims/claimer.go
+5
-5
claimer_test.go
op-challenger/game/fault/claims/claimer_test.go
+19
-2
No files found.
op-challenger/game/fault/claims/claimer.go
View file @
16bf8454
...
...
@@ -79,14 +79,14 @@ func (c *Claimer) claimBond(ctx context.Context, game types.GameMetadata, addr c
}
candidate
,
err
:=
contract
.
ClaimCreditTx
(
ctx
,
addr
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to create credit claim tx: %w"
,
err
)
}
if
err
=
c
.
txSender
.
SendAndWaitSimple
(
"claim credit"
,
candidate
);
errors
.
Is
(
err
,
contracts
.
ErrSimulationFailed
)
{
if
errors
.
Is
(
err
,
contracts
.
ErrSimulationFailed
)
{
c
.
logger
.
Debug
(
"Credit still locked"
,
"game"
,
game
.
Proxy
,
"addr"
,
addr
)
return
nil
}
else
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to create credit claim tx: %w"
,
err
)
}
if
err
=
c
.
txSender
.
SendAndWaitSimple
(
"claim credit"
,
candidate
);
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to claim credit: %w"
,
err
)
}
...
...
op-challenger/game/fault/claims/claimer_test.go
View file @
16bf8454
...
...
@@ -3,9 +3,11 @@ package claims
import
(
"context"
"errors"
"fmt"
"math/big"
"testing"
"github.com/ethereum-optimism/optimism/op-challenger/game/fault/contracts"
"github.com/ethereum-optimism/optimism/op-challenger/game/types"
"github.com/ethereum-optimism/optimism/op-service/testlog"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
...
...
@@ -76,6 +78,17 @@ func TestClaimer_ClaimBonds(t *testing.T) {
require
.
Equal
(
t
,
0
,
m
.
RecordBondClaimedCalls
)
})
t
.
Run
(
"BondStillLocked"
,
func
(
t
*
testing
.
T
)
{
gameAddr
:=
common
.
HexToAddress
(
"0x1234"
)
c
,
m
,
contract
,
txSender
:=
newTestClaimer
(
t
)
contract
.
claimSimulationFails
=
true
contract
.
credit
[
txSender
.
From
()]
=
1
err
:=
c
.
ClaimBonds
(
context
.
Background
(),
[]
types
.
GameMetadata
{{
Proxy
:
gameAddr
}})
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
0
,
txSender
.
sends
)
require
.
Equal
(
t
,
0
,
m
.
RecordBondClaimedCalls
)
})
t
.
Run
(
"ZeroCreditReturnsNil"
,
func
(
t
*
testing
.
T
)
{
gameAddr
:=
common
.
HexToAddress
(
"0x1234"
)
c
,
m
,
contract
,
txSender
:=
newTestClaimer
(
t
)
...
...
@@ -143,8 +156,9 @@ func (s *mockTxSender) SendAndWaitSimple(_ string, _ ...txmgr.TxCandidate) error
}
type
stubBondContract
struct
{
credit
map
[
common
.
Address
]
int64
status
types
.
GameStatus
credit
map
[
common
.
Address
]
int64
status
types
.
GameStatus
claimSimulationFails
bool
}
func
(
s
*
stubBondContract
)
GetCredit
(
_
context
.
Context
,
addr
common
.
Address
)
(
*
big
.
Int
,
types
.
GameStatus
,
error
)
{
...
...
@@ -152,5 +166,8 @@ func (s *stubBondContract) GetCredit(_ context.Context, addr common.Address) (*b
}
func
(
s
*
stubBondContract
)
ClaimCreditTx
(
_
context
.
Context
,
_
common
.
Address
)
(
txmgr
.
TxCandidate
,
error
)
{
if
s
.
claimSimulationFails
{
return
txmgr
.
TxCandidate
{},
fmt
.
Errorf
(
"failed: %w"
,
contracts
.
ErrSimulationFailed
)
}
return
txmgr
.
TxCandidate
{},
nil
}
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