Skip to content
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

Chain extension: unit tests #710

Merged
merged 45 commits into from
Nov 14, 2022
Merged

Conversation

pmikolajczyk41
Copy link
Member

This PR:

  1. increases testability of SnarcosChainExtension through abstracting away Environment and Runtime,
  2. introduces a suite of 15 unit tests for SnarcosChainExtension that ensure correct charging, arguments reading and error passing

There is (at least) one controversial thing here - unstable feature of additional constant generics. It was introduced because all the main calls (pallet_snarcos::(store_key|verify)) are invoked as static methods of Runtime. Therefore, it makes testing different behaviors highly inconvenient (since we cannot change the mock behavior depending on any variable). Being able to introduce enums into generics gives us the possibility of concise defining scenarios.

@pmikolajczyk41 pmikolajczyk41 changed the base branch from snarkeling to benchmarks November 7, 2022 07:22
Base automatically changed from benchmarks to snarkeling November 8, 2022 08:05
…xtension/tests

# Conflicts:
#	bin/runtime/src/chain_extension/mod.rs
#	pallets/snarcos/src/benchmarking/mod.rs
@pmikolajczyk41
Copy link
Member Author

I guess that we are looking forward to see rust-lang/rust#95174 stabilized soon...

@pmikolajczyk41 pmikolajczyk41 merged commit 34ede10 into snarkeling Nov 14, 2022
@pmikolajczyk41 pmikolajczyk41 deleted the liminal/chain-extension/tests branch November 14, 2022 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants