-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add splitTestsCompilation solidity setting (6): Solidity test runner updates
#8133
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
Merged
alcuadrado
merged 15 commits into
dont-split-compilations
from
dont-split-compilations-phase-6
Apr 16, 2026
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a405dc4
Fix existing race condition
alcuadrado c3d1d31
Update the SPEC to reflect some DX improvements
alcuadrado 6db5c9c
Update test solidity task
alcuadrado e7eef17
Update the tests
alcuadrado cdcb497
Remove duplicated code
alcuadrado 7114817
Simplify and optimize code a bit
alcuadrado 768b800
Fix typos and cspell config
alcuadrado 0460272
Minor simplification
alcuadrado a1fa452
Disable spellcheck in the spec file
alcuadrado 8fee584
Improve type-safety
alcuadrado bda6aa6
spellcheck
alcuadrado 835dd6e
Get scopes in parallel
alcuadrado 43f99fb
Fix typo
alcuadrado a63341e
Fix test files resolution
alcuadrado 3dd4360
Validate that the provided test files exist
alcuadrado File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,7 +31,7 @@ import { formatArtifactId } from "./formatters.js"; | |
| * Despite the changes, the signature of the function should still be considered | ||
| * a draft that may change in the future. | ||
| * | ||
| * TODO: Once the signature is finalized, give feedback to the EDR team. | ||
| * Important TODO: Transform this into an AsyncGenerator<SuiteResult, SolidityTestResult, void> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should create an issue to track this, otherwise it's likely to get forgotten. It would be good to clean this up while it's still fresh in our minds
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| */ | ||
| export function run( | ||
| chainType: ChainType, | ||
|
|
@@ -41,67 +41,75 @@ export function run( | |
| tracingConfig: TracingConfigWithBuffers, | ||
| sourceNameToUserSourceName: Map<string, string>, | ||
| ): TestsStream { | ||
| const stream = new ReadableStream<TestEvent>({ | ||
| async start(controller) { | ||
| if (testSuiteIds.length === 0) { | ||
| controller.close(); | ||
| return; | ||
| } | ||
| let runCompleted = false; | ||
| const stream = new Readable({ | ||
| objectMode: true, | ||
| read() {}, | ||
| }); | ||
|
|
||
| const remainingSuites = new Set( | ||
| testSuiteIds.map((id) => | ||
| formatArtifactId(id, sourceNameToUserSourceName), | ||
| ), | ||
| ); | ||
| if (testSuiteIds.length === 0) { | ||
| stream.push(null); | ||
| return stream; | ||
| } | ||
|
|
||
| // TODO: Add support for predeploys once EDR supports them. | ||
| try { | ||
| const edrContext = await getGlobalEdrContext(); | ||
| const solidityTestResult = await edrContext.runSolidityTests( | ||
| hardhatChainTypeToEdrChainType(chainType), | ||
| artifacts, | ||
| testSuiteIds, | ||
| testRunnerConfig, | ||
| tracingConfig, | ||
| (suiteResult) => { | ||
| controller.enqueue({ | ||
| type: "suite:done", | ||
| data: suiteResult, | ||
| }); | ||
| remainingSuites.delete( | ||
| formatArtifactId(suiteResult.id, sourceNameToUserSourceName), | ||
| ); | ||
| if (remainingSuites.size === 0) { | ||
| if (runCompleted) { | ||
| controller.close(); | ||
| } | ||
| } | ||
| }, | ||
| ); | ||
| controller.enqueue({ | ||
| type: "run:done", | ||
| data: solidityTestResult, | ||
| }); | ||
| runCompleted = true; | ||
| let runCompleted = false; | ||
|
|
||
| const remainingSuites = new Set( | ||
| testSuiteIds.map((id) => formatArtifactId(id, sourceNameToUserSourceName)), | ||
| ); | ||
|
|
||
| if (remainingSuites.size === 0) { | ||
| controller.close(); | ||
| } | ||
| } catch (error) { | ||
| ensureError(error); | ||
| // Start the async work immediately. The read() callback is a no-op | ||
| // because we push data proactively from the EDR suite-completion | ||
| // callback. Using a native Readable (instead of a web ReadableStream | ||
| // wrapped with Readable.from) avoids a race where Node.js stream | ||
| // cleanup cancels the web reader while the async start callback still | ||
| // has pending work — push() on a destroyed Readable is a safe no-op. | ||
| // TODO: Add support for predeploys once EDR supports them. | ||
| void (async () => { | ||
| try { | ||
| const edrContext = await getGlobalEdrContext(); | ||
| const solidityTestResult = await edrContext.runSolidityTests( | ||
| hardhatChainTypeToEdrChainType(chainType), | ||
| artifacts, | ||
| testSuiteIds, | ||
| testRunnerConfig, | ||
| tracingConfig, | ||
| (suiteResult) => { | ||
| stream.push({ | ||
| type: "suite:done", | ||
| data: suiteResult, | ||
| } satisfies TestEvent); | ||
| remainingSuites.delete( | ||
| formatArtifactId(suiteResult.id, sourceNameToUserSourceName), | ||
| ); | ||
| if (remainingSuites.size === 0) { | ||
| if (runCompleted) { | ||
| stream.push(null); | ||
| } | ||
| } | ||
| }, | ||
| ); | ||
| stream.push({ | ||
| type: "run:done", | ||
| data: solidityTestResult, | ||
| } satisfies TestEvent); | ||
| runCompleted = true; | ||
|
|
||
| controller.error( | ||
| new HardhatError( | ||
| HardhatError.ERRORS.CORE.SOLIDITY_TESTS.UNHANDLED_EDR_ERROR_SOLIDITY_TESTS, | ||
| { | ||
| error: error.message, | ||
| }, | ||
| ), | ||
| ); | ||
| if (remainingSuites.size === 0) { | ||
| stream.push(null); | ||
| } | ||
| }, | ||
| }); | ||
| } catch (error) { | ||
| ensureError(error); | ||
|
|
||
| stream.destroy( | ||
| new HardhatError( | ||
| HardhatError.ERRORS.CORE.SOLIDITY_TESTS.UNHANDLED_EDR_ERROR_SOLIDITY_TESTS, | ||
| { | ||
| error: error.message, | ||
| }, | ||
| ), | ||
| ); | ||
| } | ||
| })(); | ||
|
|
||
| return Readable.from(stream); | ||
| return stream; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.