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
96ac4c23
Unverified
Commit
96ac4c23
authored
Sep 05, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-e2e: Extract out helper methods for connecting peers.
parent
c3dd839f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
36 deletions
+52
-36
peers.go
op-e2e/e2eutils/geth/peers.go
+49
-0
l2_gossip_test.go
op-e2e/l2_gossip_test.go
+3
-36
No files found.
op-e2e/e2eutils/geth/peers.go
0 → 100644
View file @
96ac4c23
package
geth
import
(
"context"
"testing"
"time"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p"
"github.com/stretchr/testify/require"
)
// ConnectP2P creates a p2p peer connection between node1 and node2.
func
ConnectP2P
(
t
*
testing
.
T
,
node1
*
ethclient
.
Client
,
node2
*
ethclient
.
Client
)
{
var
targetInfo
p2p
.
NodeInfo
require
.
NoError
(
t
,
node2
.
Client
()
.
Call
(
&
targetInfo
,
"admin_nodeInfo"
),
"get node info"
)
var
peerAdded
bool
require
.
NoError
(
t
,
node1
.
Client
()
.
Call
(
&
peerAdded
,
"admin_addPeer"
,
targetInfo
.
Enode
),
"add peer"
)
require
.
True
(
t
,
peerAdded
,
"should have added peer successfully"
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
30
*
time
.
Second
)
defer
cancel
()
err
:=
wait
.
For
(
ctx
,
time
.
Second
,
func
()
(
bool
,
error
)
{
var
peerCount
hexutil
.
Uint64
if
err
:=
node1
.
Client
()
.
Call
(
&
peerCount
,
"net_peerCount"
);
err
!=
nil
{
return
false
,
err
}
t
.
Logf
(
"Peer count %v"
,
uint64
(
peerCount
))
return
peerCount
>=
hexutil
.
Uint64
(
1
),
nil
})
require
.
NoError
(
t
,
err
,
"wait for a peer to be connected"
)
}
func
WithP2P
()
func
(
ethCfg
*
ethconfig
.
Config
,
nodeCfg
*
node
.
Config
)
error
{
return
func
(
ethCfg
*
ethconfig
.
Config
,
nodeCfg
*
node
.
Config
)
error
{
ethCfg
.
RollupDisableTxPoolGossip
=
false
nodeCfg
.
P2P
=
p2p
.
Config
{
NoDiscovery
:
true
,
ListenAddr
:
"127.0.0.1:0"
,
MaxPeers
:
10
,
}
return
nil
}
}
op-e2e/l2_gossip_test.go
View file @
96ac4c23
package
op_e2e
package
op_e2e
import
(
import
(
"context"
"testing"
"testing"
"time"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/
wait
"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/
geth
"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/eth/ethconfig"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/require"
)
)
...
@@ -18,15 +12,7 @@ func TestTxGossip(t *testing.T) {
...
@@ -18,15 +12,7 @@ func TestTxGossip(t *testing.T) {
InitParallel
(
t
)
InitParallel
(
t
)
cfg
:=
DefaultSystemConfig
(
t
)
cfg
:=
DefaultSystemConfig
(
t
)
gethOpts
:=
[]
GethOption
{
gethOpts
:=
[]
GethOption
{
func
(
ethCfg
*
ethconfig
.
Config
,
nodeCfg
*
node
.
Config
)
error
{
geth
.
WithP2P
(),
ethCfg
.
RollupDisableTxPoolGossip
=
false
nodeCfg
.
P2P
=
p2p
.
Config
{
NoDiscovery
:
true
,
ListenAddr
:
"127.0.0.1:0"
,
MaxPeers
:
10
,
}
return
nil
},
}
}
cfg
.
GethOptions
[
"sequencer"
]
=
gethOpts
cfg
.
GethOptions
[
"sequencer"
]
=
gethOpts
cfg
.
GethOptions
[
"verifier"
]
=
gethOpts
cfg
.
GethOptions
[
"verifier"
]
=
gethOpts
...
@@ -35,26 +21,7 @@ func TestTxGossip(t *testing.T) {
...
@@ -35,26 +21,7 @@ func TestTxGossip(t *testing.T) {
seqClient
:=
sys
.
Clients
[
"sequencer"
]
seqClient
:=
sys
.
Clients
[
"sequencer"
]
verifClient
:=
sys
.
Clients
[
"verifier"
]
verifClient
:=
sys
.
Clients
[
"verifier"
]
var
seqInfo
p2p
.
NodeInfo
geth
.
ConnectP2P
(
t
,
seqClient
,
verifClient
)
require
.
NoError
(
t
,
seqClient
.
Client
()
.
Call
(
&
seqInfo
,
"admin_nodeInfo"
),
"get sequencer node info"
)
var
verifInfo
p2p
.
NodeInfo
require
.
NoError
(
t
,
verifClient
.
Client
()
.
Call
(
&
verifInfo
,
"admin_nodeInfo"
),
"get verifier node info"
)
var
peerAdded
bool
require
.
NoError
(
t
,
verifClient
.
Client
()
.
Call
(
&
peerAdded
,
"admin_addPeer"
,
seqInfo
.
Enode
),
"add peer to verifier"
)
require
.
True
(
t
,
peerAdded
,
"should have added peer to verifier successfully"
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
30
*
time
.
Second
)
defer
cancel
()
err
=
wait
.
For
(
ctx
,
time
.
Second
,
func
()
(
bool
,
error
)
{
var
peerCount
hexutil
.
Uint64
if
err
:=
verifClient
.
Client
()
.
Call
(
&
peerCount
,
"net_peerCount"
);
err
!=
nil
{
return
false
,
err
}
t
.
Logf
(
"Peer count %v"
,
uint64
(
peerCount
))
return
peerCount
>=
hexutil
.
Uint64
(
1
),
nil
})
require
.
NoError
(
t
,
err
,
"wait for a peer to be connected"
)
// Send a transaction to the verifier and it should be gossiped to the sequencer and included in a block.
// Send a transaction to the verifier and it should be gossiped to the sequencer and included in a block.
SendL2Tx
(
t
,
cfg
,
verifClient
,
cfg
.
Secrets
.
Alice
,
func
(
opts
*
TxOpts
)
{
SendL2Tx
(
t
,
cfg
,
verifClient
,
cfg
.
Secrets
.
Alice
,
func
(
opts
*
TxOpts
)
{
...
...
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