Skip to content

Commit

Permalink
finish tests, fix transfer to reset price
Browse files Browse the repository at this point in the history
  • Loading branch information
shawntabrizi committed Sep 13, 2024
1 parent cf70060 commit 807e2b1
Show file tree
Hide file tree
Showing 35 changed files with 2,320 additions and 126 deletions.
11 changes: 2 additions & 9 deletions steps/30/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ construct_runtime! {
}
}

const DEFAULT_KITTY: Kitty<TestRuntime> = Kitty { dna: [0u8; 32], owner: 1 };

#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for TestRuntime {
type Block = Block;
Expand Down Expand Up @@ -155,18 +153,13 @@ fn cannot_mint_duplicate_kitty() {
})
}

#[test]
fn kitty_struct_created_correctly() {
let _kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
}

#[test]
fn kitty_struct_has_expected_traits() {
new_test_ext().execute_with(|| {
let kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
let kitty = DEFAULT_KITTY;
let bytes = kitty.encode();
let _new_kitty = Kitty::<TestRuntime>::decode(&mut &bytes[..]).unwrap();
assert_eq!(Kitty::<TestRuntime>::max_encoded_len(), 40);
assert!(Kitty::<TestRuntime>::max_encoded_len() > 0);
let _info = Kitty::<TestRuntime>::type_info();
})
}
Expand Down
11 changes: 2 additions & 9 deletions steps/31/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ construct_runtime! {
}
}

const DEFAULT_KITTY: Kitty<TestRuntime> = Kitty { dna: [0u8; 32], owner: 1 };

#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for TestRuntime {
type Block = Block;
Expand Down Expand Up @@ -155,18 +153,13 @@ fn cannot_mint_duplicate_kitty() {
})
}

#[test]
fn kitty_struct_created_correctly() {
let _kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
}

#[test]
fn kitty_struct_has_expected_traits() {
new_test_ext().execute_with(|| {
let kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
let kitty = DEFAULT_KITTY;
let bytes = kitty.encode();
let _new_kitty = Kitty::<TestRuntime>::decode(&mut &bytes[..]).unwrap();
assert_eq!(Kitty::<TestRuntime>::max_encoded_len(), 40);
assert!(Kitty::<TestRuntime>::max_encoded_len() > 0);
let _info = Kitty::<TestRuntime>::type_info();
})
}
Expand Down
11 changes: 2 additions & 9 deletions steps/32/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ construct_runtime! {
}
}

const DEFAULT_KITTY: Kitty<TestRuntime> = Kitty { dna: [0u8; 32], owner: 1 };

#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for TestRuntime {
type Block = Block;
Expand Down Expand Up @@ -155,18 +153,13 @@ fn cannot_mint_duplicate_kitty() {
})
}

#[test]
fn kitty_struct_created_correctly() {
let _kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
}

#[test]
fn kitty_struct_has_expected_traits() {
new_test_ext().execute_with(|| {
let kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
let kitty = DEFAULT_KITTY;
let bytes = kitty.encode();
let _new_kitty = Kitty::<TestRuntime>::decode(&mut &bytes[..]).unwrap();
assert_eq!(Kitty::<TestRuntime>::max_encoded_len(), 40);
assert!(Kitty::<TestRuntime>::max_encoded_len() > 0);
let _info = Kitty::<TestRuntime>::type_info();
})
}
Expand Down
11 changes: 2 additions & 9 deletions steps/33/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ construct_runtime! {
}
}

const DEFAULT_KITTY: Kitty<TestRuntime> = Kitty { dna: [0u8; 32], owner: 1 };

#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for TestRuntime {
type Block = Block;
Expand Down Expand Up @@ -155,18 +153,13 @@ fn cannot_mint_duplicate_kitty() {
})
}

#[test]
fn kitty_struct_created_correctly() {
let _kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
}

#[test]
fn kitty_struct_has_expected_traits() {
new_test_ext().execute_with(|| {
let kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
let kitty = DEFAULT_KITTY;
let bytes = kitty.encode();
let _new_kitty = Kitty::<TestRuntime>::decode(&mut &bytes[..]).unwrap();
assert_eq!(Kitty::<TestRuntime>::max_encoded_len(), 40);
assert!(Kitty::<TestRuntime>::max_encoded_len() > 0);
let _info = Kitty::<TestRuntime>::type_info();
})
}
Expand Down
11 changes: 2 additions & 9 deletions steps/34/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ construct_runtime! {
}
}

const DEFAULT_KITTY: Kitty<TestRuntime> = Kitty { dna: [0u8; 32], owner: 1 };

