Skip to content

Commit

Permalink
mdBook generated from gitorial
Browse files Browse the repository at this point in the history
  • Loading branch information
shawntabrizi committed Nov 29, 2024
1 parent 9c30dd9 commit d04fd3f
Show file tree
Hide file tree
Showing 78 changed files with 1,682 additions and 602 deletions.
44 changes: 32 additions & 12 deletions src/1/source/changes.diff
Original file line number Diff line number Diff line change
Expand Up @@ -3751,10 +3751,10 @@ index 0000000..ae8a09b
+}
diff --git a/src/tests.rs b/src/tests.rs
new file mode 100644
index 0000000..0901674
index 0000000..6d271d5
--- /dev/null
+++ b/src/tests.rs
@@ -0,0 +1,97 @@
@@ -0,0 +1,117 @@
+// Tests for the Kitties Pallet.
+//
+// Normally this file would be split into two parts: `mock.rs` and `tests.rs`.
Expand All @@ -3770,6 +3770,7 @@ index 0000000..0901674
+
+use crate as pallet_kitties;
+use crate::*;
+use frame::deps::frame_support::runtime;
+use frame::deps::sp_io;
+use frame::runtime::prelude::*;
+use frame::testing_prelude::*;
Expand All @@ -3785,16 +3786,35 @@ index 0000000..0901674
+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. PalletBalances: 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,
+ PalletBalances: pallet_balances,
+ PalletKitties: pallet_kitties,
+ }
+#[runtime]
+mod runtime {
+ #[runtime::derive(
+ RuntimeCall,
+ RuntimeEvent,
+ RuntimeError,
+ RuntimeOrigin,
+ RuntimeTask,
+ RuntimeHoldReason,
+ RuntimeFreezeReason
+ )]
+ #[runtime::runtime]
+ /// The "test runtime" that represents the state transition function for our blockchain.
+ ///
+ /// The runtime is composed of individual modules called "pallets", which you find see below.
+ /// Each pallet has its own logic and storage, all of which can be combined together.
+ pub struct TestRuntime;
+
+ /// System: Mandatory system pallet that should always be included in a FRAME runtime.
+ #[runtime::pallet_index(0)]
+ pub type System = frame_system::Pallet<Runtime>;
+
+ /// PalletBalances: Manages your blockchain's native currency. (i.e. DOT on Polkadot)
+ #[runtime::pallet_index(1)]
+ pub type PalletBalances = pallet_balances::Pallet<Runtime>;
+
+ /// PalletKitties: The pallet you are building in this tutorial!
+ #[runtime::pallet_index(2)]
+ pub type PalletKitties = pallet_kitties::Pallet<Runtime>;
+}
+
+// Normally `System` would have many more configurations, but you can see that we use some macro
Expand Down
40 changes: 30 additions & 10 deletions src/1/source/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use crate as pallet_kitties;
use crate::*;
use frame::deps::frame_support::runtime;
use frame::deps::sp_io;
use frame::runtime::prelude::*;
use frame::testing_prelude::*;
Expand All @@ -28,16 +29,35 @@ type Block = frame_system::mocking::MockBlock<TestRuntime>;
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. PalletBalances: 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,
PalletBalances: pallet_balances,
PalletKitties: pallet_kitties,
}
#[runtime]
mod runtime {
#[runtime::derive(
RuntimeCall,
RuntimeEvent,
RuntimeError,
RuntimeOrigin,
RuntimeTask,
RuntimeHoldReason,
RuntimeFreezeReason
)]
#[runtime::runtime]
/// The "test runtime" that represents the state transition function for our blockchain.
///
/// The runtime is composed of individual modules called "pallets", which you find see below.
/// Each pallet has its own logic and storage, all of which can be combined together.
pub struct TestRuntime;

/// System: Mandatory system pallet that should always be included in a FRAME runtime.
#[runtime::pallet_index(0)]
pub type System = frame_system::Pallet<Runtime>;

/// PalletBalances: Manages your blockchain's native currency. (i.e. DOT on Polkadot)
#[runtime::pallet_index(1)]
pub type PalletBalances = pallet_balances::Pallet<Runtime>;

