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
18288915
Unverified
Commit
18288915
authored
Sep 28, 2023
by
refcell.eth
Committed by
Adrian Sutton
Sep 29, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix sequencer start stock test waits (#7447)
parent
3293d79c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
47 deletions
+79
-47
blocks.go
op-e2e/e2eutils/wait/blocks.go
+66
-0
waits.go
op-e2e/e2eutils/wait/waits.go
+0
-37
system_adminrpc_test.go
op-e2e/system_adminrpc_test.go
+13
-10
No files found.
op-e2e/e2eutils/wait/blocks.go
0 → 100644
View file @
18288915
package
wait
import
(
"context"
"fmt"
"math/big"
"time"
"github.com/ethereum/go-ethereum/core/types"
)
// BlockCaller is a subset of the [ethclient.Client] interface
// encompassing methods that query for block information.
type
BlockCaller
interface
{
BlockByNumber
(
ctx
context
.
Context
,
number
*
big
.
Int
)
(
*
types
.
Block
,
error
)
BlockNumber
(
ctx
context
.
Context
)
(
uint64
,
error
)
}
func
ForBlock
(
ctx
context
.
Context
,
client
BlockCaller
,
n
uint64
)
error
{
for
{
if
ctx
.
Done
()
!=
nil
{
return
ctx
.
Err
()
}
height
,
err
:=
client
.
BlockNumber
(
ctx
)
if
err
!=
nil
{
return
err
}
if
height
<
n
{
time
.
Sleep
(
500
*
time
.
Millisecond
)
continue
}
break
}
return
nil
}
func
ForBlockWithTimestamp
(
ctx
context
.
Context
,
client
BlockCaller
,
target
uint64
)
error
{
_
,
err
:=
AndGet
(
ctx
,
time
.
Second
,
func
()
(
uint64
,
error
)
{
head
,
err
:=
client
.
BlockByNumber
(
ctx
,
nil
)
if
err
!=
nil
{
return
0
,
err
}
return
head
.
Time
(),
nil
},
func
(
actual
uint64
)
bool
{
return
actual
>=
target
})
return
err
}
func
ForNextBlock
(
ctx
context
.
Context
,
client
BlockCaller
)
error
{
current
,
err
:=
client
.
BlockNumber
(
ctx
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"get starting block number: %w"
,
err
)
}
return
ForBlock
(
ctx
,
client
,
current
+
1
)
}
func
ForNextBlockWithTimeout
(
ctx
context
.
Context
,
client
BlockCaller
,
timeout
time
.
Duration
)
error
{
timeoutCtx
,
cancel
:=
context
.
WithTimeout
(
ctx
,
timeout
)
defer
cancel
()
current
,
err
:=
client
.
BlockNumber
(
ctx
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"get starting block number: %w"
,
err
)
}
return
ForBlock
(
timeoutCtx
,
client
,
current
+
1
)
}
op-e2e/e2eutils/wait/waits.go
View file @
18288915
...
...
@@ -69,43 +69,6 @@ func printDebugTrace(ctx context.Context, client *ethclient.Client, txHash commo
fmt
.
Printf
(
"TxTrace: %v
\n
"
,
trace
)
}
func
ForBlock
(
ctx
context
.
Context
,
client
*
ethclient
.
Client
,
n
uint64
)
error
{
for
{
height
,
err
:=
client
.
BlockNumber
(
ctx
)
if
err
!=
nil
{
return
err
}
if
height
<
n
{
time
.
Sleep
(
500
*
time
.
Millisecond
)
continue
}
break
}
return
nil
}
func
ForBlockWithTimestamp
(
ctx
context
.
Context
,
client
*
ethclient
.
Client
,
target
uint64
)
error
{
_
,
err
:=
AndGet
(
ctx
,
time
.
Second
,
func
()
(
uint64
,
error
)
{
head
,
err
:=
client
.
BlockByNumber
(
ctx
,
nil
)
if
err
!=
nil
{
return
0
,
err
}
return
head
.
Time
(),
nil
},
func
(
actual
uint64
)
bool
{
return
actual
>=
target
})
return
err
}
func
ForNextBlock
(
ctx
context
.
Context
,
client
*
ethclient
.
Client
)
error
{
current
,
err
:=
client
.
BlockNumber
(
ctx
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"get starting block number: %w"
,
err
)
}
return
ForBlock
(
ctx
,
client
,
current
+
1
)
}
func
For
(
ctx
context
.
Context
,
rate
time
.
Duration
,
cb
func
()
(
bool
,
error
))
error
{
tick
:=
time
.
NewTicker
(
rate
)
defer
tick
.
Stop
()
...
...
op-e2e/system_adminrpc_test.go
View file @
18288915
...
...
@@ -5,6 +5,7 @@ import (
"testing"
"time"
"github.com/ethereum-optimism/optimism/op-e2e/e2eutils/wait"
"github.com/ethereum-optimism/optimism/op-node/client"
"github.com/ethereum-optimism/optimism/op-node/node"
"github.com/ethereum-optimism/optimism/op-node/sources"
...
...
@@ -34,10 +35,11 @@ func TestStopStartSequencer(t *testing.T) {
require
.
NoError
(
t
,
err
)
require
.
True
(
t
,
active
,
"sequencer should be active"
)
blockBefore
:=
latestBlock
(
t
,
l2Seq
)
time
.
Sleep
(
time
.
Duration
(
cfg
.
DeployConfig
.
L2BlockTime
+
1
)
*
time
.
Second
)
blockAfter
:=
latestBlock
(
t
,
l2Seq
)
require
.
Greaterf
(
t
,
blockAfter
,
blockBefore
,
"Chain did not advance"
)
require
.
NoError
(
t
,
wait
.
ForNextBlockWithTimeout
(
ctx
,
l2Seq
,
time
.
Duration
(
cfg
.
DeployConfig
.
L2BlockTime
+
1
)
*
2
*
time
.
Second
),
"Chain did not advance after starting sequencer"
,
)
ctx
,
cancel
=
context
.
WithTimeout
(
context
.
Background
(),
5
*
time
.
Second
)
defer
cancel
()
...
...
@@ -50,9 +52,9 @@ func TestStopStartSequencer(t *testing.T) {
require
.
NoError
(
t
,
err
)
require
.
False
(
t
,
active
,
"sequencer should be inactive"
)
blockBefore
=
latestBlock
(
t
,
l2Seq
)
blockBefore
:
=
latestBlock
(
t
,
l2Seq
)
time
.
Sleep
(
time
.
Duration
(
cfg
.
DeployConfig
.
L2BlockTime
+
1
)
*
time
.
Second
)
blockAfter
=
latestBlock
(
t
,
l2Seq
)
blockAfter
:
=
latestBlock
(
t
,
l2Seq
)
require
.
Equal
(
t
,
blockAfter
,
blockBefore
,
"Chain advanced after stopping sequencer"
)
ctx
,
cancel
=
context
.
WithTimeout
(
context
.
Background
(),
5
*
time
.
Second
)
...
...
@@ -66,10 +68,11 @@ func TestStopStartSequencer(t *testing.T) {
require
.
NoError
(
t
,
err
)
require
.
True
(
t
,
active
,
"sequencer should be active again"
)
blockBefore
=
latestBlock
(
t
,
l2Seq
)
time
.
Sleep
(
time
.
Duration
(
cfg
.
DeployConfig
.
L2BlockTime
+
1
)
*
time
.
Second
)
blockAfter
=
latestBlock
(
t
,
l2Seq
)
require
.
Greater
(
t
,
blockAfter
,
blockBefore
,
"Chain did not advance after starting sequencer"
)
require
.
NoError
(
t
,
wait
.
ForNextBlockWithTimeout
(
ctx
,
l2Seq
,
time
.
Duration
(
cfg
.
DeployConfig
.
L2BlockTime
+
1
)
*
2
*
time
.
Second
),
"Chain did not advance after starting sequencer"
,
)
}
func
TestPersistSequencerStateWhenChanged
(
t
*
testing
.
T
)
{
...
...
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