#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for TestRuntime {
type Block = Block;
Expand Down Expand Up @@ -155,18 +153,13 @@ fn cannot_mint_duplicate_kitty() {
})
}

#[test]
fn kitty_struct_created_correctly() {
let _kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
}

#[test]
fn kitty_struct_has_expected_traits() {
new_test_ext().execute_with(|| {
let kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
let kitty = DEFAULT_KITTY;
let bytes = kitty.encode();
let _new_kitty = Kitty::<TestRuntime>::decode(&mut &bytes[..]).unwrap();
assert_eq!(Kitty::<TestRuntime>::max_encoded_len(), 40);
assert!(Kitty::<TestRuntime>::max_encoded_len() > 0);
let _info = Kitty::<TestRuntime>::type_info();
})
}
Expand Down
11 changes: 2 additions & 9 deletions steps/35/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ construct_runtime! {
}
}

const DEFAULT_KITTY: Kitty<TestRuntime> = Kitty { dna: [0u8; 32], owner: 1 };

#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for TestRuntime {
type Block = Block;
Expand Down Expand Up @@ -155,18 +153,13 @@ fn cannot_mint_duplicate_kitty() {
})
}

#[test]
fn kitty_struct_created_correctly() {
let _kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
}

#[test]
fn kitty_struct_has_expected_traits() {
new_test_ext().execute_with(|| {
let kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
let kitty = DEFAULT_KITTY;
let bytes = kitty.encode();
let _new_kitty = Kitty::<TestRuntime>::decode(&mut &bytes[..]).unwrap();
assert_eq!(Kitty::<TestRuntime>::max_encoded_len(), 40);
assert!(Kitty::<TestRuntime>::max_encoded_len() > 0);
let _info = Kitty::<TestRuntime>::type_info();
})
}
Expand Down
11 changes: 2 additions & 9 deletions steps/36/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ construct_runtime! {
}
}

const DEFAULT_KITTY: Kitty<TestRuntime> = Kitty { dna: [0u8; 32], owner: 1 };

#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for TestRuntime {
type Block = Block;
Expand Down Expand Up @@ -155,18 +153,13 @@ fn cannot_mint_duplicate_kitty() {
})
}

#[test]
fn kitty_struct_created_correctly() {
let _kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
}

#[test]
fn kitty_struct_has_expected_traits() {
new_test_ext().execute_with(|| {
let kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
let kitty = DEFAULT_KITTY;
let bytes = kitty.encode();
let _new_kitty = Kitty::<TestRuntime>::decode(&mut &bytes[..]).unwrap();
assert_eq!(Kitty::<TestRuntime>::max_encoded_len(), 40);
assert!(Kitty::<TestRuntime>::max_encoded_len() > 0);
let _info = Kitty::<TestRuntime>::type_info();
})
}
Expand Down
11 changes: 2 additions & 9 deletions steps/37/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ construct_runtime! {
}
}

const DEFAULT_KITTY: Kitty<TestRuntime> = Kitty { dna: [0u8; 32], owner: 1 };

#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for TestRuntime {
type Block = Block;
Expand Down Expand Up @@ -155,18 +153,13 @@ fn cannot_mint_duplicate_kitty() {
})
}

#[test]
fn kitty_struct_created_correctly() {
let _kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
}

#[test]
fn kitty_struct_has_expected_traits() {
new_test_ext().execute_with(|| {
let kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
let kitty = DEFAULT_KITTY;
let bytes = kitty.encode();
let _new_kitty = Kitty::<TestRuntime>::decode(&mut &bytes[..]).unwrap();
assert_eq!(Kitty::<TestRuntime>::max_encoded_len(), 40);
assert!(Kitty::<TestRuntime>::max_encoded_len() > 0);
let _info = Kitty::<TestRuntime>::type_info();
})
}
Expand Down
11 changes: 2 additions & 9 deletions steps/38/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ construct_runtime! {
}
}

const DEFAULT_KITTY: Kitty<TestRuntime> = Kitty { dna: [0u8; 32], owner: 1 };

#[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
impl frame_system::Config for TestRuntime {
type Block = Block;
Expand Down Expand Up @@ -155,18 +153,13 @@ fn cannot_mint_duplicate_kitty() {
})
}

#[test]
fn kitty_struct_created_correctly() {
let _kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
}

#[test]
fn kitty_struct_has_expected_traits() {
new_test_ext().execute_with(|| {
let kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
let kitty = DEFAULT_KITTY;
let bytes = kitty.encode();
let _new_kitty = Kitty::<TestRuntime>::decode(&mut &bytes[..]).unwrap();
assert_eq!(Kitty::<TestRuntime>::max_encoded_len(), 40);
assert!(Kitty::<TestRuntime>::max_encoded_len() > 0);
let _info = Kitty::<TestRuntime>::type_info();
})
}
Expand Down
11 changes: 2 additions & 9 deletions steps/39/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ construct_runtime! {
PalletKitties: pallet_kitties,
}
}

