Skip to content

Conversation

@jribbink
Copy link
Contributor

@jribbink jribbink commented Oct 16, 2025

Closes #2164

Description

This adds --fork, --fork-host, and --fork-height flags to the test command,
allowing tests to be run against forked state from mainnet or testnet.

The --fork flag accepts a network name (e.g. mainnet/testnet) and resolves it from
flow.json. The fork mode automatically detects the chain ID by querying the
access node's GetNetworkParameters endpoint.

When in fork mode, contract aliases are resolved using the specified network
instead of the default 'testing' network.

Depends on onflow/cadence-tools#517


For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@jribbink jribbink changed the title Jribbink/fork test Add fork mode support to test framework Oct 22, 2025
@jribbink jribbink added the Improvement Technical work without new features, refactoring, improving tests label Oct 22, 2025
@jribbink jribbink marked this pull request as ready for review October 22, 2025 18:53
@jribbink jribbink force-pushed the jribbink/fork-test branch 6 times, most recently from 3f7a239 to fdaa0bf Compare October 23, 2025 14:43
@github-actions
Copy link

github-actions bot commented Oct 24, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails
gomod/github.com/onflow/cadence-tools/test 1.8.0 🟢 5.8
Details
CheckScoreReason
Maintained🟢 1030 commit(s) and 7 issue activity found in the last 90 days -- score normalized to 10
Code-Review🟢 10all changesets reviewed
Security-Policy🟢 10security policy file detected
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Binary-Artifacts🟢 10no binaries found in the repo
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
Pinned-Dependencies⚠️ 0dependency not pinned by hash detected -- score normalized to 0
Fuzzing⚠️ 0project is not fuzzed
License🟢 10license file detected
Signed-Releases⚠️ -1no releases found
Branch-Protection⚠️ -1internal error: error during branchesHandler.setup: internal error: some github tokens can't read classic branch protection rules: https://github.com/ossf/scorecard-action/blob/main/docs/authentication/fine-grained-auth-token.md
Packaging🟢 10packaging workflow detected
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0
Vulnerabilities⚠️ 076 existing vulnerabilities detected
gomod/github.com/onflow/flow-emulator 1.10.1 🟢 6.8
Details
CheckScoreReason
Code-Review🟢 10all changesets reviewed
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Maintained🟢 1030 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 10
Security-Policy🟢 10security policy file detected
Binary-Artifacts🟢 10no binaries found in the repo
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
Fuzzing⚠️ 0project is not fuzzed
License🟢 10license file detected
Pinned-Dependencies⚠️ 0dependency not pinned by hash detected -- score normalized to 0
Branch-Protection⚠️ -1internal error: error during branchesHandler.setup: internal error: some github tokens can't read classic branch protection rules: https://github.com/ossf/scorecard-action/blob/main/docs/authentication/fine-grained-auth-token.md
Signed-Releases⚠️ -1no releases found
Vulnerabilities🟢 100 existing vulnerabilities detected
Packaging🟢 10packaging workflow detected
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0

Scanned Files

  • go.mod

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds fork mode support to the test framework, enabling tests to run against forked state from mainnet or testnet. The implementation includes automatic chain ID detection via the access node's GetNetworkParameters endpoint and resolves contract aliases from the specified network instead of the default 'testing' network.

Key Changes:

  • Added --fork, --fork-host, and --fork-height CLI flags for fork mode configuration
  • Implemented automatic chain ID detection from remote networks
  • Modified contract alias resolution to use fork network when specified

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

File Description
internal/util/util.go Added GetNetworkChainID function to query chain ID from access nodes
internal/test/test.go Integrated fork mode configuration and network-based alias resolution
internal/test/test_test.go Added tests for fork mode alias resolution and refactored assertion error checks
go.mod Updated dependencies for cadence-tools/test and flow-emulator

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov-commenter
Copy link

codecov-commenter commented Oct 28, 2025

Codecov Report

❌ Patch coverage is 41.66667% with 28 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/util/util.go 0.00% 20 Missing ⚠️
internal/test/test.go 71.42% 7 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@github-actions
Copy link

@jribbink jribbink merged commit 3306758 into master Oct 28, 2025
9 checks passed
@jribbink jribbink deleted the jribbink/fork-test branch October 28, 2025 16:17
@jribbink jribbink added Feature A new user feature or a new package API and removed Improvement Technical work without new features, refactoring, improving tests labels Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature A new user feature or a new package API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add flow test --fork support

4 participants