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
c9bdd910
Unverified
Commit
c9bdd910
authored
Mar 18, 2024
by
felipe
Committed by
GitHub
Mar 18, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(proxyd): add smoke test (#9875)
parent
010dbf6c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
4 deletions
+77
-4
main.go
proxyd/cmd/proxyd/main.go
+2
-4
smoke_test.go
proxyd/integration_tests/smoke_test.go
+51
-0
smoke.toml
proxyd/integration_tests/testdata/smoke.toml
+18
-0
proxyd.go
proxyd/proxyd.go
+6
-0
No files found.
proxyd/cmd/proxyd/main.go
View file @
c9bdd910
...
...
@@ -28,8 +28,7 @@ var (
func
main
()
{
// Set up logger with a default INFO level in case we fail to parse flags.
// Otherwise the final critical log won't show what the parsing error was.
log
.
SetDefault
(
log
.
NewLogger
(
slog
.
NewJSONHandler
(
os
.
Stdout
,
&
slog
.
HandlerOptions
{
Level
:
slog
.
LevelInfo
})))
proxyd
.
SetLogLevel
(
slog
.
LevelInfo
)
log
.
Info
(
"starting proxyd"
,
"version"
,
GitVersion
,
"commit"
,
GitCommit
,
"date"
,
GitDate
)
...
...
@@ -50,8 +49,7 @@ func main() {
log
.
Warn
(
"invalid server.log_level set: "
+
config
.
Server
.
LogLevel
)
}
}
log
.
SetDefault
(
log
.
NewLogger
(
slog
.
NewJSONHandler
(
os
.
Stdout
,
&
slog
.
HandlerOptions
{
Level
:
logLevel
})))
proxyd
.
SetLogLevel
(
logLevel
)
if
config
.
Server
.
EnablePprof
{
log
.
Info
(
"starting pprof"
,
"addr"
,
"0.0.0.0"
,
"port"
,
"6060"
)
...
...
proxyd/integration_tests/smoke_test.go
0 → 100644
View file @
c9bdd910
package
integration_tests
import
(
"fmt"
"io"
"os"
"strings"
"testing"
"github.com/ethereum-optimism/optimism/proxyd"
"github.com/ethereum/go-ethereum/log"
"github.com/stretchr/testify/require"
)
func
TestInitProxyd
(
t
*
testing
.
T
)
{
goodBackend
:=
NewMockBackend
(
BatchedResponseHandler
(
200
,
goodResponse
))
defer
goodBackend
.
Close
()
require
.
NoError
(
t
,
os
.
Setenv
(
"GOOD_BACKEND_RPC_URL"
,
goodBackend
.
URL
()))
config
:=
ReadConfig
(
"smoke"
)
sysStdOut
:=
os
.
Stdout
r
,
w
,
err
:=
os
.
Pipe
()
require
.
NoError
(
t
,
err
)
os
.
Stdout
=
w
proxyd
.
SetLogLevel
(
log
.
LevelInfo
)
defer
func
()
{
w
.
Close
()
out
,
_
:=
io
.
ReadAll
(
r
)
require
.
True
(
t
,
strings
.
Contains
(
string
(
out
),
"started proxyd"
))
require
.
True
(
t
,
strings
.
Contains
(
string
(
out
),
"shutting down proxyd"
))
fmt
.
Println
(
string
(
out
))
os
.
Stdout
=
sysStdOut
}()
_
,
shutdown
,
err
:=
proxyd
.
Start
(
config
)
require
.
NoError
(
t
,
err
)
defer
shutdown
()
t
.
Run
(
"initialization"
,
func
(
t
*
testing
.
T
)
{
client
:=
NewProxydClient
(
"http://127.0.0.1:8545"
)
res
,
code
,
err
:=
client
.
SendRPC
(
ethChainID
,
nil
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
200
,
code
)
require
.
NotNil
(
t
,
res
)
})
}
proxyd/integration_tests/testdata/smoke.toml
0 → 100644
View file @
c9bdd910
[server]
rpc_port
=
8545
[backend]
response_timeout_seconds
=
1
[backends]
[backends.good]
rpc_url
=
"$GOOD_BACKEND_RPC_URL"
ws_url
=
"$GOOD_BACKEND_RPC_URL"
[backend_groups]
[backend_groups.main]
backends
=
["good"]
[rpc_method_mappings]
eth_chainId
=
"main"
proxyd/proxyd.go
View file @
c9bdd910
...
...
@@ -13,9 +13,15 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/redis/go-redis/v9"
"golang.org/x/exp/slog"
"golang.org/x/sync/semaphore"
)
func
SetLogLevel
(
logLevel
slog
.
Leveler
)
{
log
.
SetDefault
(
log
.
NewLogger
(
slog
.
NewJSONHandler
(
os
.
Stdout
,
&
slog
.
HandlerOptions
{
Level
:
logLevel
})))
}
func
Start
(
config
*
Config
)
(
*
Server
,
func
(),
error
)
{
if
len
(
config
.
Backends
)
==
0
{
return
nil
,
nil
,
errors
.
New
(
"must define at least one backend"
)
...
...
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