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
c2a8bc3c
Unverified
Commit
c2a8bc3c
authored
Feb 24, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-e2e: Add e2e tests for bedrock behaviour that will change in regolith
parent
e36ddb03
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
106 additions
and
0 deletions
+106
-0
op_geth_test.go
op-e2e/op_geth_test.go
+106
-0
No files found.
op-e2e/op_geth_test.go
View file @
c2a8bc3c
...
@@ -9,6 +9,7 @@ import (
...
@@ -9,6 +9,7 @@ import (
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum-optimism/optimism/op-node/eth"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/params"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
)
)
...
@@ -70,3 +71,108 @@ func TestInvalidDepositInFCU(t *testing.T) {
...
@@ -70,3 +71,108 @@ func TestInvalidDepositInFCU(t *testing.T) {
require
.
Nil
(
t
,
err
)
require
.
Nil
(
t
,
err
)
require
.
Equal
(
t
,
0
,
balance
.
Cmp
(
common
.
Big0
))
require
.
Equal
(
t
,
0
,
balance
.
Cmp
(
common
.
Big0
))
}
}
func
TestBedrockSystemTxUsesZeroGas
(
t
*
testing
.
T
)
{
cfg
:=
DefaultSystemConfig
(
t
)
cfg
.
DeployConfig
.
FundDevAccounts
=
false
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
60
*
time
.
Second
)
defer
cancel
()
opGeth
,
err
:=
NewOpGeth
(
t
,
ctx
,
&
cfg
)
require
.
NoError
(
t
,
err
)
defer
opGeth
.
Close
()
block
,
err
:=
opGeth
.
AddL2Block
(
ctx
)
require
.
NoError
(
t
,
err
)
infoTx
,
err
:=
opGeth
.
L2Client
.
TransactionInBlock
(
ctx
,
block
.
BlockHash
,
0
)
require
.
NoError
(
t
,
err
)
require
.
True
(
t
,
infoTx
.
IsSystemTx
())
receipt
,
err
:=
opGeth
.
L2Client
.
TransactionReceipt
(
ctx
,
infoTx
.
Hash
())
require
.
NoError
(
t
,
err
)
require
.
Zero
(
t
,
receipt
.
GasUsed
)
}
func
TestBedrockDepositTx
(
t
*
testing
.
T
)
{
cfg
:=
DefaultSystemConfig
(
t
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
60
*
time
.
Second
)
defer
cancel
()
opGeth
,
err
:=
NewOpGeth
(
t
,
ctx
,
&
cfg
)
require
.
NoError
(
t
,
err
)
defer
opGeth
.
Close
()
aliceAddr
:=
cfg
.
Secrets
.
Addresses
()
.
Alice
// Deposit TX with a higher gas limit than required
depositTx
:=
types
.
NewTx
(
&
types
.
DepositTx
{
SourceHash
:
opGeth
.
L1Head
.
Hash
(),
From
:
aliceAddr
,
To
:
&
aliceAddr
,
Value
:
big
.
NewInt
(
0
),
Gas
:
50
_000
,
// Simple transfer only requires 21,000
IsSystemTransaction
:
false
,
})
// Contract creation deposit tx
contractCreateTx
:=
types
.
NewTx
(
&
types
.
DepositTx
{
SourceHash
:
opGeth
.
L1Head
.
Hash
(),
From
:
aliceAddr
,
Value
:
big
.
NewInt
(
params
.
Ether
),
Gas
:
1000001
,
Data
:
[]
byte
{},
IsSystemTransaction
:
false
,
})
_
,
err
=
opGeth
.
AddL2Block
(
ctx
,
depositTx
,
contractCreateTx
)
require
.
NoError
(
t
,
err
)
receipt
,
err
:=
opGeth
.
L2Client
.
TransactionReceipt
(
ctx
,
depositTx
.
Hash
())
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
types
.
ReceiptStatusSuccessful
,
receipt
.
Status
,
"tx should succeed"
)
require
.
Equal
(
t
,
depositTx
.
Gas
(),
receipt
.
GasUsed
,
"should use all gas"
)
incorrectContractAddress
:=
crypto
.
CreateAddress
(
aliceAddr
,
uint64
(
0
))
// Expected to be wrong
correctContractAddress
:=
crypto
.
CreateAddress
(
aliceAddr
,
uint64
(
1
))
createRcpt
,
err
:=
opGeth
.
L2Client
.
TransactionReceipt
(
ctx
,
contractCreateTx
.
Hash
())
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
types
.
ReceiptStatusSuccessful
,
createRcpt
.
Status
,
"create should succeed"
)
require
.
Equal
(
t
,
incorrectContractAddress
,
createRcpt
.
ContractAddress
,
"should report incorrect contract address"
)
contractBalance
,
err
:=
opGeth
.
L2Client
.
BalanceAt
(
ctx
,
createRcpt
.
ContractAddress
,
nil
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
uint64
(
0
),
contractBalance
.
Uint64
(),
"balance unchanged on incorrect contract address"
)
contractBalance
,
err
=
opGeth
.
L2Client
.
BalanceAt
(
ctx
,
correctContractAddress
,
nil
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
uint64
(
params
.
Ether
),
contractBalance
.
Uint64
(),
"balance changed on correct contract address"
)
}
func
TestBedrockShouldNotRefundDepositTxUnusedGas
(
t
*
testing
.
T
)
{
cfg
:=
DefaultSystemConfig
(
t
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
60
*
time
.
Second
)
defer
cancel
()
opGeth
,
err
:=
NewOpGeth
(
t
,
ctx
,
&
cfg
)
require
.
NoError
(
t
,
err
)
defer
opGeth
.
Close
()
aliceAddr
:=
cfg
.
Secrets
.
Addresses
()
.
Alice
origBalance
,
err
:=
opGeth
.
L2Client
.
BalanceAt
(
ctx
,
aliceAddr
,
nil
)
require
.
NoError
(
t
,
err
)
// Deposit TX with a higher gas limit than required
depositTx
:=
types
.
NewTx
(
&
types
.
DepositTx
{
SourceHash
:
opGeth
.
L1Head
.
Hash
(),
From
:
aliceAddr
,
To
:
&
aliceAddr
,
Value
:
big
.
NewInt
(
0
),
Gas
:
50
_000
,
// Simple transfer only requires 21,000
IsSystemTransaction
:
false
,
})
_
,
err
=
opGeth
.
AddL2Block
(
ctx
,
depositTx
)
require
.
NoError
(
t
,
err
)
receipt
,
err
:=
opGeth
.
L2Client
.
TransactionReceipt
(
ctx
,
depositTx
.
Hash
())
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
types
.
ReceiptStatusSuccessful
,
receipt
.
Status
,
"tx should succeed"
)
newBalance
,
err
:=
opGeth
.
L2Client
.
BalanceAt
(
ctx
,
aliceAddr
,
nil
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
origBalance
,
newBalance
,
"should not refund cost of unused gas"
)
}
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