cmd/devp2p: set flag as required

This commit is contained in:
jsvisa 2025-10-20 23:26:43 +08:00
parent 7c107c2691
commit 557e191976
2 changed files with 5 additions and 14 deletions

View file

@ -143,9 +143,6 @@ type testParams struct {
func cliTestParams(ctx *cli.Context) *testParams { func cliTestParams(ctx *cli.Context) *testParams {
nodeStr := ctx.String(testNodeFlag.Name) nodeStr := ctx.String(testNodeFlag.Name)
if nodeStr == "" {
exit(fmt.Errorf("missing -%s", testNodeFlag.Name))
}
node, err := parseNode(nodeStr) node, err := parseNode(nodeStr)
if err != nil { if err != nil {
exit(err) exit(err)
@ -156,14 +153,5 @@ func cliTestParams(ctx *cli.Context) *testParams {
jwt: ctx.String(testNodeJWTFlag.Name), jwt: ctx.String(testNodeJWTFlag.Name),
chainDir: ctx.String(testChainDirFlag.Name), chainDir: ctx.String(testChainDirFlag.Name),
} }
if p.engineAPI == "" {
exit(fmt.Errorf("missing -%s", testNodeEngineFlag.Name))
}
if p.jwt == "" {
exit(fmt.Errorf("missing -%s", testNodeJWTFlag.Name))
}
if p.chainDir == "" {
exit(fmt.Errorf("missing -%s", testChainDirFlag.Name))
}
return &p return &p
} }

View file

@ -39,26 +39,29 @@ var (
} }
// for eth/snap tests // for eth/snap tests
testChainDirFlag = &cli.StringFlag{ testChainDirFlag = &cli.PathFlag{
Name: "chain", Name: "chain",
Usage: "Test chain directory (required)", Usage: "Test chain directory (required)",
Category: flags.TestingCategory, Category: flags.TestingCategory,
Required: true,
} }
testNodeFlag = &cli.StringFlag{ testNodeFlag = &cli.StringFlag{
Name: "node", Name: "node",
Usage: "Peer-to-Peer endpoint (ENR) of the test node (required)", Usage: "Peer-to-Peer endpoint (ENR) of the test node (required)",
Category: flags.TestingCategory, Category: flags.TestingCategory,
Required: true,
} }
testNodeJWTFlag = &cli.StringFlag{ testNodeJWTFlag = &cli.StringFlag{
Name: "jwtsecret", Name: "jwtsecret",
Usage: "JWT secret for the engine API of the test node (required)", Usage: "JWT secret for the engine API of the test node (required)",
Category: flags.TestingCategory, Category: flags.TestingCategory,
Value: "0x7365637265747365637265747365637265747365637265747365637265747365", Required: true,
} }
testNodeEngineFlag = &cli.StringFlag{ testNodeEngineFlag = &cli.StringFlag{
Name: "engineapi", Name: "engineapi",
Usage: "Engine API endpoint of the test node (required)", Usage: "Engine API endpoint of the test node (required)",
Category: flags.TestingCategory, Category: flags.TestingCategory,
Required: true,
} }
// These two are specific to the discovery tests. // These two are specific to the discovery tests.