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
8df680a3
Unverified
Commit
8df680a3
authored
Dec 06, 2023
by
Adrian Sutton
Committed by
GitHub
Dec 06, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #8463 from ethereum-optimism/jg/batcher_config_test
op-batcher: Move config test from op-e2e to unit tests
parents
6ae7e38b
5e254502
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
121 additions
and
12 deletions
+121
-12
config.go
op-batcher/batcher/config.go
+20
-1
config_test.go
op-batcher/batcher/config_test.go
+93
-0
system_test.go
op-e2e/system_test.go
+0
-11
cli.go
op-service/rpc/cli.go
+8
-0
No files found.
op-batcher/batcher/config.go
View file @
8df680a3
package
batcher
import
(
"errors"
"fmt"
"time"
"github.com/urfave/cli/v2"
...
...
@@ -63,7 +65,24 @@ type CLIConfig struct {
}
func
(
c
*
CLIConfig
)
Check
()
error
{
// TODO(7512): check the sanity of flags loaded directly https://github.com/ethereum-optimism/optimism/issues/7512
if
c
.
L1EthRpc
==
""
{
return
errors
.
New
(
"empty L1 RPC URL"
)
}
if
c
.
L2EthRpc
==
""
{
return
errors
.
New
(
"empty L2 RPC URL"
)
}
if
c
.
RollupRpc
==
""
{
return
errors
.
New
(
"empty rollup RPC URL"
)
}
if
c
.
PollInterval
==
0
{
return
errors
.
New
(
"must set PollInterval"
)
}
if
c
.
MaxL1TxSize
<=
1
{
return
errors
.
New
(
"MaxL1TxSize must be greater than 0"
)
}
if
c
.
BatchType
>
1
{
return
fmt
.
Errorf
(
"unknown batch type: %v"
,
c
.
BatchType
)
}
if
err
:=
c
.
MetricsConfig
.
Check
();
err
!=
nil
{
return
err
...
...
op-batcher/batcher/config_test.go
0 → 100644
View file @
8df680a3
package
batcher_test
import
(
"testing"
"time"
"github.com/ethereum-optimism/optimism/op-batcher/batcher"
"github.com/ethereum-optimism/optimism/op-service/log"
"github.com/ethereum-optimism/optimism/op-service/metrics"
"github.com/ethereum-optimism/optimism/op-service/pprof"
"github.com/ethereum-optimism/optimism/op-service/rpc"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/stretchr/testify/require"
)
func
validBatcherConfig
()
batcher
.
CLIConfig
{
return
batcher
.
CLIConfig
{
L1EthRpc
:
"fake"
,
L2EthRpc
:
"fake"
,
RollupRpc
:
"fake"
,
MaxChannelDuration
:
0
,
SubSafetyMargin
:
0
,
PollInterval
:
time
.
Second
,
MaxPendingTransactions
:
0
,
MaxL1TxSize
:
10
,
Stopped
:
false
,
BatchType
:
0
,
TxMgrConfig
:
txmgr
.
NewCLIConfig
(
"fake"
,
txmgr
.
DefaultBatcherFlagValues
),
LogConfig
:
log
.
DefaultCLIConfig
(),
MetricsConfig
:
metrics
.
DefaultCLIConfig
(),
PprofConfig
:
pprof
.
DefaultCLIConfig
(),
// The compressor config is not checked in config.Check()
RPC
:
rpc
.
DefaultCLIConfig
(),
}
}
func
TestValidBatcherConfig
(
t
*
testing
.
T
)
{
cfg
:=
validBatcherConfig
()
require
.
NoError
(
t
,
cfg
.
Check
(),
"valid config should pass the check function"
)
}
func
TestBatcherConfig
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
name
string
override
func
(
*
batcher
.
CLIConfig
)
errString
string
}{
{
name
:
"empty L1"
,
override
:
func
(
c
*
batcher
.
CLIConfig
)
{
c
.
L1EthRpc
=
""
},
errString
:
"empty L1 RPC URL"
,
},
{
name
:
"empty L2"
,
override
:
func
(
c
*
batcher
.
CLIConfig
)
{
c
.
L2EthRpc
=
""
},
errString
:
"empty L2 RPC URL"
,
},
{
name
:
"empty rollup"
,
override
:
func
(
c
*
batcher
.
CLIConfig
)
{
c
.
RollupRpc
=
""
},
errString
:
"empty rollup RPC URL"
,
},
{
name
:
"empty poll interval"
,
override
:
func
(
c
*
batcher
.
CLIConfig
)
{
c
.
PollInterval
=
0
},
errString
:
"must set PollInterval"
,
},
{
name
:
"max L1 tx size too small"
,
override
:
func
(
c
*
batcher
.
CLIConfig
)
{
c
.
MaxL1TxSize
=
0
},
errString
:
"MaxL1TxSize must be greater than 0"
,
},
{
name
:
"invalid batch type close"
,
override
:
func
(
c
*
batcher
.
CLIConfig
)
{
c
.
BatchType
=
2
},
errString
:
"unknown batch type: 2"
,
},
{
name
:
"invalid batch type far"
,
override
:
func
(
c
*
batcher
.
CLIConfig
)
{
c
.
BatchType
=
100
},
errString
:
"unknown batch type: 100"
,
},
}
for
_
,
test
:=
range
tests
{
tc
:=
test
t
.
Run
(
tc
.
name
,
func
(
t
*
testing
.
T
)
{
cfg
:=
validBatcherConfig
()
tc
.
override
(
&
cfg
)
require
.
ErrorContains
(
t
,
cfg
.
Check
(),
tc
.
errString
)
})
}
}
op-e2e/system_test.go
View file @
8df680a3
...
...
@@ -1628,14 +1628,3 @@ func TestRequiredProtocolVersionChangeAndHalt(t *testing.T) {
require
.
NoError
(
t
,
err
)
t
.
Log
(
"verified that op-geth closed!"
)
}
func
TestIncorrectBatcherConfiguration
(
t
*
testing
.
T
)
{
InitParallel
(
t
)
cfg
:=
DefaultSystemConfig
(
t
)
// make the batcher configuration invalid
cfg
.
BatcherMaxL1TxSizeBytes
=
1
_
,
err
:=
cfg
.
Start
(
t
)
require
.
Error
(
t
,
err
,
"Expected error on invalid batcher configuration"
)
}
op-service/rpc/cli.go
View file @
8df680a3
...
...
@@ -42,6 +42,14 @@ type CLIConfig struct {
EnableAdmin
bool
}
func
DefaultCLIConfig
()
CLIConfig
{
return
CLIConfig
{
ListenAddr
:
"0.0.0.0"
,
ListenPort
:
8545
,
EnableAdmin
:
false
,
}
}
func
(
c
CLIConfig
)
Check
()
error
{
if
c
.
ListenPort
<
0
||
c
.
ListenPort
>
math
.
MaxUint16
{
return
errors
.
New
(
"invalid RPC port"
)
...
...
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