inkdevhub / drink

De-chained Ready-to-play ink! playground
Apache License 2.0
69 stars 15 forks source link

Basic contract mocking #61

Closed pmikolajczyk41 closed 1 year ago

pmikolajczyk41 commented 1 year ago

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

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.