Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Implements mocking of runtime apis #5448

Merged
merged 5 commits into from
Mar 31, 2020
Merged

Conversation

bkchr
Copy link
Member

@bkchr bkchr commented Mar 29, 2020

This pr adds support for easily mock runtime api implementations for
tests by using the mock_impl_runtime_apis! macro. The syntax is
similar to impl_runtime_apis!. The mocked implementation automatically
implements ApiExt, ApiErrorExt and Core as these are required by
the runtime api traits, but not required in tests or only a subset of them.

  • Grandpa & authority discovery tests look much better.

Closes: #1120

polkadot-companion: paritytech/polkadot#957

This pr adds support for easily mock runtime api implementations for
tests by using the `mock_impl_runtime_apis!` macro. The syntax is
similar to `impl_runtime_apis!`. The mocked implementation automatically
implements `ApiExt`, `ApiErrorExt` and `Core` as these are required by
the runtime api traits, but not required in tests or only a subset of them.
@bkchr bkchr added A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes labels Mar 29, 2020
let error = Error::new(
ty.span(),
"Error type can not change between runtime apis",
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIY, you can combine syn errors so that original error_type that differs from this ty is highlighted as well

something like this:

let error = Error::new(
	ty.span(),
	"Error type can not change between runtime apis",
 ).combine(Error::new(error_type.span(), "First Error type declared here"));

@bkchr bkchr merged commit ea5ea42 into master Mar 31, 2020
@bkchr bkchr deleted the bkchr-mock-impl-runtime-apis branch March 31, 2020 11:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-please_review Pull request needs code review. B0-silent Changes should not be mentioned in any release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make runtime api stuff workable in tests
2 participants