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
1be5226f
Commit
1be5226f
authored
Sep 21, 2023
by
cby3149
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support external client in tests
parent
b245c0ac
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
14 deletions
+30
-14
external.go
op-e2e/external.go
+2
-1
main_test.go
op-e2e/external_geth/main_test.go
+1
-1
op_geth.go
op-e2e/op_geth.go
+22
-4
op_geth_test.go
op-e2e/op_geth_test.go
+2
-5
setup.go
op-e2e/setup.go
+3
-3
No files found.
op-e2e/external.go
View file @
1be5226f
...
@@ -46,13 +46,14 @@ func (eec *ExternalEthClient) WSAuthEndpoint() string {
...
@@ -46,13 +46,14 @@ func (eec *ExternalEthClient) WSAuthEndpoint() string {
return
eec
.
Endpoints
.
WSAuthEndpoint
return
eec
.
Endpoints
.
WSAuthEndpoint
}
}
func
(
eec
*
ExternalEthClient
)
Close
()
{
func
(
eec
*
ExternalEthClient
)
Close
()
error
{
eec
.
Session
.
Terminate
()
eec
.
Session
.
Terminate
()
select
{
select
{
case
<-
time
.
After
(
5
*
time
.
Second
)
:
case
<-
time
.
After
(
5
*
time
.
Second
)
:
eec
.
Session
.
Kill
()
eec
.
Session
.
Kill
()
case
<-
eec
.
Session
.
Exited
:
case
<-
eec
.
Session
.
Exited
:
}
}
return
nil
}
}
func
(
er
*
ExternalRunner
)
Run
(
t
*
testing
.
T
)
*
ExternalEthClient
{
func
(
er
*
ExternalRunner
)
Run
(
t
*
testing
.
T
)
*
ExternalEthClient
{
...
...
op-e2e/external_geth/main_test.go
View file @
1be5226f
...
@@ -39,7 +39,7 @@ func TestShim(t *testing.T) {
...
@@ -39,7 +39,7 @@ func TestShim(t *testing.T) {
Name
:
"TestShim"
,
Name
:
"TestShim"
,
BinPath
:
shimPath
,
BinPath
:
shimPath
,
})
.
Run
(
t
)
})
.
Run
(
t
)
t
.
Cleanup
(
ec
.
Close
)
t
.
Cleanup
(
func
()
{
_
=
ec
.
Close
}
)
for
_
,
endpoint
:=
range
[]
string
{
for
_
,
endpoint
:=
range
[]
string
{
ec
.
HTTPEndpoint
(),
ec
.
HTTPEndpoint
(),
...
...
op-e2e/op_geth.go
View file @
1be5226f
...
@@ -38,9 +38,10 @@ var (
...
@@ -38,9 +38,10 @@ var (
// OpGeth is an actor that functions as a l2 op-geth node
// OpGeth is an actor that functions as a l2 op-geth node
// It provides useful functions for advancing and querying the chain
// It provides useful functions for advancing and querying the chain
type
OpGeth
struct
{
type
OpGeth
struct
{
node
*
gn
.
Nod
e
node
EthInstanc
e
l2Engine
*
sources
.
EngineClient
l2Engine
*
sources
.
EngineClient
L2Client
*
ethclient
.
Client
L2Client
*
ethclient
.
Client
L2RpcClient
*
rpc
.
Client
SystemConfig
eth
.
SystemConfig
SystemConfig
eth
.
SystemConfig
L1ChainConfig
*
params
.
ChainConfig
L1ChainConfig
*
params
.
ChainConfig
L2ChainConfig
*
params
.
ChainConfig
L2ChainConfig
*
params
.
ChainConfig
...
@@ -73,9 +74,21 @@ func NewOpGeth(t *testing.T, ctx context.Context, cfg *SystemConfig) (*OpGeth, e
...
@@ -73,9 +74,21 @@ func NewOpGeth(t *testing.T, ctx context.Context, cfg *SystemConfig) (*OpGeth, e
SystemConfig
:
e2eutils
.
SystemConfigFromDeployConfig
(
cfg
.
DeployConfig
),
SystemConfig
:
e2eutils
.
SystemConfigFromDeployConfig
(
cfg
.
DeployConfig
),
}
}
node
,
_
,
err
:=
geth
.
InitL2
(
"l2"
,
big
.
NewInt
(
int64
(
cfg
.
DeployConfig
.
L2ChainID
)),
l2Genesis
,
cfg
.
JWTFilePath
)
var
node
EthInstance
require
.
Nil
(
t
,
err
)
if
cfg
.
ExternalL2Shim
==
""
{
require
.
Nil
(
t
,
node
.
Start
())
gethNode
,
_
,
err
:=
geth
.
InitL2
(
"l2"
,
big
.
NewInt
(
int64
(
cfg
.
DeployConfig
.
L2ChainID
)),
l2Genesis
,
cfg
.
JWTFilePath
)
require
.
Nil
(
t
,
err
)
require
.
Nil
(
t
,
gethNode
.
Start
())
node
=
gethNode
}
else
{
externalNode
:=
(
&
ExternalRunner
{
Name
:
"Sequencer"
,
BinPath
:
cfg
.
ExternalL2Shim
,
Genesis
:
l2Genesis
,
JWTPath
:
cfg
.
JWTFilePath
,
})
.
Run
(
t
)
node
=
externalNode
}
auth
:=
rpc
.
WithHTTPAuth
(
gn
.
NewJWTAuth
(
cfg
.
JWTSecret
))
auth
:=
rpc
.
WithHTTPAuth
(
gn
.
NewJWTAuth
(
cfg
.
JWTSecret
))
l2Node
,
err
:=
client
.
NewRPC
(
ctx
,
logger
,
node
.
WSAuthEndpoint
(),
client
.
WithGethRPCOptions
(
auth
))
l2Node
,
err
:=
client
.
NewRPC
(
ctx
,
logger
,
node
.
WSAuthEndpoint
(),
client
.
WithGethRPCOptions
(
auth
))
...
@@ -93,12 +106,16 @@ func NewOpGeth(t *testing.T, ctx context.Context, cfg *SystemConfig) (*OpGeth, e
...
@@ -93,12 +106,16 @@ func NewOpGeth(t *testing.T, ctx context.Context, cfg *SystemConfig) (*OpGeth, e
l2Client
,
err
:=
ethclient
.
Dial
(
node
.
HTTPEndpoint
())
l2Client
,
err
:=
ethclient
.
Dial
(
node
.
HTTPEndpoint
())
require
.
Nil
(
t
,
err
)
require
.
Nil
(
t
,
err
)
l2RpcClient
,
err
:=
rpc
.
Dial
(
node
.
HTTPEndpoint
())
require
.
Nil
(
t
,
err
)
genesisPayload
,
err
:=
eth
.
BlockAsPayload
(
l2GenesisBlock
)
genesisPayload
,
err
:=
eth
.
BlockAsPayload
(
l2GenesisBlock
)
require
.
Nil
(
t
,
err
)
require
.
Nil
(
t
,
err
)
return
&
OpGeth
{
return
&
OpGeth
{
node
:
node
,
node
:
node
,
L2Client
:
l2Client
,
L2Client
:
l2Client
,
L2RpcClient
:
l2RpcClient
,
l2Engine
:
l2Engine
,
l2Engine
:
l2Engine
,
SystemConfig
:
rollupGenesis
.
SystemConfig
,
SystemConfig
:
rollupGenesis
.
SystemConfig
,
L1ChainConfig
:
l1Genesis
.
Config
,
L1ChainConfig
:
l1Genesis
.
Config
,
...
@@ -112,6 +129,7 @@ func (d *OpGeth) Close() {
...
@@ -112,6 +129,7 @@ func (d *OpGeth) Close() {
_
=
d
.
node
.
Close
()
_
=
d
.
node
.
Close
()
d
.
l2Engine
.
Close
()
d
.
l2Engine
.
Close
()
d
.
L2Client
.
Close
()
d
.
L2Client
.
Close
()
d
.
L2RpcClient
.
Close
()
}
}
// AddL2Block Appends a new L2 block to the current chain including the specified transactions
// AddL2Block Appends a new L2 block to the current chain including the specified transactions
...
...
op-e2e/op_geth_test.go
View file @
1be5226f
...
@@ -38,6 +38,7 @@ func TestMissingGasLimit(t *testing.T) {
...
@@ -38,6 +38,7 @@ func TestMissingGasLimit(t *testing.T) {
attrs
.
GasLimit
=
nil
attrs
.
GasLimit
=
nil
res
,
err
:=
opGeth
.
StartBlockBuilding
(
ctx
,
attrs
)
res
,
err
:=
opGeth
.
StartBlockBuilding
(
ctx
,
attrs
)
require
.
Error
(
t
,
err
)
require
.
ErrorIs
(
t
,
err
,
eth
.
InputError
{})
require
.
ErrorIs
(
t
,
err
,
eth
.
InputError
{})
require
.
Equal
(
t
,
eth
.
InvalidPayloadAttributes
,
err
.
(
eth
.
InputError
)
.
Code
)
require
.
Equal
(
t
,
eth
.
InvalidPayloadAttributes
,
err
.
(
eth
.
InputError
)
.
Code
)
require
.
Nil
(
t
,
res
)
require
.
Nil
(
t
,
res
)
...
@@ -157,16 +158,12 @@ func TestGethOnlyPendingBlockIsLatest(t *testing.T) {
...
@@ -157,16 +158,12 @@ func TestGethOnlyPendingBlockIsLatest(t *testing.T) {
require
.
NoError
(
t
,
opGeth
.
L2Client
.
SendTransaction
(
ctx
,
tx
),
"send tx to make pending work different"
)
require
.
NoError
(
t
,
opGeth
.
L2Client
.
SendTransaction
(
ctx
,
tx
),
"send tx to make pending work different"
)
checkPending
(
"prepared"
,
0
)
checkPending
(
"prepared"
,
0
)
rpcClient
,
err
:=
opGeth
.
node
.
Attach
()
require
.
NoError
(
t
,
err
)
defer
rpcClient
.
Close
()
// Wait for tx to be in tx-pool, for it to be picked up in block building
// Wait for tx to be in tx-pool, for it to be picked up in block building
var
txPoolStatus
struct
{
var
txPoolStatus
struct
{
Pending
hexutil
.
Uint64
`json:"pending"`
Pending
hexutil
.
Uint64
`json:"pending"`
}
}
for
i
:=
0
;
i
<
5
;
i
++
{
for
i
:=
0
;
i
<
5
;
i
++
{
require
.
NoError
(
t
,
r
pcClient
.
CallContext
(
ctx
,
&
txPoolStatus
,
"txpool_status"
))
require
.
NoError
(
t
,
opGeth
.
L2R
pcClient
.
CallContext
(
ctx
,
&
txPoolStatus
,
"txpool_status"
))
if
txPoolStatus
.
Pending
==
0
{
if
txPoolStatus
.
Pending
==
0
{
time
.
Sleep
(
time
.
Second
)
time
.
Sleep
(
time
.
Second
)
}
else
{
}
else
{
...
...
op-e2e/setup.go
View file @
1be5226f
...
@@ -224,8 +224,8 @@ func (gi *GethInstance) HTTPAuthEndpoint() string {
...
@@ -224,8 +224,8 @@ func (gi *GethInstance) HTTPAuthEndpoint() string {
return
gi
.
Node
.
HTTPAuthEndpoint
()
return
gi
.
Node
.
HTTPAuthEndpoint
()
}
}
func
(
gi
*
GethInstance
)
Close
()
{
func
(
gi
*
GethInstance
)
Close
()
error
{
gi
.
Node
.
Close
()
return
gi
.
Node
.
Close
()
}
}
// EthInstance is either an in process Geth or external process exposing its
// EthInstance is either an in process Geth or external process exposing its
...
@@ -235,7 +235,7 @@ type EthInstance interface {
...
@@ -235,7 +235,7 @@ type EthInstance interface {
WSEndpoint
()
string
WSEndpoint
()
string
HTTPAuthEndpoint
()
string
HTTPAuthEndpoint
()
string
WSAuthEndpoint
()
string
WSAuthEndpoint
()
string
Close
()
Close
()
error
}
}
type
System
struct
{
type
System
struct
{
...
...
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