Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Szegoo committed Aug 10, 2024
1 parent d0b2082 commit 50c4e32
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
1 change: 1 addition & 0 deletions pallets/regions/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ impl<T: Config> Default for IsmpModuleCallback<T> {
}
}

use frame_support::ensure;
impl<T: Config> IsmpModule for IsmpModuleCallback<T> {
fn on_accept(&self, _request: Post) -> Result<(), IsmpError> {
Err(IsmpCustomError::NotSupported.into())
Expand Down
15 changes: 6 additions & 9 deletions pallets/regions/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::{
Error, Event, IsmpCustomError, IsmpModuleCallback, Record, Region,
};
use frame_support::{
assert_err, assert_noop, assert_ok,
assert_noop, assert_ok,
pallet_prelude::*,
traits::nonfungible::{Inspect, Mutate, Transfer as NonFungibleTransfer},
};
Expand Down Expand Up @@ -286,19 +286,15 @@ fn on_timeout_works() {

// failed to decode region_id
let mut invalid_get_req = get.clone();
invalid_get_req.keys.push(vec![0u8; 15]);
assert_err!(
invalid_get_req.keys = vec![vec![0u8; 15]];
assert_noop!(
module.on_timeout(Timeout::Request(Request::Get(invalid_get_req.clone()))),
IsmpCustomError::KeyDecodeFailed
);

// invalid id: region not found
invalid_get_req.keys.pop();
if let Some(key) = invalid_get_req.keys.get_mut(0) {
for i in 0..key.len() {
key[i] = key[i].reverse_bits();
}
}
let non_existing_region = RegionId { begin: 42, core: 72, mask: CoreMask::complete() };
invalid_get_req.keys = vec![non_existing_region.encode()];
assert_noop!(
module.on_timeout(Timeout::Request(Request::Get(invalid_get_req.clone()))),
IsmpCustomError::RegionNotFound
Expand All @@ -314,6 +310,7 @@ fn on_timeout_works() {
data: Default::default(),
};
assert_ok!(module.on_timeout(Timeout::Request(Request::Post(post.clone()))));
System::assert_last_event(Event::RequestTimedOut { region_id }.into());

assert_ok!(module.on_timeout(Timeout::Response(PostResponse {
post,
Expand Down

0 comments on commit 50c4e32

Please sign in to comment.