const DEFAULT_KITTY: Kitty<TestRuntime> = Kitty { dna: [0u8; 32], owner: 1 };
const ALICE: u64 = 1;
const BOB: u64 = 2;

Expand Down Expand Up @@ -157,18 +155,13 @@ fn cannot_mint_duplicate_kitty() {
})
}

#[test]
fn kitty_struct_created_correctly() {
let _kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
}

#[test]
fn kitty_struct_has_expected_traits() {
new_test_ext().execute_with(|| {
let kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
let kitty = DEFAULT_KITTY;
let bytes = kitty.encode();
let _new_kitty = Kitty::<TestRuntime>::decode(&mut &bytes[..]).unwrap();
assert_eq!(Kitty::<TestRuntime>::max_encoded_len(), 40);
assert!(Kitty::<TestRuntime>::max_encoded_len() > 0);
let _info = Kitty::<TestRuntime>::type_info();
})
}
Expand Down
11 changes: 2 additions & 9 deletions steps/40/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ construct_runtime! {
PalletKitties: pallet_kitties,
}
}

const DEFAULT_KITTY: Kitty<TestRuntime> = Kitty { dna: [0u8; 32], owner: 1 };
const ALICE: u64 = 1;
const BOB: u64 = 2;

Expand Down Expand Up @@ -157,18 +155,13 @@ fn cannot_mint_duplicate_kitty() {
})
}

#[test]
fn kitty_struct_created_correctly() {
let _kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
}

#[test]
fn kitty_struct_has_expected_traits() {
new_test_ext().execute_with(|| {
let kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
let kitty = DEFAULT_KITTY;
let bytes = kitty.encode();
let _new_kitty = Kitty::<TestRuntime>::decode(&mut &bytes[..]).unwrap();
assert_eq!(Kitty::<TestRuntime>::max_encoded_len(), 40);
assert!(Kitty::<TestRuntime>::max_encoded_len() > 0);
let _info = Kitty::<TestRuntime>::type_info();
})
}
Expand Down
11 changes: 2 additions & 9 deletions steps/41/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ construct_runtime! {
PalletKitties: pallet_kitties,
}
}

const DEFAULT_KITTY: Kitty<TestRuntime> = Kitty { dna: [0u8; 32], owner: 1 };
const ALICE: u64 = 1;
const BOB: u64 = 2;

Expand Down Expand Up @@ -157,18 +155,13 @@ fn cannot_mint_duplicate_kitty() {
})
}

#[test]
fn kitty_struct_created_correctly() {
let _kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
}

#[test]
fn kitty_struct_has_expected_traits() {
new_test_ext().execute_with(|| {
let kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
let kitty = DEFAULT_KITTY;
let bytes = kitty.encode();
let _new_kitty = Kitty::<TestRuntime>::decode(&mut &bytes[..]).unwrap();
assert_eq!(Kitty::<TestRuntime>::max_encoded_len(), 40);
assert!(Kitty::<TestRuntime>::max_encoded_len() > 0);
let _info = Kitty::<TestRuntime>::type_info();
})
}
Expand Down
11 changes: 2 additions & 9 deletions steps/42/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ construct_runtime! {
PalletKitties: pallet_kitties,
}
}

const DEFAULT_KITTY: Kitty<TestRuntime> = Kitty { dna: [0u8; 32], owner: 1 };
const ALICE: u64 = 1;
const BOB: u64 = 2;

Expand Down Expand Up @@ -157,18 +155,13 @@ fn cannot_mint_duplicate_kitty() {
})
}

#[test]
fn kitty_struct_created_correctly() {
let _kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
}

#[test]
fn kitty_struct_has_expected_traits() {
new_test_ext().execute_with(|| {
let kitty = Kitty::<TestRuntime> { dna: [0u8; 32], owner: 1 };
let kitty = DEFAULT_KITTY;
let bytes = kitty.encode();
let _new_kitty = Kitty::<TestRuntime>::decode(&mut &bytes[..]).unwrap();
assert_eq!(Kitty::<TestRuntime>::max_encoded_len(), 40);
assert!(Kitty::<TestRuntime>::max_encoded_len() > 0);
let _info = Kitty::<TestRuntime>::type_info();
})
}
Expand Down
Loading

0 comments on commit 807e2b1

Please sign in to comment.