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
4731750d
Commit
4731750d
authored
Apr 13, 2023
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-chain-ops: update tests
parent
a737ef99
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
4 deletions
+21
-4
witness_test.go
op-chain-ops/crossdomain/witness_test.go
+21
-4
No files found.
op-chain-ops/crossdomain/witness_test.go
View file @
4731750d
...
@@ -175,7 +175,7 @@ func TestMessagePasserSafety(t *testing.T) {
...
@@ -175,7 +175,7 @@ func TestMessagePasserSafety(t *testing.T) {
selector
:=
crypto
.
Keccak256
([]
byte
(
"passMessageToL1(bytes)"
))[
0
:
4
]
selector
:=
crypto
.
Keccak256
([]
byte
(
"passMessageToL1(bytes)"
))[
0
:
4
]
require
.
Equal
(
t
,
selector
,
hexutil
.
MustDecode
(
"0xcafa81dc"
))
require
.
Equal
(
t
,
selector
,
hexutil
.
MustDecode
(
"0xcafa81dc"
))
calldata
:=
append
(
selector
,
msg
...
)
calldata
:=
append
(
selector
,
msg
...
)
t
ransaction
,
err
:=
opts
.
Signer
(
testAddr
,
types
.
NewTx
(
&
types
.
DynamicFeeTx
{
faultyT
ransaction
,
err
:=
opts
.
Signer
(
testAddr
,
types
.
NewTx
(
&
types
.
DynamicFeeTx
{
ChainID
:
big
.
NewInt
(
1337
),
ChainID
:
big
.
NewInt
(
1337
),
Nonce
:
nonce
,
Nonce
:
nonce
,
GasTipCap
:
msgTx
.
GasTipCap
(),
GasTipCap
:
msgTx
.
GasTipCap
(),
...
@@ -185,12 +185,29 @@ func TestMessagePasserSafety(t *testing.T) {
...
@@ -185,12 +185,29 @@ func TestMessagePasserSafety(t *testing.T) {
Data
:
calldata
,
Data
:
calldata
,
}))
}))
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
err
=
backend
.
SendTransaction
(
context
.
Background
(),
faultyTransaction
)
err
=
backend
.
SendTransaction
(
context
.
Background
(),
transaction
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
// the transaction should revert
backend
.
Commit
()
backend
.
Commit
()
badReceipt
,
err
:=
bind
.
WaitMined
(
context
.
Background
(),
backend
,
t
ransaction
)
badReceipt
,
err
:=
bind
.
WaitMined
(
context
.
Background
(),
backend
,
faultyT
ransaction
)
require
.
NoError
(
t
,
err
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
badReceipt
.
Status
,
types
.
ReceiptStatusFailed
)
require
.
Equal
(
t
,
badReceipt
.
Status
,
types
.
ReceiptStatusFailed
)
// test the transaction calldata against the abi unpacking
abi
,
err
:=
bindings
.
LegacyMessagePasserMetaData
.
GetAbi
()
require
.
NoError
(
t
,
err
)
method
,
err
:=
abi
.
MethodById
(
selector
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
method
.
Name
,
"passMessageToL1"
)
// the faulty transaction has the correct 4 byte selector but doesn't
// have abi encoded bytes following it
require
.
Equal
(
t
,
faultyTransaction
.
Data
()[
:
4
],
selector
)
_
,
err
=
method
.
Inputs
.
Unpack
(
faultyTransaction
.
Data
()[
4
:
])
require
.
Error
(
t
,
err
)
// the original transaction has the correct 4 byte selector and abi encoded bytes
_
,
err
=
method
.
Inputs
.
Unpack
(
msgTx
.
Data
()[
4
:
])
require
.
NoError
(
t
,
err
)
}
}
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