-
Notifications
You must be signed in to change notification settings - Fork 17
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
feat: solidity test runner config #592
feat: solidity test runner config #592
Conversation
|
pub struct StorageCachingConfig { | ||
/// Chains to cache. Either all or none or a list of chain names, e.g. | ||
/// ["optimism", "mainnet"]. | ||
pub chains: Either<CachedChains, Vec<String>>, |
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.
Either
is a workaround for lack of enums with fields in JS
The test failures are unrelated and fixed in #598 |
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.
Overall looks good.
I primarily would like to better understand why we cannot use an async fn run_solidity_tests
for calling an async constructor, as this pattern is used in our other N-API bindings.
Co-authored-by: Wodann <[email protected]>
+1 to renaming the function to |
Ok, I'll do that in a follow up PR. |
Actually on a second thought, |
Sure, I'm ok with postponing that discussion! |
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.
I proposed a solution to the mentioned async
problem with N-API here. I'm not sure whether this also circumvents the original issue that we had (about a month ago) relating to process.exit()
.
I had a discussion with @fvictorio about Javascript's best practices around callbacks. If an API is explicitly designed to receive callbacks to track its result, it should only use callbacks. No promises.
In that case, could you maybe just rename the errorCallback
to indicate that it will not be called for all errors but just for the spawning error?
I'm a proponent of renaming the runSolidityTests
function to spawnSolidityTestRunner
to make that clearer as well.
edited based on discussion with Franco
The doc says explicitly: "The error callback is called if an invalid configuration value is provided." |
Config Options
This PR exposes Solidity test runner config options to TypeScript from Rust through NAPI-RS.
The basis of the config options are the Foundry testing configuration options documented here. There were some additional config options not covered there that are needed to construct a test runner. These are exposed based on the Foundry config struct that contains all configuration options (including build and deployment options which we don't need).
The following Foundry testing options are not exposed:
Error Callback
In addition to the config options, this PR brings another change to the Solidity test runner interface: an error callback.
The reason for introducing this error callback is that building a test runner is async now to resolve forked EVM parameters, but the JS interface is sync and returns results with a progress callback. If we want to be able to propagate errors encountered while building a test runner we have two options:
The second option is simpler and composes well with the
Promise
wrapper on the TS-side (just have to pass thereject
arg of the promise as the error callback), so I went with this option.