Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
727 changes: 652 additions & 75 deletions .ai/categories/parachains.md

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,7 @@ Follow these steps to prepare your environment for pallet benchmarking:
1. Register your pallet in `runtime/src/benchmarks.rs`:

```rust hl_lines="11" title="benchmarks.rs"
polkadot_sdk::frame_benchmarking::define_benchmarks!(
[frame_system, SystemBench::<Runtime>]
[pallet_balances, Balances]
[pallet_session, SessionBench::<Runtime>]
[pallet_timestamp, Timestamp]
[pallet_message_queue, MessageQueue]
[pallet_sudo, Sudo]
[pallet_collator_selection, CollatorSelection]
[cumulus_pallet_parachain_system, ParachainSystem]
[cumulus_pallet_xcmp_queue, XcmpQueue]
[custom_pallet, CustomPallet]
);

```

2. Enable runtime benchmarking for your pallet in `runtime/Cargo.toml`:
Expand Down Expand Up @@ -307,11 +296,6 @@ Finally, configure the actual weight values in your production runtime. In `runt

```rust hl_lines="5" title="mod.rs"

// Define counter max value runtime constant.
parameter_types! {
pub const CounterMaxValue: u32 = 500;
}

```

Your pallet is now complete with full testing and benchmarking support, ready for production use.
Expand Down
112 changes: 91 additions & 21 deletions .ai/site-index.json
Original file line number Diff line number Diff line change
Expand Up @@ -5226,14 +5226,14 @@
},
{
"id": "parachains-customize-runtime-pallet-development-pallet-testing",
"title": "Pallet Testing",
"title": "Pallet Unit Testing",
"slug": "parachains-customize-runtime-pallet-development-pallet-testing",
"categories": [
"Parachains"
],
"raw_md_url": "https://raw.githubusercontent.com/polkadot-developers/polkadot-docs/master/.ai/pages/parachains-customize-runtime-pallet-development-pallet-testing.md",
"html_url": "https://docs.polkadot.com/parachains/customize-runtime/pallet-development/pallet-testing/",
"preview": "Unit testing in the Polkadot SDK helps ensure that the functions provided by a pallet behave as expected. It also confirms that data and events associated with a pallet are processed correctly during interactions. The Polkadot SDK offers a set of APIs to create a test environment to simulate runtime and mock transaction execution for extrinsics and queries.",
"preview": "Unit testing in the Polkadot SDK helps ensure that the functions provided by a pallet behave as expected. It also confirms that data and events associated with a pallet are processed correctly during interactions. With your mock runtime in place from the previous guide, you can now write comprehensive tests that verify your pallet's behavior in isolation.",
"outline": [
{
"depth": 2,
Expand All @@ -5242,28 +5242,98 @@
},
{
"depth": 2,
"title": "Writing Unit Tests",
"anchor": "writing-unit-tests"
"title": "Prerequisites",
"anchor": "prerequisites"
},
{
"depth": 2,
"title": "Understanding FRAME Testing Tools",
"anchor": "understanding-frame-testing-tools"
},
{
"depth": 3,
"title": "Assertion Macros",
"anchor": "assertion-macros"
},
{
"depth": 3,
"title": "System Pallet Test Helpers",
"anchor": "system-pallet-test-helpers"
},
{
"depth": 3,
"title": "Test Initialization",
"anchor": "test-initialization"
"title": "Origin Types",
"anchor": "origin-types"
},
{
"depth": 2,
"title": "Create the Tests Module",
"anchor": "create-the-tests-module"
},
{
"depth": 2,
"title": "Set Up the Test Module",
"anchor": "set-up-the-test-module"
},
{
"depth": 2,
"title": "Write Your First Test",
"anchor": "write-your-first-test"
},
{
"depth": 3,
"title": "Function Call Testing",
"anchor": "function-call-testing"
"title": "Test Basic Increment",
"anchor": "test-basic-increment"
},
{
"depth": 2,
"title": "Test Error Conditions",
"anchor": "test-error-conditions"
},
{
"depth": 3,
"title": "Storage Testing",
"anchor": "storage-testing"
"title": "Test Overflow Protection",
"anchor": "test-overflow-protection"
},
{
"depth": 3,
"title": "Event Testing",
"anchor": "event-testing"
"title": "Test Underflow Protection",
"anchor": "test-underflow-protection"
},
{
"depth": 2,
"title": "Test Access Control",
"anchor": "test-access-control"
},
{
"depth": 3,
"title": "Test Root-Only Access",
"anchor": "test-root-only-access"
},
{
"depth": 2,
"title": "Test Event Emission",
"anchor": "test-event-emission"
},
{
"depth": 3,
"title": "Test Event Data",
"anchor": "test-event-data"
},
{
"depth": 2,
"title": "Test Genesis Configuration",
"anchor": "test-genesis-configuration"
},
{
"depth": 3,
"title": "Test Genesis Setup",
"anchor": "test-genesis-setup"
},
{
"depth": 2,
"title": "Run All Tests",
"anchor": "run-all-tests"
},
{
"depth": 2,
Expand All @@ -5272,12 +5342,12 @@
}
],
"stats": {
"chars": 6892,
"words": 911,
"headings": 7,
"estimated_token_count_total": 1563
"chars": 24230,
"words": 2405,
"headings": 21,
"estimated_token_count_total": 5344
},
"hash": "sha256:8568dfa238b9a649a4e6e60510625c2e7879b76a93187b0b8b8dccf6bc467ae6",
"hash": "sha256:91981098cfa2fc26c44b817041ce5cda73c50567972407bee491cc17c45b386c",
"token_estimator": "heuristic-v1"
},
{
Expand Down Expand Up @@ -14088,12 +14158,12 @@
}
],
"stats": {
"chars": 12857,
"words": 1539,
"chars": 12200,
"words": 1502,
"headings": 6,
"estimated_token_count_total": 2929
"estimated_token_count_total": 2837
},
"hash": "sha256:df60044893f48dd7f37a11de275a16bf32adb31317ed70a789fd7fac64150e1a",
"hash": "sha256:ad43951deac53a539a3d8a2317500aec351aa7e85f3cc49b386aa30baf6bcc09",
"token_estimator": "heuristic-v1"
},
{
Expand Down

This file was deleted.

This file was deleted.

Loading
Loading