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
c3dd839f
Unverified
Commit
c3dd839f
authored
Sep 05, 2023
by
Adrian Sutton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
op-e2e: Add test for L2 transaction gossip
parent
4df80ce8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
3 deletions
+68
-3
l2_gossip_test.go
op-e2e/l2_gossip_test.go
+65
-0
tx_helper.go
op-e2e/tx_helper.go
+3
-3
No files found.
op-e2e/l2_gossip_test.go
0 → 100644
View file @
c3dd839f
package
op_e2e
import
(
"context"
"testing"
"time"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
"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"
)
func
TestTxGossip
(
t
*
testing
.
T
)
{
InitParallel
(
t
)
cfg
:=
DefaultSystemConfig
(
t
)
gethOpts
:=
[]
GethOption
{
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
},
}
cfg
.
GethOptions
[
"sequencer"
]
=
gethOpts
cfg
.
GethOptions
[
"verifier"
]
=
gethOpts
sys
,
err
:=
cfg
.
Start
(
t
)
require
.
NoError
(
t
,
err
,
"Start system"
)
seqClient
:=
sys
.
Clients
[
"sequencer"
]
verifClient
:=
sys
.
Clients
[
"verifier"
]
var
seqInfo
p2p
.
NodeInfo
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.
SendL2Tx
(
t
,
cfg
,
verifClient
,
cfg
.
Secrets
.
Alice
,
func
(
opts
*
TxOpts
)
{
opts
.
ToAddr
=
&
common
.
Address
{
0xaa
}
opts
.
Value
=
common
.
Big1
opts
.
VerifyOnClients
(
seqClient
,
verifClient
)
})
}
op-e2e/tx_helper.go
View file @
c3dd839f
...
@@ -91,16 +91,16 @@ func SendL2Tx(t *testing.T, cfg SystemConfig, l2Client *ethclient.Client, privKe
...
@@ -91,16 +91,16 @@ func SendL2Tx(t *testing.T, cfg SystemConfig, l2Client *ethclient.Client, privKe
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
30
*
time
.
Second
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
30
*
time
.
Second
)
defer
cancel
()
defer
cancel
()
err
:=
l2Client
.
SendTransaction
(
ctx
,
tx
)
err
:=
l2Client
.
SendTransaction
(
ctx
,
tx
)
require
.
N
il
(
t
,
err
,
"Sending L2 tx"
)
require
.
N
oError
(
t
,
err
,
"Sending L2 tx"
)
receipt
,
err
:=
waitForTransaction
(
tx
.
Hash
(),
l2Client
,
10
*
time
.
Duration
(
cfg
.
DeployConfig
.
L2BlockTime
)
*
time
.
Second
)
receipt
,
err
:=
waitForTransaction
(
tx
.
Hash
(),
l2Client
,
10
*
time
.
Duration
(
cfg
.
DeployConfig
.
L2BlockTime
)
*
time
.
Second
)
require
.
N
il
(
t
,
err
,
"Waiting for L2 tx"
)
require
.
N
oError
(
t
,
err
,
"Waiting for L2 tx"
)
require
.
Equal
(
t
,
opts
.
ExpectedStatus
,
receipt
.
Status
,
"TX should have expected status"
)
require
.
Equal
(
t
,
opts
.
ExpectedStatus
,
receipt
.
Status
,
"TX should have expected status"
)
for
i
,
client
:=
range
opts
.
VerifyClients
{
for
i
,
client
:=
range
opts
.
VerifyClients
{
t
.
Logf
(
"Waiting for tx %v on verification client %d"
,
tx
.
Hash
(),
i
)
t
.
Logf
(
"Waiting for tx %v on verification client %d"
,
tx
.
Hash
(),
i
)
receiptVerif
,
err
:=
waitForTransaction
(
tx
.
Hash
(),
client
,
10
*
time
.
Duration
(
cfg
.
DeployConfig
.
L2BlockTime
)
*
time
.
Second
)
receiptVerif
,
err
:=
waitForTransaction
(
tx
.
Hash
(),
client
,
10
*
time
.
Duration
(
cfg
.
DeployConfig
.
L2BlockTime
)
*
time
.
Second
)
require
.
N
il
f
(
t
,
err
,
"Waiting for L2 tx on verification client %d"
,
i
)
require
.
N
oError
f
(
t
,
err
,
"Waiting for L2 tx on verification client %d"
,
i
)
require
.
Equalf
(
t
,
receipt
,
receiptVerif
,
"Receipts should be the same on sequencer and verification client %d"
,
i
)
require
.
Equalf
(
t
,
receipt
,
receiptVerif
,
"Receipts should be the same on sequencer and verification client %d"
,
i
)
}
}
return
receipt
return
receipt
...
...
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