Skip to content

Commit

Permalink
update to use ALICE and add tests section to step 7
Browse files Browse the repository at this point in the history
  • Loading branch information
shawntabrizi committed Sep 13, 2024
1 parent 2484dce commit 0a1604d
Show file tree
Hide file tree
Showing 49 changed files with 259 additions and 251 deletions.
4 changes: 2 additions & 2 deletions steps/10/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn system_and_balances_work() {
fn create_kitty_checks_signed() {
new_test_ext().execute_with(|| {
// The `create_kitty` extrinsic should work when being called by a user.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// The `create_kitty` extrinsic should fail when being called by an unsigned message.
assert_noop!(PalletKitties::create_kitty(RuntimeOrigin::none()), DispatchError::BadOrigin);
})
Expand All @@ -94,7 +94,7 @@ fn create_kitty_emits_event() {
// We need to set block number to 1 to view events.
System::set_block_number(1);
// Execute our call, and ensure it is successful.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// Assert the last event by our blockchain is the `Created` event with the correct owner.
System::assert_last_event(Event::<TestRuntime>::Created { owner: 1 }.into());
})
Expand Down
4 changes: 2 additions & 2 deletions steps/11/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn system_and_balances_work() {
fn create_kitty_checks_signed() {
new_test_ext().execute_with(|| {
// The `create_kitty` extrinsic should work when being called by a user.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// The `create_kitty` extrinsic should fail when being called by an unsigned message.
assert_noop!(PalletKitties::create_kitty(RuntimeOrigin::none()), DispatchError::BadOrigin);
})
Expand All @@ -94,7 +94,7 @@ fn create_kitty_emits_event() {
// We need to set block number to 1 to view events.
System::set_block_number(1);
// Execute our call, and ensure it is successful.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// Assert the last event by our blockchain is the `Created` event with the correct owner.
System::assert_last_event(Event::<TestRuntime>::Created { owner: 1 }.into());
})
Expand Down
4 changes: 2 additions & 2 deletions steps/12/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn system_and_balances_work() {
fn create_kitty_checks_signed() {
new_test_ext().execute_with(|| {
// The `create_kitty` extrinsic should work when being called by a user.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// The `create_kitty` extrinsic should fail when being called by an unsigned message.
assert_noop!(PalletKitties::create_kitty(RuntimeOrigin::none()), DispatchError::BadOrigin);
})
Expand All @@ -94,7 +94,7 @@ fn create_kitty_emits_event() {
// We need to set block number to 1 to view events.
System::set_block_number(1);
// Execute our call, and ensure it is successful.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// Assert the last event by our blockchain is the `Created` event with the correct owner.
System::assert_last_event(Event::<TestRuntime>::Created { owner: 1 }.into());
})
Expand Down
4 changes: 2 additions & 2 deletions steps/13/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn system_and_balances_work() {
fn create_kitty_checks_signed() {
new_test_ext().execute_with(|| {
// The `create_kitty` extrinsic should work when being called by a user.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// The `create_kitty` extrinsic should fail when being called by an unsigned message.
assert_noop!(PalletKitties::create_kitty(RuntimeOrigin::none()), DispatchError::BadOrigin);
})
Expand All @@ -94,7 +94,7 @@ fn create_kitty_emits_event() {
// We need to set block number to 1 to view events.
System::set_block_number(1);
// Execute our call, and ensure it is successful.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// Assert the last event by our blockchain is the `Created` event with the correct owner.
System::assert_last_event(Event::<TestRuntime>::Created { owner: 1 }.into());
})
Expand Down
4 changes: 2 additions & 2 deletions steps/14/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn system_and_balances_work() {
fn create_kitty_checks_signed() {
new_test_ext().execute_with(|| {
// The `create_kitty` extrinsic should work when being called by a user.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// The `create_kitty` extrinsic should fail when being called by an unsigned message.
assert_noop!(PalletKitties::create_kitty(RuntimeOrigin::none()), DispatchError::BadOrigin);
})
Expand All @@ -94,7 +94,7 @@ fn create_kitty_emits_event() {
// We need to set block number to 1 to view events.
System::set_block_number(1);
// Execute our call, and ensure it is successful.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// Assert the last event by our blockchain is the `Created` event with the correct owner.
System::assert_last_event(Event::<TestRuntime>::Created { owner: 1 }.into());
})
Expand Down
6 changes: 3 additions & 3 deletions steps/15/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn system_and_balances_work() {
fn create_kitty_checks_signed() {
new_test_ext().execute_with(|| {
// The `create_kitty` extrinsic should work when being called by a user.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// The `create_kitty` extrinsic should fail when being called by an unsigned message.
assert_noop!(PalletKitties::create_kitty(RuntimeOrigin::none()), DispatchError::BadOrigin);
})
Expand All @@ -94,7 +94,7 @@ fn create_kitty_emits_event() {
// We need to set block number to 1 to view events.
System::set_block_number(1);
// Execute our call, and ensure it is successful.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// Assert the last event by our blockchain is the `Created` event with the correct owner.
System::assert_last_event(Event::<TestRuntime>::Created { owner: 1 }.into());
})
Expand All @@ -118,7 +118,7 @@ fn mint_increments_count_for_kitty() {
// Querying storage before anything is set will return `None`.
assert_eq!(CountForKitties::<TestRuntime>::get(), None);
// Call `create_kitty` which will call `mint`.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// Now the storage should be `Some(1)`
assert_eq!(CountForKitties::<TestRuntime>::get(), Some(1));
})
Expand Down
6 changes: 3 additions & 3 deletions steps/16/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn system_and_balances_work() {
fn create_kitty_checks_signed() {
new_test_ext().execute_with(|| {
// The `create_kitty` extrinsic should work when being called by a user.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// The `create_kitty` extrinsic should fail when being called by an unsigned message.
assert_noop!(PalletKitties::create_kitty(RuntimeOrigin::none()), DispatchError::BadOrigin);
})
Expand All @@ -94,7 +94,7 @@ fn create_kitty_emits_event() {
// We need to set block number to 1 to view events.
System::set_block_number(1);
// Execute our call, and ensure it is successful.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// Assert the last event by our blockchain is the `Created` event with the correct owner.
System::assert_last_event(Event::<TestRuntime>::Created { owner: 1 }.into());
})
Expand All @@ -118,7 +118,7 @@ fn mint_increments_count_for_kitty() {
// Querying storage before anything is set will return `None`.
assert_eq!(CountForKitties::<TestRuntime>::get(), None);
// Call `create_kitty` which will call `mint`.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// Now the storage should be `Some(1)`
assert_eq!(CountForKitties::<TestRuntime>::get(), Some(1));
})
Expand Down
6 changes: 3 additions & 3 deletions steps/17/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn system_and_balances_work() {
fn create_kitty_checks_signed() {
new_test_ext().execute_with(|| {
// The `create_kitty` extrinsic should work when being called by a user.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// The `create_kitty` extrinsic should fail when being called by an unsigned message.
assert_noop!(PalletKitties::create_kitty(RuntimeOrigin::none()), DispatchError::BadOrigin);
})
Expand All @@ -94,7 +94,7 @@ fn create_kitty_emits_event() {
// We need to set block number to 1 to view events.
System::set_block_number(1);
// Execute our call, and ensure it is successful.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// Assert the last event by our blockchain is the `Created` event with the correct owner.
System::assert_last_event(Event::<TestRuntime>::Created { owner: 1 }.into());
})
Expand All @@ -118,7 +118,7 @@ fn mint_increments_count_for_kitty() {
// Querying storage before anything is set will return `None`.
assert_eq!(CountForKitties::<TestRuntime>::get(), None);
// Call `create_kitty` which will call `mint`.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// Now the storage should be `Some(1)`
assert_eq!(CountForKitties::<TestRuntime>::get(), Some(1));
})
Expand Down
6 changes: 3 additions & 3 deletions steps/18/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn system_and_balances_work() {
fn create_kitty_checks_signed() {
new_test_ext().execute_with(|| {
// The `create_kitty` extrinsic should work when being called by a user.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// The `create_kitty` extrinsic should fail when being called by an unsigned message.
assert_noop!(PalletKitties::create_kitty(RuntimeOrigin::none()), DispatchError::BadOrigin);
})
Expand All @@ -94,7 +94,7 @@ fn create_kitty_emits_event() {
// We need to set block number to 1 to view events.
System::set_block_number(1);
// Execute our call, and ensure it is successful.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// Assert the last event by our blockchain is the `Created` event with the correct owner.
System::assert_last_event(Event::<TestRuntime>::Created { owner: 1 }.into());
})
Expand All @@ -118,7 +118,7 @@ fn mint_increments_count_for_kitty() {
// Querying storage before anything is set will return `None`.
assert_eq!(CountForKitties::<TestRuntime>::get(), None);
// Call `create_kitty` which will call `mint`.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// Now the storage should be `Some(1)`
assert_eq!(CountForKitties::<TestRuntime>::get(), Some(1));
})
Expand Down
6 changes: 3 additions & 3 deletions steps/19/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn system_and_balances_work() {
fn create_kitty_checks_signed() {
new_test_ext().execute_with(|| {
// The `create_kitty` extrinsic should work when being called by a user.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// The `create_kitty` extrinsic should fail when being called by an unsigned message.
assert_noop!(PalletKitties::create_kitty(RuntimeOrigin::none()), DispatchError::BadOrigin);
})
Expand All @@ -94,7 +94,7 @@ fn create_kitty_emits_event() {
// We need to set block number to 1 to view events.
System::set_block_number(1);
// Execute our call, and ensure it is successful.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// Assert the last event by our blockchain is the `Created` event with the correct owner.
System::assert_last_event(Event::<TestRuntime>::Created { owner: 1 }.into());
})
Expand All @@ -118,7 +118,7 @@ fn mint_increments_count_for_kitty() {
// Querying storage before anything is set will return `0`.
assert_eq!(CountForKitties::<TestRuntime>::get(), 0);
// Call `create_kitty` which will call `mint`.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// Now the storage should be `Some(1)`
assert_eq!(CountForKitties::<TestRuntime>::get(), 1);
})
Expand Down
6 changes: 3 additions & 3 deletions steps/20/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn system_and_balances_work() {
fn create_kitty_checks_signed() {
new_test_ext().execute_with(|| {
// The `create_kitty` extrinsic should work when being called by a user.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// The `create_kitty` extrinsic should fail when being called by an unsigned message.
assert_noop!(PalletKitties::create_kitty(RuntimeOrigin::none()), DispatchError::BadOrigin);
})
Expand All @@ -94,7 +94,7 @@ fn create_kitty_emits_event() {
// We need to set block number to 1 to view events.
System::set_block_number(1);
// Execute our call, and ensure it is successful.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// Assert the last event by our blockchain is the `Created` event with the correct owner.
System::assert_last_event(Event::<TestRuntime>::Created { owner: 1 }.into());
})
Expand All @@ -118,7 +118,7 @@ fn mint_increments_count_for_kitty() {
// Querying storage before anything is set will return `0`.
assert_eq!(CountForKitties::<TestRuntime>::get(), 0);
// Call `create_kitty` which will call `mint`.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// Now the storage should be `Some(1)`
assert_eq!(CountForKitties::<TestRuntime>::get(), 1);
})
Expand Down
6 changes: 3 additions & 3 deletions steps/21/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn system_and_balances_work() {
fn create_kitty_checks_signed() {
new_test_ext().execute_with(|| {
// The `create_kitty` extrinsic should work when being called by a user.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// The `create_kitty` extrinsic should fail when being called by an unsigned message.
assert_noop!(PalletKitties::create_kitty(RuntimeOrigin::none()), DispatchError::BadOrigin);
})
Expand All @@ -94,7 +94,7 @@ fn create_kitty_emits_event() {
// We need to set block number to 1 to view events.
System::set_block_number(1);
// Execute our call, and ensure it is successful.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// Assert the last event by our blockchain is the `Created` event with the correct owner.
System::assert_last_event(Event::<TestRuntime>::Created { owner: 1 }.into());
})
Expand All @@ -118,7 +118,7 @@ fn mint_increments_count_for_kitty() {
// Querying storage before anything is set will return `0`.
assert_eq!(CountForKitties::<TestRuntime>::get(), 0);
// Call `create_kitty` which will call `mint`.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// Now the storage should be `Some(1)`
assert_eq!(CountForKitties::<TestRuntime>::get(), 1);
})
Expand Down
6 changes: 3 additions & 3 deletions steps/22/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn system_and_balances_work() {
fn create_kitty_checks_signed() {
new_test_ext().execute_with(|| {
// The `create_kitty` extrinsic should work when being called by a user.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// The `create_kitty` extrinsic should fail when being called by an unsigned message.
assert_noop!(PalletKitties::create_kitty(RuntimeOrigin::none()), DispatchError::BadOrigin);
})
Expand All @@ -94,7 +94,7 @@ fn create_kitty_emits_event() {
// We need to set block number to 1 to view events.
System::set_block_number(1);
// Execute our call, and ensure it is successful.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// Assert the last event by our blockchain is the `Created` event with the correct owner.
System::assert_last_event(Event::<TestRuntime>::Created { owner: 1 }.into());
})
Expand All @@ -118,7 +118,7 @@ fn mint_increments_count_for_kitty() {
// Querying storage before anything is set will return `0`.
assert_eq!(CountForKitties::<TestRuntime>::get(), 0);
// Call `create_kitty` which will call `mint`.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// Now the storage should be `Some(1)`
assert_eq!(CountForKitties::<TestRuntime>::get(), 1);
})
Expand Down
8 changes: 4 additions & 4 deletions steps/23/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn system_and_balances_work() {
fn create_kitty_checks_signed() {
new_test_ext().execute_with(|| {
// The `create_kitty` extrinsic should work when being called by a user.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// The `create_kitty` extrinsic should fail when being called by an unsigned message.
assert_noop!(PalletKitties::create_kitty(RuntimeOrigin::none()), DispatchError::BadOrigin);
})
Expand All @@ -94,7 +94,7 @@ fn create_kitty_emits_event() {
// We need to set block number to 1 to view events.
System::set_block_number(1);
// Execute our call, and ensure it is successful.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// Assert the last event by our blockchain is the `Created` event with the correct owner.
System::assert_last_event(Event::<TestRuntime>::Created { owner: 1 }.into());
})
Expand All @@ -118,7 +118,7 @@ fn mint_increments_count_for_kitty() {
// Querying storage before anything is set will return `0`.
assert_eq!(CountForKitties::<TestRuntime>::get(), 0);
// Call `create_kitty` which will call `mint`.
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
// Now the storage should be `Some(1)`
assert_eq!(CountForKitties::<TestRuntime>::get(), 1);
})
Expand Down Expand Up @@ -150,7 +150,7 @@ fn kitties_map_created_correctly() {
#[test]
fn create_kitty_adds_to_map() {
new_test_ext().execute_with(|| {
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(1)));
assert_ok!(PalletKitties::create_kitty(RuntimeOrigin::signed(ALICE)));
assert_eq!(Kitties::<TestRuntime>::iter().count(), 1);
})
}
Loading

0 comments on commit 0a1604d

Please sign in to comment.