cmd/devp2p: add -node flag for testing

This commit is contained in:
Felix Lange 2023-11-07 13:27:07 +01:00
parent 9e09c76cbf
commit 10ea0443b7
3 changed files with 42 additions and 18 deletions

View file

@ -54,6 +54,7 @@ var (
testPatternFlag,
testTAPFlag,
testChainDirFlag,
testNodeFlag,
testNodeJWTFlag,
testNodeEngineFlag,
},
@ -61,12 +62,13 @@ var (
rlpxSnapTestCommand = &cli.Command{
Name: "snap-test",
Usage: "Runs snap protocol tests against a node",
ArgsUsage: "<node>",
ArgsUsage: "",
Action: rlpxSnapTest,
Flags: []cli.Flag{
testPatternFlag,
testTAPFlag,
testChainDirFlag,
testNodeFlag,
testNodeJWTFlag,
testNodeEngineFlag,
},
@ -136,8 +138,16 @@ type testParams struct {
}
func cliTestParams(ctx *cli.Context) *testParams {
nodeStr := ctx.String(testNodeFlag.Name)
if nodeStr == "" {
exit(fmt.Errorf("missing -%s", testNodeFlag.Name))
}
node, err := parseNode(nodeStr)
if err != nil {
exit(err)
}
p := testParams{
node: getNodeArg(ctx),
node: node,
engineAPI: ctx.String(testNodeEngineFlag.Name),
jwt: ctx.String(testNodeJWTFlag.Name),
chainDir: ctx.String(testChainDirFlag.Name),

View file

@ -20,6 +20,7 @@ import (
"os"
"github.com/ethereum/go-ethereum/cmd/devp2p/internal/v4test"
"github.com/ethereum/go-ethereum/internal/flags"
"github.com/ethereum/go-ethereum/internal/utesting"
"github.com/ethereum/go-ethereum/log"
"github.com/urfave/cli/v2"
@ -27,38 +28,50 @@ import (
var (
testPatternFlag = &cli.StringFlag{
Name: "run",
Usage: "Pattern of test suite(s) to run",
Name: "run",
Usage: "Pattern of test suite(s) to run",
Category: flags.TestingCategory,
}
testTAPFlag = &cli.BoolFlag{
Name: "tap",
Usage: "Output TAP",
Name: "tap",
Usage: "Output test results in TAP format",
Category: flags.TestingCategory,
}
// for eth/snap tests
testChainDirFlag = &cli.StringFlag{
Name: "chain",
Usage: "Test chain directory",
Name: "chain",
Usage: "Test chain directory (required)",
Category: flags.TestingCategory,
}
testNodeFlag = &cli.StringFlag{
Name: "node",
Usage: "Peer-to-Peer endpoint (ENR) of the test node (required)",
Category: flags.TestingCategory,
}
testNodeJWTFlag = &cli.StringFlag{
Name: "jwt",
Usage: "JWT for talking to the engine API of the test node",
Name: "jwt",
Usage: "JWT for talking to the engine API of the test node (required)",
Category: flags.TestingCategory,
}
testNodeEngineFlag = &cli.StringFlag{
Name: "engineapi",
Usage: "Engine API endpoint of the test node",
Name: "engineapi",
Usage: "Engine API endpoint of the test node (required)",
Category: flags.TestingCategory,
}
// These two are specific to the discovery tests.
testListen1Flag = &cli.StringFlag{
Name: "listen1",
Usage: "IP address of the first tester",
Value: v4test.Listen1,
Name: "listen1",
Usage: "IP address of the first tester",
Value: v4test.Listen1,
Category: flags.TestingCategory,
}
testListen2Flag = &cli.StringFlag{
Name: "listen2",
Usage: "IP address of the second tester",
Value: v4test.Listen2,
Name: "listen2",
Usage: "IP address of the second tester",
Value: v4test.Listen2,
Category: flags.TestingCategory,
}
)

View file

@ -35,6 +35,7 @@ const (
LoggingCategory = "LOGGING AND DEBUGGING"
MetricsCategory = "METRICS AND STATS"
MiscCategory = "MISC"
TestingCategory = "TESTING"
DeprecatedCategory = "ALIASED (deprecated)"
)