Skip to content

Commit

Permalink
test: more helper methods
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha committed Feb 16, 2025
1 parent d1af748 commit 4b8bb25
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
44 changes: 44 additions & 0 deletions packages/taiko-client/driver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/urfave/cli/v2"

p2pFlags "github.com/ethereum-optimism/optimism/op-node/flags"
"github.com/ethereum-optimism/optimism/op-node/p2p"
"github.com/taikoxyz/taiko-mono/packages/taiko-client/cmd/flags"
)

Expand Down Expand Up @@ -101,3 +102,46 @@ func (s *DriverTestSuite) SetupApp() *cli.App {
}
return app
}

func (s *DriverTestSuite) defaultCliP2PConfigs() (*p2p.Config, p2p.SignerSetup) {
var (
p2pConfigCh = make(chan *p2p.Config)
signerSetupCh = make(chan p2p.SignerSetup)
app = s.SetupApp()
)

app.Action = func(ctx *cli.Context) error {
c, err := NewConfigFromCliContext(ctx)
s.Nil(err)
s.NotNil(c.P2PConfigs)
s.NotNil(c.P2PSignerConfigs)

go func() {
p2pConfigCh <- c.P2PConfigs
signerSetupCh <- c.P2PSignerConfigs
}()

return nil
}

s.Nil(app.Run([]string{
"GetDefaultP2PConfig",
"--" + flags.L1WSEndpoint.Name, l1Endpoint,
"--" + flags.L1BeaconEndpoint.Name, l1BeaconEndpoint,
"--" + flags.L2WSEndpoint.Name, l2Endpoint,
"--" + flags.L2AuthEndpoint.Name, l2EngineEndpoint,
"--" + flags.TaikoL1Address.Name, taikoL1,
"--" + flags.TaikoL2Address.Name, taikoL2,
"--" + flags.JWTSecret.Name, os.Getenv("JWT_SECRET"),
"--" + flags.P2PSyncTimeout.Name, "120s",
"--" + flags.RPCTimeout.Name, "5s",
"--" + flags.P2PSync.Name,
"--" + flags.CheckPointSyncURL.Name, l2CheckPoint,
"--" + p2pFlags.P2PPrivPathName, os.Getenv("JWT_SECRET"),
"--" + p2pFlags.DiscoveryPathName, "memory",
"--" + p2pFlags.PeerstorePathName, "memory",
"--" + p2pFlags.SequencerP2PKeyName, os.Getenv("L1_PROPOSER_PRIVATE_KEY"),
}))

return <-p2pConfigCh, <-signerSetupCh
}
6 changes: 6 additions & 0 deletions packages/taiko-client/driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ func (s *DriverTestSuite) SetupTest() {

d := new(Driver)
ctx, cancel := context.WithCancel(context.Background())

// Get default in-memory db p2p configs
p2pConfig, p2pSignerConfig := s.defaultCliP2PConfigs()

s.Nil(d.InitFromConfig(ctx, &Config{
ClientConfig: &rpc.ClientConfig{
L1Endpoint: os.Getenv("L1_WS"),
Expand All @@ -60,6 +64,8 @@ func (s *DriverTestSuite) SetupTest() {
JwtSecret: string(jwtSecret),
},
BlobServerEndpoint: s.BlobServer.URL(),
P2PConfigs: p2pConfig,
P2PSignerConfigs: p2pSignerConfig,
}))
s.d = d
s.cancel = cancel
Expand Down

0 comments on commit 4b8bb25

Please sign in to comment.