Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Szegoo committed Aug 8, 2024
1 parent 0a51612 commit 414acfa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 0 additions & 4 deletions pallets/regions/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,25 +129,21 @@ pub mod pallet {
/// The ismp get request commitment.
request_commitment: H256,
},

/// A region was minted via a cross chain transfer.
RegionMinted {
/// minted region id
region_id: RegionId,
},

/// A region was burnt.
RegionBurnt {
/// burnt region id
region_id: RegionId,
},

/// A region was locked.
RegionLocked {
/// locked region id
region_id: RegionId,
},

/// A region was unlocked.
RegionUnlocked {
/// unlocked region id
Expand Down
5 changes: 5 additions & 0 deletions pallets/regions/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ fn nonfungibles_implementation_works() {

assert!(Regions::regions(&region_id).is_none());
assert_ok!(Regions::mint_into(&region_id.into(), &2));
System::assert_last_event(Event::RegionMinted { region_id }.into());
assert_eq!(
Regions::regions(&region_id).unwrap(),
Region { owner: 2, locked: false, record: Record::Unavailable }
Expand All @@ -55,6 +56,7 @@ fn nonfungibles_implementation_works() {
assert_noop!(Regions::burn(&region_id.into(), Some(&1)), Error::<Test>::NotOwner);

assert_ok!(Regions::burn(&region_id.into(), Some(&2)));
System::assert_last_event(Event::RegionBurnt { region_id }.into());
assert!(Regions::regions(&region_id).is_none());

assert_noop!(Regions::burn(&region_id.into(), None), Error::<Test>::UnknownRegion);
Expand Down Expand Up @@ -427,6 +429,7 @@ fn region_locking_works() {
assert_noop!(Regions::lock(&region_id.into(), Some(2)), Error::<Test>::NotOwner);

assert_ok!(Regions::lock(&region_id.into(), Some(1)));
System::assert_last_event(Event::RegionLocked { region_id }.into());
assert_eq!(
Regions::regions(&region_id).unwrap(),
Region { owner: 1, locked: true, record: Record::Unavailable }
Expand Down Expand Up @@ -461,6 +464,7 @@ fn region_unlocking_works() {
assert_noop!(Regions::unlock(&region_id.into(), Some(1)), Error::<Test>::RegionNotLocked);

assert_ok!(Regions::lock(&region_id.into(), Some(1)));
System::assert_last_event(Event::RegionLocked { region_id }.into());
assert_eq!(
Regions::regions(&region_id).unwrap(),
Region { owner: 1, locked: true, record: Record::Unavailable }
Expand All @@ -470,6 +474,7 @@ fn region_unlocking_works() {
assert_noop!(Regions::unlock(&region_id.into(), Some(2)), Error::<Test>::NotOwner);

assert_ok!(Regions::unlock(&region_id.into(), Some(1)));
System::assert_last_event(Event::RegionUnlocked { region_id }.into());
assert_eq!(
Regions::regions(&region_id).unwrap(),
Region { owner: 1, locked: false, record: Record::Unavailable }
Expand Down

0 comments on commit 414acfa

Please sign in to comment.