From 3d9c9596d44e3a6175dedcc5f559263e42507696 Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Fri, 13 Sep 2024 19:31:06 -0400 Subject: [PATCH] more tests documentation --- steps/1/src/tests.rs | 14 ++++++++++++++ steps/10/src/tests.rs | 14 ++++++++++++++ steps/11/src/tests.rs | 14 ++++++++++++++ steps/12/src/tests.rs | 14 ++++++++++++++ steps/13/src/tests.rs | 14 ++++++++++++++ steps/14/src/tests.rs | 14 ++++++++++++++ steps/15/src/tests.rs | 14 ++++++++++++++ steps/16/src/tests.rs | 14 ++++++++++++++ steps/17/src/tests.rs | 14 ++++++++++++++ steps/18/src/tests.rs | 14 ++++++++++++++ steps/19/src/tests.rs | 14 ++++++++++++++ steps/2/src/tests.rs | 14 ++++++++++++++ steps/20/src/tests.rs | 14 ++++++++++++++ steps/21/src/tests.rs | 14 ++++++++++++++ steps/22/src/tests.rs | 14 ++++++++++++++ steps/23/src/tests.rs | 14 ++++++++++++++ steps/24/src/tests.rs | 14 ++++++++++++++ steps/25/src/tests.rs | 14 ++++++++++++++ steps/26/src/tests.rs | 14 ++++++++++++++ steps/27/src/tests.rs | 14 ++++++++++++++ steps/28/src/tests.rs | 14 ++++++++++++++ steps/29/src/tests.rs | 14 ++++++++++++++ steps/3/src/tests.rs | 14 ++++++++++++++ steps/30/src/tests.rs | 14 ++++++++++++++ steps/31/src/tests.rs | 14 ++++++++++++++ steps/32/src/tests.rs | 14 ++++++++++++++ steps/33/src/tests.rs | 14 ++++++++++++++ steps/34/src/tests.rs | 14 ++++++++++++++ steps/35/src/tests.rs | 14 ++++++++++++++ steps/36/src/tests.rs | 14 ++++++++++++++ steps/37/src/tests.rs | 14 ++++++++++++++ steps/38/src/tests.rs | 14 ++++++++++++++ steps/39/src/tests.rs | 14 ++++++++++++++ steps/4/src/tests.rs | 14 ++++++++++++++ steps/40/src/tests.rs | 14 ++++++++++++++ steps/41/src/tests.rs | 14 ++++++++++++++ steps/42/src/tests.rs | 14 ++++++++++++++ steps/43/src/tests.rs | 14 ++++++++++++++ steps/44/src/tests.rs | 14 ++++++++++++++ steps/45/src/tests.rs | 14 ++++++++++++++ steps/46/src/tests.rs | 14 ++++++++++++++ steps/47/src/tests.rs | 14 ++++++++++++++ steps/48/src/tests.rs | 14 ++++++++++++++ steps/49/src/tests.rs | 14 ++++++++++++++ steps/5/src/tests.rs | 14 ++++++++++++++ steps/50/src/tests.rs | 14 ++++++++++++++ steps/51/src/tests.rs | 14 ++++++++++++++ steps/52/src/tests.rs | 14 ++++++++++++++ steps/53/src/tests.rs | 14 ++++++++++++++ steps/54/src/tests.rs | 14 ++++++++++++++ steps/6/src/tests.rs | 14 ++++++++++++++ steps/7/src/tests.rs | 14 ++++++++++++++ steps/8/src/tests.rs | 14 ++++++++++++++ steps/9/src/tests.rs | 14 ++++++++++++++ 54 files changed, 756 insertions(+) diff --git a/steps/1/src/tests.rs b/steps/1/src/tests.rs index efdf1bd3..375cd3f4 100644 --- a/steps/1/src/tests.rs +++ b/steps/1/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/10/src/tests.rs b/steps/10/src/tests.rs index 7232fd0a..8fa3dc60 100644 --- a/steps/10/src/tests.rs +++ b/steps/10/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/11/src/tests.rs b/steps/11/src/tests.rs index 7232fd0a..8fa3dc60 100644 --- a/steps/11/src/tests.rs +++ b/steps/11/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/12/src/tests.rs b/steps/12/src/tests.rs index 7232fd0a..8fa3dc60 100644 --- a/steps/12/src/tests.rs +++ b/steps/12/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/13/src/tests.rs b/steps/13/src/tests.rs index 435847d8..d3e7ab78 100644 --- a/steps/13/src/tests.rs +++ b/steps/13/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/14/src/tests.rs b/steps/14/src/tests.rs index 435847d8..d3e7ab78 100644 --- a/steps/14/src/tests.rs +++ b/steps/14/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/15/src/tests.rs b/steps/15/src/tests.rs index c3b31004..6318ca0b 100644 --- a/steps/15/src/tests.rs +++ b/steps/15/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/16/src/tests.rs b/steps/16/src/tests.rs index c3b31004..6318ca0b 100644 --- a/steps/16/src/tests.rs +++ b/steps/16/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/17/src/tests.rs b/steps/17/src/tests.rs index 9fb65844..5e74d29a 100644 --- a/steps/17/src/tests.rs +++ b/steps/17/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/18/src/tests.rs b/steps/18/src/tests.rs index 9fb65844..5e74d29a 100644 --- a/steps/18/src/tests.rs +++ b/steps/18/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/19/src/tests.rs b/steps/19/src/tests.rs index 840d7790..6f6a0f90 100644 --- a/steps/19/src/tests.rs +++ b/steps/19/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/2/src/tests.rs b/steps/2/src/tests.rs index efdf1bd3..375cd3f4 100644 --- a/steps/2/src/tests.rs +++ b/steps/2/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/20/src/tests.rs b/steps/20/src/tests.rs index 840d7790..6f6a0f90 100644 --- a/steps/20/src/tests.rs +++ b/steps/20/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/21/src/tests.rs b/steps/21/src/tests.rs index 1f0d7b0a..bd27a534 100644 --- a/steps/21/src/tests.rs +++ b/steps/21/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/22/src/tests.rs b/steps/22/src/tests.rs index 1f0d7b0a..bd27a534 100644 --- a/steps/22/src/tests.rs +++ b/steps/22/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/23/src/tests.rs b/steps/23/src/tests.rs index 166e629b..209251c5 100644 --- a/steps/23/src/tests.rs +++ b/steps/23/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/24/src/tests.rs b/steps/24/src/tests.rs index 166e629b..209251c5 100644 --- a/steps/24/src/tests.rs +++ b/steps/24/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/25/src/tests.rs b/steps/25/src/tests.rs index 88db00a4..05c8f2d1 100644 --- a/steps/25/src/tests.rs +++ b/steps/25/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/26/src/tests.rs b/steps/26/src/tests.rs index 88db00a4..05c8f2d1 100644 --- a/steps/26/src/tests.rs +++ b/steps/26/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/27/src/tests.rs b/steps/27/src/tests.rs index 88db00a4..05c8f2d1 100644 --- a/steps/27/src/tests.rs +++ b/steps/27/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/28/src/tests.rs b/steps/28/src/tests.rs index 39747e26..16e7943c 100644 --- a/steps/28/src/tests.rs +++ b/steps/28/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/29/src/tests.rs b/steps/29/src/tests.rs index 39747e26..16e7943c 100644 --- a/steps/29/src/tests.rs +++ b/steps/29/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/3/src/tests.rs b/steps/3/src/tests.rs index efdf1bd3..375cd3f4 100644 --- a/steps/3/src/tests.rs +++ b/steps/3/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/30/src/tests.rs b/steps/30/src/tests.rs index 16cc0882..b36fc983 100644 --- a/steps/30/src/tests.rs +++ b/steps/30/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1 }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,22 +41,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/31/src/tests.rs b/steps/31/src/tests.rs index 16cc0882..b36fc983 100644 --- a/steps/31/src/tests.rs +++ b/steps/31/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1 }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,22 +41,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/32/src/tests.rs b/steps/32/src/tests.rs index 342c0c0d..349005a8 100644 --- a/steps/32/src/tests.rs +++ b/steps/32/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1 }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,22 +41,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/33/src/tests.rs b/steps/33/src/tests.rs index 342c0c0d..349005a8 100644 --- a/steps/33/src/tests.rs +++ b/steps/33/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1 }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,22 +41,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/34/src/tests.rs b/steps/34/src/tests.rs index 87fe23e9..49760074 100644 --- a/steps/34/src/tests.rs +++ b/steps/34/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1 }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,22 +41,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/35/src/tests.rs b/steps/35/src/tests.rs index 87fe23e9..49760074 100644 --- a/steps/35/src/tests.rs +++ b/steps/35/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1 }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,22 +41,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/36/src/tests.rs b/steps/36/src/tests.rs index 5e3ffb8c..c3e66b50 100644 --- a/steps/36/src/tests.rs +++ b/steps/36/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1 }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,22 +41,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/37/src/tests.rs b/steps/37/src/tests.rs index 5e3ffb8c..c3e66b50 100644 --- a/steps/37/src/tests.rs +++ b/steps/37/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1 }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,22 +41,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/38/src/tests.rs b/steps/38/src/tests.rs index 5e3ffb8c..c3e66b50 100644 --- a/steps/38/src/tests.rs +++ b/steps/38/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1 }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,22 +41,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/39/src/tests.rs b/steps/39/src/tests.rs index f290fdf5..22e93172 100644 --- a/steps/39/src/tests.rs +++ b/steps/39/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1 }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,22 +41,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/4/src/tests.rs b/steps/4/src/tests.rs index efdf1bd3..375cd3f4 100644 --- a/steps/4/src/tests.rs +++ b/steps/4/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/40/src/tests.rs b/steps/40/src/tests.rs index f290fdf5..22e93172 100644 --- a/steps/40/src/tests.rs +++ b/steps/40/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1 }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,22 +41,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/41/src/tests.rs b/steps/41/src/tests.rs index 852cb115..71ad136d 100644 --- a/steps/41/src/tests.rs +++ b/steps/41/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1 }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,22 +41,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/42/src/tests.rs b/steps/42/src/tests.rs index 852cb115..71ad136d 100644 --- a/steps/42/src/tests.rs +++ b/steps/42/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1 }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,22 +41,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/43/src/tests.rs b/steps/43/src/tests.rs index 3a2dabf3..95ed12eb 100644 --- a/steps/43/src/tests.rs +++ b/steps/43/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1 }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,23 +41,33 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; type NativeBalance = Balances; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/44/src/tests.rs b/steps/44/src/tests.rs index 3a2dabf3..95ed12eb 100644 --- a/steps/44/src/tests.rs +++ b/steps/44/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1 }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,23 +41,33 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; type NativeBalance = Balances; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/45/src/tests.rs b/steps/45/src/tests.rs index 13ba065a..a0bb6cfc 100644 --- a/steps/45/src/tests.rs +++ b/steps/45/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1, price: None }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,23 +41,33 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; type NativeBalance = Balances; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/46/src/tests.rs b/steps/46/src/tests.rs index 13ba065a..a0bb6cfc 100644 --- a/steps/46/src/tests.rs +++ b/steps/46/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1, price: None }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,23 +41,33 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; type NativeBalance = Balances; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/47/src/tests.rs b/steps/47/src/tests.rs index a5d52822..8a99f4c1 100644 --- a/steps/47/src/tests.rs +++ b/steps/47/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1, price: None }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,23 +41,33 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; type NativeBalance = Balances; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/48/src/tests.rs b/steps/48/src/tests.rs index a5d52822..8a99f4c1 100644 --- a/steps/48/src/tests.rs +++ b/steps/48/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1, price: None }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,23 +41,33 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; type NativeBalance = Balances; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/49/src/tests.rs b/steps/49/src/tests.rs index d6ba48b9..4a71e26a 100644 --- a/steps/49/src/tests.rs +++ b/steps/49/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1, price: None }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,23 +41,33 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; type NativeBalance = Balances; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/5/src/tests.rs b/steps/5/src/tests.rs index efdf1bd3..375cd3f4 100644 --- a/steps/5/src/tests.rs +++ b/steps/5/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/50/src/tests.rs b/steps/50/src/tests.rs index d6ba48b9..4a71e26a 100644 --- a/steps/50/src/tests.rs +++ b/steps/50/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1, price: None }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,23 +41,33 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; type NativeBalance = Balances; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/51/src/tests.rs b/steps/51/src/tests.rs index a1b784d6..c7dbc15d 100644 --- a/steps/51/src/tests.rs +++ b/steps/51/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1, price: None }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,23 +41,33 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; type NativeBalance = Balances; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/52/src/tests.rs b/steps/52/src/tests.rs index a1b784d6..c7dbc15d 100644 --- a/steps/52/src/tests.rs +++ b/steps/52/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1, price: None }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,23 +41,33 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; type NativeBalance = Balances; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/53/src/tests.rs b/steps/53/src/tests.rs index 728614ee..c2b41a6d 100644 --- a/steps/53/src/tests.rs +++ b/steps/53/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1, price: None }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,23 +41,33 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; type NativeBalance = Balances; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/54/src/tests.rs b/steps/54/src/tests.rs index 728614ee..c2b41a6d 100644 --- a/steps/54/src/tests.rs +++ b/steps/54/src/tests.rs @@ -29,6 +29,10 @@ const ALICE: u64 = 1; const BOB: u64 = 2; const DEFAULT_KITTY: Kitty = Kitty { dna: [0u8; 32], owner: 1, price: None }; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -37,23 +41,33 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; type NativeBalance = Balances; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/6/src/tests.rs b/steps/6/src/tests.rs index efdf1bd3..375cd3f4 100644 --- a/steps/6/src/tests.rs +++ b/steps/6/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/7/src/tests.rs b/steps/7/src/tests.rs index 4e6382a3..c2140eda 100644 --- a/steps/7/src/tests.rs +++ b/steps/7/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/8/src/tests.rs b/steps/8/src/tests.rs index 4e6382a3..c2140eda 100644 --- a/steps/8/src/tests.rs +++ b/steps/8/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage() diff --git a/steps/9/src/tests.rs b/steps/9/src/tests.rs index 7232fd0a..8fa3dc60 100644 --- a/steps/9/src/tests.rs +++ b/steps/9/src/tests.rs @@ -28,6 +28,10 @@ type Block = frame_system::mocking::MockBlock; const ALICE: u64 = 1; const BOB: u64 = 2; +// Our blockchain tests only need 3 Pallets: +// 1. System: Which is included with every FRAME runtime. +// 2. Balances: Which is manages your blockchain's native currency. (i.e. DOT on Polkadot) +// 3. PalletKitties: The pallet you are building in this tutorial! construct_runtime! { pub struct TestRuntime { System: frame_system, @@ -36,22 +40,32 @@ construct_runtime! { } } +// Normally `System` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(frame_system::config_preludes::TestDefaultConfig)] impl frame_system::Config for TestRuntime { type Block = Block; type AccountData = pallet_balances::AccountData; } +// Normally `Balances` would have many more configurations, but you can see that we use some macro +// magic to automatically configure most of the pallet for a "default test configuration". #[derive_impl(pallet_balances::config_preludes::TestDefaultConfig)] impl pallet_balances::Config for TestRuntime { type AccountStore = System; type Balance = Balance; } +// This is the configuration of our Pallet! If you make changes to the pallet's `trait Config`, you +// will also need to update this configuration to represent that. impl pallet_kitties::Config for TestRuntime { type RuntimeEvent = RuntimeEvent; } +// We need to run most of our tests using this function: `new_test_ext().execute_with(|| { ... });` +// It simulates the blockchain database backend for our tests. +// If you forget to include this and try to access your Pallet storage, you will get an error like: +// "`get_version_1` called outside of an Externalities-provided environment." pub fn new_test_ext() -> sp_io::TestExternalities { frame_system::GenesisConfig::::default() .build_storage()