-
Notifications
You must be signed in to change notification settings - Fork 9
Update convert tests #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add configuration for multiple distinct sporks for testing
Remove unused createSpork() function and associated data. The data was moved to variable `Mainnet24_SporkVersion6`.
The test was not actually verifying anything, due to only checking resultIDs for current blocks against sealed results of previous blocks.
WalkthroughRefactors tests in Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant TR as Test Runner
participant ST as sporkTemplate
participant S as *config.Spork
participant BS as BlockSource
participant ERS as ExecResultSource
rect rgb(235,245,255)
note right of TR: Per-spork subtest setup
TR->>ST: build sporkTemplate
ST-->>TR: S (Spork)
end
rect rgb(240,255,240)
note right of TR: VerifyBlocksForSpork
TR->>BS: Fetch BlockByHeight / BlockHeaderByHeight [start..end] using S
BS-->>TR: Blocks & Headers
TR->>TR: verifyBlockHash per block (compare header/block hash)
end
rect rgb(255,250,235)
note right of TR: VerifyExecutionResultsForSpork
TR->>ERS: Fetch seals and execution payloads using S
ERS-->>TR: Seals & payloads
TR->>TR: convertExecutionResult / deriveExecutionResult -> map by flow.Identifier
TR->>TR: Compare sealed vs computed results (ensure at least one match)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (5)
state/convert_test.go (5)
41-54: Enable TLS for real access nodes (avoid insecure dials and fatal dial failures)These are production mainnet endpoints; dialing without TLS will use insecure creds in access.New and likely fail. Set TLS: true (or provide PublicKey) for each NodeConfig.
Apply:
var Mainnet24_SporkVersion6 = sporkTemplate{ - AccessNodes: []access.NodeConfig{{Address: "access-001.mainnet24.nodes.onflow.org:9000"}}, + AccessNodes: []access.NodeConfig{{Address: "access-001.mainnet24.nodes.onflow.org:9000", TLS: true}}, Chain: config.Chain{Network: "mainnet"}, RootBlock: 65264619, Version: 6, } var Mainnet26_SporkVersion7 = sporkTemplate{ - AccessNodes: []access.NodeConfig{{Address: "access-001.mainnet26.nodes.onflow.org:9000"}}, + AccessNodes: []access.NodeConfig{{Address: "access-001.mainnet26.nodes.onflow.org:9000", TLS: true}}, Chain: config.Chain{Network: "mainnet"}, RootBlock: 125_000_000, Version: 7, }If TLS is not accepted by these hosts in your env, please confirm the expected setting for NodeConfig (TLS vs PublicKey).
55-66: Bound network calls with timeouts in subtestsGuard against hangs by using context.WithTimeout in each subtest.
t.Run("mainnet24 spork version 6", func(t *testing.T) { - ctx := context.Background() + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + defer cancel() spork := Mainnet24_SporkVersion6.create(ctx) VerifyBlocksForSpork(t, ctx, spork, 65264620, 65264630) }) t.Run("mainnet26 spork version 7", func(t *testing.T) { - ctx := context.Background() + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + defer cancel() spork := Mainnet26_SporkVersion7.create(ctx) VerifyBlocksForSpork(t, ctx, spork, 125_000_001, 125_000_011) })t.Run("mainnet24 spork version 6", func(t *testing.T) { - ctx := context.Background() + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + defer cancel() spork := Mainnet24_SporkVersion6.create(ctx) VerifyExecutionResultsForSpork(t, ctx, spork, 65264620, 65264630) }) t.Run("mainnet26 spork version 7", func(t *testing.T) { - ctx := context.Background() + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + defer cancel() spork := Mainnet26_SporkVersion7.create(ctx) VerifyExecutionResultsForSpork(t, ctx, spork, 125_000_001, 125_000_011) })t.Run("mainnet24 / spork version 6", func(t *testing.T) { - ctx := context.Background() + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + defer cancel() spork := Mainnet24_SporkVersion6.create(ctx) VerifyEventsHashForSpork(t, ctx, spork, 65264620, 65264630) }) t.Run("mainnet26 / spork version 7", func(t *testing.T) { - ctx := context.Background() + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + defer cancel() spork := Mainnet26_SporkVersion7.create(ctx) VerifyEventsHashForSpork(t, ctx, spork, 125_000_001, 125_000_011) })Add import:
import ( "bytes" "context" "testing" + "time"Also applies to: 84-96, 128-139
68-82: Use require.NoError instead of require.Fail for RPC errorsThis provides better test output and avoids nil-pointer risk on subsequent uses.
- block, err := client.BlockByHeight(ctx, blockHeight) - if err != nil { - require.Fail(t, err.Error()) - } + block, err := client.BlockByHeight(ctx, blockHeight) + require.NoError(t, err) - blockHeader, err := client.BlockHeaderByHeight(ctx, blockHeight) - if err != nil { - require.Fail(t, err.Error()) - } + blockHeader, err := client.BlockHeaderByHeight(ctx, blockHeight) + require.NoError(t, err)
68-82: Mark helpers with t.Helper() for accurate failure locationsImproves error reporting by attributing failures to caller sites.
func VerifyBlocksForSpork(t *testing.T, ctx context.Context, spork *config.Spork, startHeight uint64, endHeight uint64) { + t.Helper() client := spork.AccessNodes.Client()func VerifyExecutionResultsForSpork(t *testing.T, ctx context.Context, spork *config.Spork, startHeight uint64, endHeight uint64) { + t.Helper() client := spork.AccessNodes.Client()func VerifyEventsHashForSpork(t *testing.T, ctx context.Context, spork *config.Spork, startHeight uint64, endHeight uint64) { + t.Helper() client := spork.AccessNodes.Client()Also applies to: 97-126, 141-196
97-126: Sanity-check: ensure the chosen height window contains at least one sealThe test requires at least one sealed vs computed comparison; if not, it'll fail with NotZero. If flakiness shows up, consider widening the window slightly.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
state/convert_test.go(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
state/convert_test.go (2)
access/access.go (3)
NodeConfig(515-523)New(574-620)Client(66-69)config/config.go (2)
Chain(23-42)Spork(107-119)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: test
🔇 Additional comments (1)
state/convert_test.go (1)
19-39: Centralized spork construction looks goodEncapsulating Spork creation behind a template improves consistency and reduces duplication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
♻️ Duplicate comments (1)
state/convert_test.go (1)
97-126: Great fix on []byte→flow.Identifier conversions; compare identifiers directly.Using toFlowIdentifier resolves the compile-time bug flagged earlier. Also, compare identifiers directly to avoid extra allocations.
func VerifyExecutionResultsForSpork(t *testing.T, ctx context.Context, spork *config.Spork, startHeight uint64, endHeight uint64) { + t.Helper() @@ - require.Equal(t, sealedResult.String(), computedResults[blockID].String(), "mismatched result ID") + require.Equal(t, sealedResult, computedResults[blockID], "mismatched result ID")Additionally, clarify that endHeight is exclusive in the function comment or switch loop to <= and pass inclusive end.
🧹 Nitpick comments (3)
state/convert_test.go (3)
19-30: Polish versioning comment grammar.Minor doc tweak for clarity.
- // This version number is incremented each time there is a Flow network upgrades which includes a breaking change for Rosetta. + // This version number is incremented each time there is a Flow network upgrade that includes a breaking change for Rosetta.
141-196: Helper ergonomics + richer assertions for easier triage.
- Mark as helper.
- Include height/chunk index in assertion messages.
func VerifyEventsHashForSpork(t *testing.T, ctx context.Context, spork *config.Spork, startHeight uint64, endHeight uint64) { + t.Helper() @@ - require.Equal(t, len(eventHashes), len(execResult.Chunks)) + require.Equalf(t, len(eventHashes), len(execResult.Chunks), "height=%d", blockHeight) for idx, eventHash := range eventHashes { chunk := execResult.Chunks[idx] - require.Equal(t, eventHash[:], chunk.EventCollection) + require.Equalf(t, eventHash[:], chunk.EventCollection, "height=%d chunk=%d", blockHeight, idx) }
68-82: MarkVerifyBlocksForSporkas a test helper and improve error reporting
Addt.Helper()and replacerequire.Failwithrequire.NoErrorf(including the height) to retain stack traces and provide clearer context.func VerifyBlocksForSpork(t *testing.T, ctx context.Context, spork *config.Spork, startHeight uint64, endHeight uint64) { + t.Helper() client := spork.AccessNodes.Client() for blockHeight := startHeight; blockHeight < endHeight; blockHeight++ { - block, err := client.BlockByHeight(ctx, blockHeight) - if err != nil { - require.Fail(t, err.Error()) - } + block, err := client.BlockByHeight(ctx, blockHeight) + require.NoErrorf(t, err, "BlockByHeight(%d)", blockHeight) blockHeader, err := client.BlockHeaderByHeight(ctx, blockHeight) - if err != nil { - require.Fail(t, err.Error()) - } + require.NoErrorf(t, err, "BlockHeaderByHeight(%d)", blockHeight) require.True(t, verifyBlockHash(spork, block.Id, blockHeight, blockHeader, block)) } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
state/convert_test.go(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
state/convert_test.go (2)
access/access.go (3)
NodeConfig(515-523)New(574-620)Client(66-69)config/config.go (2)
Chain(23-42)Spork(107-119)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: test
🔇 Additional comments (1)
state/convert_test.go (1)
32-39: Spork factory looks good.Helper cleanly constructs a config.Spork; no issues spotted.
| var Mainnet24_SporkVersion6 = sporkTemplate{ | ||
| AccessNodes: []access.NodeConfig{{Address: "access-001.mainnet24.nodes.onflow.org:9000"}}, | ||
| Chain: config.Chain{Network: "mainnet"}, | ||
| RootBlock: 65264619, | ||
| Version: 6, | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Likely broken connectivity: set TLS for public mainnet Access nodes.
The onflow public endpoints generally require TLS. With TLS omitted, grpc.DialContext will use insecure creds and calls will fail at runtime.
Apply:
var Mainnet24_SporkVersion6 = sporkTemplate{
- AccessNodes: []access.NodeConfig{{Address: "access-001.mainnet24.nodes.onflow.org:9000"}},
+ AccessNodes: []access.NodeConfig{{Address: "access-001.mainnet24.nodes.onflow.org:9000", TLS: true}},
Chain: config.Chain{Network: "mainnet"},
RootBlock: 65264619,
Version: 6,
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| var Mainnet24_SporkVersion6 = sporkTemplate{ | |
| AccessNodes: []access.NodeConfig{{Address: "access-001.mainnet24.nodes.onflow.org:9000"}}, | |
| Chain: config.Chain{Network: "mainnet"}, | |
| RootBlock: 65264619, | |
| Version: 6, | |
| } | |
| var Mainnet24_SporkVersion6 = sporkTemplate{ | |
| AccessNodes: []access.NodeConfig{{ | |
| Address: "access-001.mainnet24.nodes.onflow.org:9000", | |
| TLS: true, | |
| }}, | |
| Chain: config.Chain{Network: "mainnet"}, | |
| RootBlock: 65264619, | |
| Version: 6, | |
| } |
🤖 Prompt for AI Agents
In state/convert_test.go around lines 41 to 47, the public mainnet Access node
is configured without TLS which will cause grpc.DialContext to use insecure
credentials and fail; update the NodeConfig to enable TLS and use the TLS port
(for example set Address to "access-001.mainnet24.nodes.onflow.org:443" and set
the NodeConfig's TLS/UseTLS field to true or equivalent so gRPC connects with
secure transport).
| var Mainnet26_SporkVersion7 = sporkTemplate{ | ||
| AccessNodes: []access.NodeConfig{{Address: "access-001.mainnet26.nodes.onflow.org:9000"}}, | ||
| Chain: config.Chain{Network: "mainnet"}, | ||
| RootBlock: 125_000_000, | ||
| Version: 7, | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set TLS on mainnet26 node as well.
var Mainnet26_SporkVersion7 = sporkTemplate{
- AccessNodes: []access.NodeConfig{{Address: "access-001.mainnet26.nodes.onflow.org:9000"}},
+ AccessNodes: []access.NodeConfig{{Address: "access-001.mainnet26.nodes.onflow.org:9000", TLS: true}},
Chain: config.Chain{Network: "mainnet"},
RootBlock: 125_000_000,
Version: 7,
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| var Mainnet26_SporkVersion7 = sporkTemplate{ | |
| AccessNodes: []access.NodeConfig{{Address: "access-001.mainnet26.nodes.onflow.org:9000"}}, | |
| Chain: config.Chain{Network: "mainnet"}, | |
| RootBlock: 125_000_000, | |
| Version: 7, | |
| } | |
| var Mainnet26_SporkVersion7 = sporkTemplate{ | |
| AccessNodes: []access.NodeConfig{{Address: "access-001.mainnet26.nodes.onflow.org:9000", TLS: true}}, | |
| Chain: config.Chain{Network: "mainnet"}, | |
| RootBlock: 125_000_000, | |
| Version: 7, | |
| } |
🤖 Prompt for AI Agents
In state/convert_test.go around lines 48 to 53, the Mainnet26_SporkVersion7
AccessNodes entry misses enabling TLS; update the access.NodeConfig for
"access-001.mainnet26.nodes.onflow.org:9000" to set TLS: true (i.e., add the TLS
field to the struct initialization) so the mainnet26 node is configured to use
TLS.
| func TestVerifyBlockHash(t *testing.T) { | ||
| t.Run("mainnet24 spork version 6", func(t *testing.T) { | ||
| ctx := context.Background() | ||
| spork := Mainnet24_SporkVersion6.create(ctx) | ||
| VerifyBlocksForSpork(t, ctx, spork, 65264620, 65264630) | ||
| }) | ||
| t.Run("mainnet26 spork version 7", func(t *testing.T) { | ||
| ctx := context.Background() | ||
| spork := Mainnet26_SporkVersion7.create(ctx) | ||
| VerifyBlocksForSpork(t, ctx, spork, 125_000_001, 125_000_011) | ||
| }) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Bound network calls with timeouts to avoid hanging tests.
Use context.WithTimeout and t.Cleanup(cancel) in each subtest.
t.Run("mainnet24 spork version 6", func(t *testing.T) {
- ctx := context.Background()
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ t.Cleanup(cancel)
spork := Mainnet24_SporkVersion6.create(ctx)
VerifyBlocksForSpork(t, ctx, spork, 65264620, 65264630)
})
t.Run("mainnet26 spork version 7", func(t *testing.T) {
- ctx := context.Background()
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ t.Cleanup(cancel)
spork := Mainnet26_SporkVersion7.create(ctx)
VerifyBlocksForSpork(t, ctx, spork, 125_000_001, 125_000_011)
})Add import:
// add to imports
"time"Also consider documenting that endHeight is exclusive to avoid off-by-one confusion.
🤖 Prompt for AI Agents
In state/convert_test.go around lines 55 to 66 the subtests create background
contexts that allow network calls to hang indefinitely; update each subtest to
use context.WithTimeout (e.g., ctx, cancel :=
context.WithTimeout(context.Background(), time.Minute)) and call
t.Cleanup(cancel) so the timeout is enforced and cleaned up. Add the "time"
import to the file imports. Also add a short comment on the VerifyBlocksForSpork
call noting that endHeight is exclusive to prevent off-by-one confusion.
| func TestVerifyExecutionResultHash(t *testing.T) { | ||
| ctx := context.Background() | ||
| spork, err := createSpork(ctx) | ||
| if err != nil { | ||
| require.Fail(t, err.Error()) | ||
| } | ||
| t.Run("mainnet24 spork version 6", func(t *testing.T) { | ||
| ctx := context.Background() | ||
| spork := Mainnet24_SporkVersion6.create(ctx) | ||
| VerifyExecutionResultsForSpork(t, ctx, spork, 65264620, 65264630) | ||
| }) | ||
| t.Run("mainnet26 spork version 7", func(t *testing.T) { | ||
| ctx := context.Background() | ||
| spork := Mainnet26_SporkVersion7.create(ctx) | ||
| VerifyExecutionResultsForSpork(t, ctx, spork, 125_000_001, 125_000_011) | ||
| }) | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add timeouts to execution-result subtests.
t.Run("mainnet24 spork version 6", func(t *testing.T) {
- ctx := context.Background()
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ t.Cleanup(cancel)
spork := Mainnet24_SporkVersion6.create(ctx)
VerifyExecutionResultsForSpork(t, ctx, spork, 65264620, 65264630)
})
t.Run("mainnet26 spork version 7", func(t *testing.T) {
- ctx := context.Background()
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ t.Cleanup(cancel)
spork := Mainnet26_SporkVersion7.create(ctx)
VerifyExecutionResultsForSpork(t, ctx, spork, 125_000_001, 125_000_011)
})📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| func TestVerifyExecutionResultHash(t *testing.T) { | |
| ctx := context.Background() | |
| spork, err := createSpork(ctx) | |
| if err != nil { | |
| require.Fail(t, err.Error()) | |
| } | |
| t.Run("mainnet24 spork version 6", func(t *testing.T) { | |
| ctx := context.Background() | |
| spork := Mainnet24_SporkVersion6.create(ctx) | |
| VerifyExecutionResultsForSpork(t, ctx, spork, 65264620, 65264630) | |
| }) | |
| t.Run("mainnet26 spork version 7", func(t *testing.T) { | |
| ctx := context.Background() | |
| spork := Mainnet26_SporkVersion7.create(ctx) | |
| VerifyExecutionResultsForSpork(t, ctx, spork, 125_000_001, 125_000_011) | |
| }) | |
| } | |
| func TestVerifyExecutionResultHash(t *testing.T) { | |
| t.Run("mainnet24 spork version 6", func(t *testing.T) { | |
| ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) | |
| t.Cleanup(cancel) | |
| spork := Mainnet24_SporkVersion6.create(ctx) | |
| VerifyExecutionResultsForSpork(t, ctx, spork, 65264620, 65264630) | |
| }) | |
| t.Run("mainnet26 spork version 7", func(t *testing.T) { | |
| ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) | |
| t.Cleanup(cancel) | |
| spork := Mainnet26_SporkVersion7.create(ctx) | |
| VerifyExecutionResultsForSpork(t, ctx, spork, 125_000_001, 125_000_011) | |
| }) | |
| } |
🤖 Prompt for AI Agents
In state/convert_test.go around lines 84 to 96, the two subtests lack timeouts
for their contexts; wrap each ctx := context.Background() with a cancellable
timeout (e.g., ctx, cancel := context.WithTimeout(context.Background(),
10*time.Second)) and defer cancel() immediately after creating it, then pass
that ctx into VerifyExecutionResultsForSpork so the test will be bounded and
will fail if it hangs.
| func TestDeriveEventsHash(t *testing.T) { | ||
| ctx := context.Background() | ||
| spork, err := createSpork(ctx) | ||
| if err != nil { | ||
| assert.Fail(t, err.Error()) | ||
| } | ||
| t.Run("mainnet24 / spork version 6", func(t *testing.T) { | ||
| ctx := context.Background() | ||
| spork := Mainnet24_SporkVersion6.create(ctx) | ||
| VerifyEventsHashForSpork(t, ctx, spork, 65264620, 65264630) | ||
| }) | ||
| t.Run("mainnet26 / spork version 7", func(t *testing.T) { | ||
| ctx := context.Background() | ||
| spork := Mainnet26_SporkVersion7.create(ctx) | ||
| VerifyEventsHashForSpork(t, ctx, spork, 125_000_001, 125_000_011) | ||
| }) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add timeouts to events-hash subtests.
t.Run("mainnet24 / spork version 6", func(t *testing.T) {
- ctx := context.Background()
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ t.Cleanup(cancel)
spork := Mainnet24_SporkVersion6.create(ctx)
VerifyEventsHashForSpork(t, ctx, spork, 65264620, 65264630)
})
t.Run("mainnet26 / spork version 7", func(t *testing.T) {
- ctx := context.Background()
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ t.Cleanup(cancel)
spork := Mainnet26_SporkVersion7.create(ctx)
VerifyEventsHashForSpork(t, ctx, spork, 125_000_001, 125_000_011)
})Optionally gate these network tests behind an env var (e.g., FLOW_INTEGRATION=1) to reduce CI flakiness.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| func TestDeriveEventsHash(t *testing.T) { | |
| ctx := context.Background() | |
| spork, err := createSpork(ctx) | |
| if err != nil { | |
| assert.Fail(t, err.Error()) | |
| } | |
| t.Run("mainnet24 / spork version 6", func(t *testing.T) { | |
| ctx := context.Background() | |
| spork := Mainnet24_SporkVersion6.create(ctx) | |
| VerifyEventsHashForSpork(t, ctx, spork, 65264620, 65264630) | |
| }) | |
| t.Run("mainnet26 / spork version 7", func(t *testing.T) { | |
| ctx := context.Background() | |
| spork := Mainnet26_SporkVersion7.create(ctx) | |
| VerifyEventsHashForSpork(t, ctx, spork, 125_000_001, 125_000_011) | |
| }) | |
| } | |
| func TestDeriveEventsHash(t *testing.T) { | |
| t.Run("mainnet24 / spork version 6", func(t *testing.T) { | |
| ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) | |
| t.Cleanup(cancel) | |
| spork := Mainnet24_SporkVersion6.create(ctx) | |
| VerifyEventsHashForSpork(t, ctx, spork, 65264620, 65264630) | |
| }) | |
| t.Run("mainnet26 / spork version 7", func(t *testing.T) { | |
| ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) | |
| t.Cleanup(cancel) | |
| spork := Mainnet26_SporkVersion7.create(ctx) | |
| VerifyEventsHashForSpork(t, ctx, spork, 125_000_001, 125_000_011) | |
| }) | |
| } |
🤖 Prompt for AI Agents
In state/convert_test.go around lines 128 to 139, the two subtests run
network-dependent verification without timeouts (and currently always run in
CI); add per-subtest timeouts by creating a context.WithTimeout inside each
t.Run and using that ctx for spork creation and VerifyEventsHashForSpork so the
test fails fast on hangs, and optionally gate these network tests behind an env
var (e.g., skip the subtest unless os.Getenv("FLOW_INTEGRATION") == "1") to
avoid running them in regular CI.
|
Included as part of PR #90. |
Allow testing on different spork versions, and fix a test that didn't verify what it claimed to.
Summary by CodeRabbit