/// PalletKitties: The pallet you are building in this tutorial!
#[runtime::pallet_index(2)]
pub type PalletKitties = pallet_kitties::Pallet<Runtime>;
}

// Normally `System` would have many more configurations, but you can see that we use some macro
Expand Down
40 changes: 30 additions & 10 deletions src/10/source/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use crate as pallet_kitties;
use crate::*;
use frame::deps::frame_support::runtime;
use frame::deps::sp_io;
use frame::runtime::prelude::*;
use frame::testing_prelude::*;
Expand All @@ -28,16 +29,35 @@ type Block = frame_system::mocking::MockBlock<TestRuntime>;
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. PalletBalances: 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,
PalletBalances: pallet_balances,
PalletKitties: pallet_kitties,
}
#[runtime]
mod runtime {
#[runtime::derive(
RuntimeCall,
RuntimeEvent,
RuntimeError,
RuntimeOrigin,
RuntimeTask,
RuntimeHoldReason,
RuntimeFreezeReason
)]
#[runtime::runtime]
/// The "test runtime" that represents the state transition function for our blockchain.
///
/// The runtime is composed of individual modules called "pallets", which you find see below.
/// Each pallet has its own logic and storage, all of which can be combined together.
pub struct TestRuntime;

/// System: Mandatory system pallet that should always be included in a FRAME runtime.
#[runtime::pallet_index(0)]
pub type System = frame_system::Pallet<Runtime>;

/// PalletBalances: Manages your blockchain's native currency. (i.e. DOT on Polkadot)
#[runtime::pallet_index(1)]
pub type PalletBalances = pallet_balances::Pallet<Runtime>;

/// PalletKitties: The pallet you are building in this tutorial!
#[runtime::pallet_index(2)]
pub type PalletKitties = pallet_kitties::Pallet<Runtime>;
}

// Normally `System` would have many more configurations, but you can see that we use some macro
Expand Down
4 changes: 2 additions & 2 deletions src/11/solution/solution.diff
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ index 7d88fff..90242f6 100644
#[pallet::event]
#[pallet::generate_deposit(pub(super) fn deposit_event)]
diff --git a/src/tests.rs b/src/tests.rs
index 2526de8..7713826 100644
index 8baa63c..6f68640 100644
--- a/src/tests.rs
+++ b/src/tests.rs
@@ -117,3 +117,17 @@ fn create_kitty_emits_event() {
@@ -137,3 +137,17 @@ fn create_kitty_emits_event() {
System::assert_last_event(Event::<TestRuntime>::Created { owner: 1 }.into());
})
}
Expand Down
40 changes: 30 additions & 10 deletions src/11/solution/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use crate as pallet_kitties;
use crate::*;
use frame::deps::frame_support::runtime;
use frame::deps::sp_io;
use frame::runtime::prelude::*;
use frame::testing_prelude::*;
Expand All @@ -28,16 +29,35 @@ type Block = frame_system::mocking::MockBlock<TestRuntime>;
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. PalletBalances: 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,
PalletBalances: pallet_balances,
PalletKitties: pallet_kitties,
}
#[runtime]
mod runtime {
#[runtime::derive(
RuntimeCall,
RuntimeEvent,
RuntimeError,
RuntimeOrigin,
RuntimeTask,
RuntimeHoldReason,
RuntimeFreezeReason
)]
#[runtime::runtime]
/// The "test runtime" that represents the state transition function for our blockchain.
///
/// The runtime is composed of individual modules called "pallets", which you find see below.
/// Each pallet has its own logic and storage, all of which can be combined together.
pub struct TestRuntime;

/// System: Mandatory system pallet that should always be included in a FRAME runtime.
#[runtime::pallet_index(0)]
pub type System = frame_system::Pallet<Runtime>;

/// PalletBalances: Manages your blockchain's native currency. (i.e. DOT on Polkadot)
#[runtime::pallet_index(1)]
pub type PalletBalances = pallet_balances::Pallet<Runtime>;

/// PalletKitties: The pallet you are building in this tutorial!
#[runtime::pallet_index(2)]
pub type PalletKitties = pallet_kitties::Pallet<Runtime>;
}

