Skip to content

Commit 33dfd5a

Browse files
committed
feat: add extra data validation argument to test command
1 parent 4d70e5f commit 33dfd5a

File tree

2 files changed

+49
-40
lines changed

2 files changed

+49
-40
lines changed

main.go

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,35 +35,36 @@ var (
3535
)
3636

3737
var (
38-
keepFlag bool
39-
outputFlag string
40-
genesisDelayFlag uint64
41-
withOverrides []string
42-
watchdog bool
43-
dryRun bool
44-
interactive bool
45-
timeout time.Duration
46-
logLevelFlag string
47-
bindExternal bool
48-
withPrometheus bool
49-
networkName string
50-
labels playground.MapStringFlag
51-
disableLogs bool
52-
platform string
53-
contenderEnabled bool
54-
contenderArgs []string
55-
contenderTarget string
56-
detached bool
57-
skipSetup bool
58-
prefundedAccounts []string
59-
followFlag bool
60-
generateForce bool
61-
testRPCURL string
62-
testELRPCURL string
63-
testTimeout time.Duration
64-
testRetries int
65-
testInsecure bool
66-
portListFlag bool
38+
keepFlag bool
39+
outputFlag string
40+
genesisDelayFlag uint64
41+
withOverrides []string
42+
watchdog bool
43+
dryRun bool
44+
interactive bool
45+
timeout time.Duration
46+
logLevelFlag string
47+
bindExternal bool
48+
withPrometheus bool
49+
networkName string
50+
labels playground.MapStringFlag
51+
disableLogs bool
52+
platform string
53+
contenderEnabled bool
54+
contenderArgs []string
55+
contenderTarget string
56+
detached bool
57+
skipSetup bool
58+
prefundedAccounts []string
59+
followFlag bool
60+
generateForce bool
61+
testRPCURL string
62+
testELRPCURL string
63+
testTimeout time.Duration
64+
testRetries int
65+
testInsecure bool
66+
testExpectedExtraData string
67+
portListFlag bool
6768
)
6869

6970
var rootCmd = &cobra.Command{
@@ -519,6 +520,7 @@ var testCmd = &cobra.Command{
519520
cfg.Timeout = testTimeout
520521
cfg.Retries = testRetries
521522
cfg.Insecure = testInsecure
523+
cfg.ExpectedExtraData = testExpectedExtraData
522524

523525
// Suggest --insecure flag if any RPC URL uses https without insecure mode
524526
for _, rpcURL := range []string{cfg.RPCURL, cfg.ELRPCURL} {
@@ -641,6 +643,7 @@ func main() {
641643
testCmd.Flags().DurationVar(&testTimeout, "timeout", time.Minute, "Timeout for waiting for transaction receipt (0 means no timeout - default: 1m)")
642644
testCmd.Flags().IntVar(&testRetries, "retries", 0, "Max number of failed receipt requests before giving up (0 means retry forever - default: 0)")
643645
testCmd.Flags().BoolVar(&testInsecure, "insecure", false, "Skip TLS certificate verification (for self-signed certs)")
646+
testCmd.Flags().StringVar(&testExpectedExtraData, "expected-extra-data", "", "Verify block extra data matches this string (fails if different)")
644647
rootCmd.AddCommand(testCmd)
645648

646649
if err := rootCmd.Execute(); err != nil {

playground/test_tx.go

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,17 @@ func (t *buildernetSigningTransport) RoundTrip(req *http.Request) (*http.Respons
6060

6161
// TestTxConfig holds configuration for the test transaction
6262
type TestTxConfig struct {
63-
RPCURL string // Target RPC URL for sending transactions (e.g., rbuilder)
64-
ELRPCURL string // EL RPC URL for chain queries (e.g., reth). If empty, uses RPCURL
65-
PrivateKey string
66-
ToAddress string
67-
Value *big.Int
68-
GasLimit uint64
69-
GasPrice *big.Int
70-
Timeout time.Duration // Timeout for waiting for receipt. If 0, no timeout.
71-
Retries int // Max failed receipt requests before giving up. If 0, retry forever.
72-
Insecure bool // Skip TLS certificate verification
63+
RPCURL string // Target RPC URL for sending transactions (e.g., rbuilder)
64+
ELRPCURL string // EL RPC URL for chain queries (e.g., reth). If empty, uses RPCURL
65+
PrivateKey string
66+
ToAddress string
67+
Value *big.Int
68+
GasLimit uint64
69+
GasPrice *big.Int
70+
Timeout time.Duration // Timeout for waiting for receipt. If 0, no timeout.
71+
Retries int // Max failed receipt requests before giving up. If 0, retry forever.
72+
Insecure bool // Skip TLS certificate verification
73+
ExpectedExtraData string // If set, verify block extra data matches this string
7374
}
7475

7576
// DefaultTestTxConfig returns the default test transaction configuration
@@ -240,7 +241,12 @@ func SendTestTransaction(ctx context.Context, cfg *TestTxConfig) error {
240241
// Get block to show extra data (builder name)
241242
block, err := elClient.BlockByNumber(ctx, receipt.BlockNumber)
242243
if err == nil && block != nil {
243-
fmt.Printf(" Extra Data: %s\n", string(block.Extra()))
244+
extraData := string(block.Extra())
245+
fmt.Printf(" Extra Data: %s\n", extraData)
246+
247+
if cfg.ExpectedExtraData != "" && extraData != cfg.ExpectedExtraData {
248+
return fmt.Errorf("extra data mismatch: expected %q, got %q", cfg.ExpectedExtraData, extraData)
249+
}
244250
}
245251
return nil
246252
}

0 commit comments

Comments
 (0)