Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
cuteolaf committed Apr 22, 2024
1 parent 9bebf52 commit 40b7c24
Showing 1 changed file with 41 additions and 11 deletions.
52 changes: 41 additions & 11 deletions pallets/regions/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ use crate::{
ismp_mock::requests, mock::*, pallet::Regions as RegionsStorage, utils, Call as RegionsCall,
Error, Event, IsmpCustomError, IsmpModuleCallback, Record, Region,
};
use frame_support::{assert_err, assert_ok, pallet_prelude::*, traits::nonfungible::{Inspect, Mutate, Transfer as NonFungibleTransfer}};
use frame_support::{
assert_err, assert_ok,
pallet_prelude::*,
traits::nonfungible::{Inspect, Mutate, Transfer as NonFungibleTransfer},
};
use ismp::{
module::IsmpModule,
router::{GetResponse, Post, PostResponse, Request, Response, Timeout},
Expand Down Expand Up @@ -298,18 +302,39 @@ fn nonfungible_attribute_works() {
new_test_ext().execute_with(|| {
let region_id = RegionId { begin: 112830, core: 72, mask: CoreMask::complete() };
let record: RegionRecord<u64, u64> = RegionRecord { end: 123600, owner: 1, paid: None };

assert_ok!(Regions::mint_into(&region_id.into(), &1));
assert_ok!(Regions::set_record(region_id, record.clone()));

assert!(Regions::attribute(&region_id.into(), "none".as_bytes().into()).is_none());
assert_eq!(Regions::attribute(&region_id.into(), "begin".as_bytes()), Some(region_id.begin.encode()));
assert_eq!(Regions::attribute(&region_id.into(), "end".as_bytes()), Some(record.end.encode()));
assert_eq!(Regions::attribute(&region_id.into(), "length".as_bytes()), Some((record.end.saturating_sub(region_id.begin)).encode()));
assert_eq!(Regions::attribute(&region_id.into(), "core".as_bytes()), Some(region_id.core.encode()));
assert_eq!(Regions::attribute(&region_id.into(), "part".as_bytes()), Some(region_id.mask.encode()));
assert_eq!(Regions::attribute(&region_id.into(), "owner".as_bytes()), Some(record.owner.encode()));
assert_eq!(Regions::attribute(&region_id.into(), "paid".as_bytes()), Some(record.paid.encode()));
assert_eq!(
Regions::attribute(&region_id.into(), "begin".as_bytes()),
Some(region_id.begin.encode())
);
assert_eq!(
Regions::attribute(&region_id.into(), "end".as_bytes()),
Some(record.end.encode())
);
assert_eq!(
Regions::attribute(&region_id.into(), "length".as_bytes()),
Some((record.end.saturating_sub(region_id.begin)).encode())
);
assert_eq!(
Regions::attribute(&region_id.into(), "core".as_bytes()),
Some(region_id.core.encode())
);
assert_eq!(
Regions::attribute(&region_id.into(), "part".as_bytes()),
Some(region_id.mask.encode())
);
assert_eq!(
Regions::attribute(&region_id.into(), "owner".as_bytes()),
Some(record.owner.encode())
);
assert_eq!(
Regions::attribute(&region_id.into(), "paid".as_bytes()),
Some(record.paid.encode())
);
});
}

Expand All @@ -321,7 +346,12 @@ fn nonfungible_transfer_works() {
assert_ok!(Regions::mint_into(&region_id.into(), &1));
assert_eq!(Regions::owner(&region_id.into()), Some(1));

assert_ok!(<Regions as NonFungibleTransfer::<<Test as frame_system::Config>::AccountId>>::transfer(&region_id.into(), &2));
assert_ok!(
<Regions as NonFungibleTransfer::<<Test as frame_system::Config>::AccountId>>::transfer(
&region_id.into(),
&2
)
);
assert_eq!(Regions::owner(&region_id.into()), Some(2));
});
}
Expand Down

0 comments on commit 40b7c24

Please sign in to comment.