Finally we introduce mocking feature. For now, user can deploy a mock contract with arbitrary number of mocked messages (defined with typed closures), like this:
let mocked_contract = ContractMock::new()
.with_message([0,0,0,0], mock_message(|()| 41))
.with_message([0,0,0,1], mock_message(|(account, value)| Ok(()));
let mock_address = session.mocking_api().deploy_mock(mocked_contract);
Future upgrades
mock spies (registering calls for every mocked message)
defining custom fallback in case selector mismatch (panic, catch-all default, ignoring mock)
mocking existing contracts (mocking a single message of an already deployed contract)
...
Notes for reviewers
I made some minor refactors which unfortunately resulted in a bigger diff. The code regarding errors and tracing was just moved to another modules, so you can safely skip it.
The area of runtime interfaces and extensions is very hard, also for me, so if you have any troubles, please check the brief introduction in the docsting in runtime/pallet_contracts_debugging.rs.
Finally we introduce mocking feature. For now, user can deploy a mock contract with arbitrary number of mocked messages (defined with typed closures), like this:
Future upgrades
Notes for reviewers
I made some minor refactors which unfortunately resulted in a bigger diff. The code regarding errors and tracing was just moved to another modules, so you can safely skip it.
The area of runtime interfaces and extensions is very hard, also for me, so if you have any troubles, please check the brief introduction in the docsting in
runtime/pallet_contracts_debugging.rs
.