https://github.com/joystream/mock_demo_node
Demo project: mocking Parity substrate modules
https://github.com/joystream/mock_demo_node
Last synced: 11 months ago
JSON representation
Demo project: mocking Parity substrate modules
- Host: GitHub
- URL: https://github.com/joystream/mock_demo_node
- Owner: Joystream
- License: unlicense
- Created: 2020-01-14T12:52:44.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-10T17:37:42.000Z (over 6 years ago)
- Last Synced: 2025-02-24T13:48:54.359Z (over 1 year ago)
- Language: Rust
- Homepage:
- Size: 45.4 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Substrate modules mocks
This project demostrates how to use mocks with Parity Substrate modules. It contains 'toy' examples and aims to demontrate mocking techniques.
Mocking framework:
- [Mockall](https://docs.rs/mockall/0.6.0/mockall/)
### Motivation
You can use mocks when you want to test modules independently. If module A is dependent on module B and next version of module B is not ready or it contains a bug - mocking can be very useful.
### Description
Project contains two substrate modules and their tests:
- discounts
- complex_prices
**complex_prices** modules depend on **discounts** module in order to calculate price.
### Complex_prices
If you need feature-rich mocks or stateful mocks you can create *mockall* solution, with some additional abstraction layers when use dependent **discounts** module.
Simpler example - how to test the substrate module - you can find [here.](https://substrate.dev/recipes/testing/externalities.html)