Closed pgherveou closed 7 months ago
@deuszx @pmikolajczyk41 updated the initial fix.
To avoid using the hacky RefCell
& thread_local solution, I updated (one more time 😓) how everything is setup.
create_minimal_sandbox
) along with the runtime. So we use MinimalSandbox
instead of Sandbox
for the default setup.SandboxConfig
is renamed Sandbox
and exposes these two new APIs
fn execute_with<T>(&mut self, execute: impl FnOnce() -> T) -> T;
fn dry_run<T>(&mut self, action: impl FnOnce(&mut Self) -> T) -> T;
initialize_storage
is removed since this can be done when the Sandbox is created, and can be customized there instead of being part of the trait.
sandbox/*_api.rs
are updated to be traits with blanket implementations for T: Sandbox
instead of impl blocks. This needs another pass to make sure some doc string are still up to date, but hopefully this address your concern.
Thanks @pgherveou , I'll review it this week. Also, before I forget, remember to bump minor version of the crate.
Thanks @pgherveou , I'll review it this week. Also, before I forget, remember to bump minor version of the crate.
Gentle ping for review 🙏
@deuszx you are still blocking this, would be nice if you could remove the "change requested" or delegate your review to someone else?
Follow up from #99
I realized that the current design was not working as I wanted. Specifically, when working with parachain and
xcm_simulator::TestExt
, I need to use the existing externalities, and the customexecute_with
to dispatch messages properly.The Sandbox is now created inside the macro (renamed
create_minimal_sandbox
) along with the runtime. The default setup now uses theMinimalSandbox
created through the macro, instead of (the now deleted)Sandbox
struct.The trait
SandboxConfig
is renamedSandbox
and exposes these two new APIsfn initialize_storage
is removed since this can be done when the Sandbox is created, and can be customized there instead of being part of the trait.The api in
sandbox/*_api.rs
are updated to be traits with blanket implementations forT: Sandbox
instead of impl blocks.These updates let us create custom sandbox environment that have full control over the storage and execution. An example of this, is the
MockNetworkSandbox
defined in ink! that uses under the hood the xcm simulator to test connected smart contract that need to interact with a Network of chains.