Verify first, write last ... and always test!
Write tests for a simple storage migration.
Testing a migration module inside a pallet.
When writing a runtime migration module it is important to test it to avoid any critical issues caused by mangling storage items. This guide provides a walk through of the tests to include for a simple storage migration of a single pallet, using the Nicks pallet migration from the Basic Storage Migration guide as a reference.
Refer to this guide to learn how to set up the dependencies for your test environment.
Derive the different tests that need to be included based on your pallet's functions.
For the Nicks pallet migration we need:
assert_eq!(...), constructing one of these tests looks like this:
- Migrating the Nicks pallet