// Normally `System` would have many more configurations, but you can see that we use some macro
Expand Down
40 changes: 30 additions & 10 deletions src/11/template/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use crate as pallet_kitties;
use crate::*;
use frame::deps::frame_support::runtime;
use frame::deps::sp_io;
use frame::runtime::prelude::*;
use frame::testing_prelude::*;
Expand All @@ -28,16 +29,35 @@ type Block = frame_system::mocking::MockBlock<TestRuntime>;
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. PalletBalances: 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,
PalletBalances: pallet_balances,
PalletKitties: pallet_kitties,
}
#[runtime]
mod runtime {
#[runtime::derive(
RuntimeCall,
RuntimeEvent,
RuntimeError,
RuntimeOrigin,
RuntimeTask,
RuntimeHoldReason,
RuntimeFreezeReason
)]
#[runtime::runtime]
/// The "test runtime" that represents the state transition function for our blockchain.
///
/// The runtime is composed of individual modules called "pallets", which you find see below.
/// Each pallet has its own logic and storage, all of which can be combined together.
pub struct TestRuntime;

/// System: Mandatory system pallet that should always be included in a FRAME runtime.
#[runtime::pallet_index(0)]
pub type System = frame_system::Pallet<Runtime>;

/// PalletBalances: Manages your blockchain's native currency. (i.e. DOT on Polkadot)
#[runtime::pallet_index(1)]
pub type PalletBalances = pallet_balances::Pallet<Runtime>;

/// PalletKitties: The pallet you are building in this tutorial!
#[runtime::pallet_index(2)]
pub type PalletKitties = pallet_kitties::Pallet<Runtime>;
}

// Normally `System` would have many more configurations, but you can see that we use some macro
Expand Down
4 changes: 2 additions & 2 deletions src/12/solution/solution.diff
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ index b396f98..9739330 100644
Ok(())
}
diff --git a/src/tests.rs b/src/tests.rs
index 7713826..6de2fcc 100644
index 6f68640..a396679 100644
--- a/src/tests.rs
+++ b/src/tests.rs
@@ -131,3 +131,15 @@ fn count_for_kitties_created_correctly() {
@@ -151,3 +151,15 @@ fn count_for_kitties_created_correctly() {
assert_eq!(CountForKitties::<TestRuntime>::get(), Some(1337u32));
})
}
Expand Down
40 changes: 30 additions & 10 deletions src/12/solution/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use crate as pallet_kitties;
use crate::*;
use frame::deps::frame_support::runtime;
use frame::deps::sp_io;
use frame::runtime::prelude::*;
use frame::testing_prelude::*;
Expand All @@ -28,16 +29,35 @@ type Block = frame_system::mocking::MockBlock<TestRuntime>;
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. PalletBalances: 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,
PalletBalances: pallet_balances,
PalletKitties: pallet_kitties,
}
#[runtime]
mod runtime {
#[runtime::derive(
RuntimeCall,
RuntimeEvent,
RuntimeError,
RuntimeOrigin,
RuntimeTask,
RuntimeHoldReason,
RuntimeFreezeReason
)]
#[runtime::runtime]
/// The "test runtime" that represents the state transition function for our blockchain.
///
/// The runtime is composed of individual modules called "pallets", which you find see below.
/// Each pallet has its own logic and storage, all of which can be combined together.
pub struct TestRuntime;

/// System: Mandatory system pallet that should always be included in a FRAME runtime.
#[runtime::pallet_index(0)]
pub type System = frame_system::Pallet<Runtime>;

/// PalletBalances: Manages your blockchain's native currency. (i.e. DOT on Polkadot)
#[runtime::pallet_index(1)]
pub type PalletBalances = pallet_balances::Pallet<Runtime>;

/// PalletKitties: The pallet you are building in this tutorial!
#[runtime::pallet_index(2)]
pub type PalletKitties = pallet_kitties::Pallet<Runtime>;
}

// Normally `System` would have many more configurations, but you can see that we use some macro
Expand Down
Loading

0 comments on commit d04fd3f

Please sign in to comment.