Skip to content
This repository has been archived by the owner on Aug 19, 2022. It is now read-only.

Latest commit

 

History

History
69 lines (44 loc) · 2.44 KB

README.md

File metadata and controls

69 lines (44 loc) · 2.44 KB

Pallets

UPDATE: This repository has been archived. Pallets that are used in production are moved to universal-dot-node.

This is a playground for new pallets that are developed for Substrate.

The pallets used in production have been moved to the node.

Pallets are developed separately from Runtime and injected into the Runtime.

Custom Pallet cargo versions shall remain consistent with Runtime package versions.

Development

To build each pallet, run:

cargo build

Optionally, you can install clippy which is a rust tool that check for Rust to improve common mistakes. To install clippy: https://github.com/rust-lang/rust-clippy

To run clippy locally, run:

cargo clippy

Add Pallet to Runtime

To add a specific pallet to a Runtime, navigate to the Universal-dot-node. In the /Runtime/Cargo.toml add each pallet dependency. For example, to add the Profile pallet, the following configuration should be added:

[dependencies.pallet-profile]
default-features = false
git = 'https://github.com/UniversalDot/pallets.git'
version = '0.0.67'

Testing

Mock Runtime

Pallet test depend on substrate Runtime. To be able to run these pallet test, first we must construct a mock Runtime environment. Mocks for runtime are constructed for each pallet separately and are located in their respective /src/ folder.
More information regarding constructing Mock Runtime at the following link.

Writing tests

Tests are functions, annotated with the #[test] macro. To test specific functionality, we use assert macros to match our expectations with the expected result. There are already several predefine assert macros such as:

  • assert_eq!
  • assert_ok!
  • assert_noop!

For more information on how to create tests, refer to the following link.

Run tests

To run test each pallet, simply run at pallet root:

cargo test

To run benchmark tests for each pallet, simply run at pallet root:

cargo test --features runtime-benchmarks

Logo