-
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
Changes from 8 commits
a405dc4
c3d1d31
6db5c9c
e7eef17
cdcb497
7114817
768b800
0460272
a1fa452
8fee584
bda6aa6
835dd6e
43f99fb
a63341e
3dd4360
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.