Skip to content

Commit

Permalink
new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Szegoo committed Apr 12, 2024
1 parent f666fe5 commit 42c069e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pallets/regions/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Benchmarking setup for pallet-parachain-template
//! Benchmarking setup for pallet-regions

use super::*;

Expand Down
2 changes: 2 additions & 0 deletions pallets/regions/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ pub mod pallet {
+ From<u32>;

/// Native currency implementation
//
// NOTE: Isn't used since we don't have a reward mechanism for ISMP relayers.
type NativeCurrency: Mutate<Self::AccountId>;

/// The Coretime chain from which we read region state.
Expand Down
32 changes: 31 additions & 1 deletion pallets/regions/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
use frame_support::{assert_err, assert_ok, pallet_prelude::*, traits::nonfungible::Mutate};
use ismp::{
module::IsmpModule,
router::{GetResponse, Post, Request, Response, Timeout},
router::{GetResponse, Post, PostResponse, Request, Response, Timeout},
};
use pallet_broker::{CoreMask, RegionId, RegionRecord};
use std::collections::BTreeMap;
Expand Down Expand Up @@ -86,6 +86,36 @@ fn on_response_works() {
});
}

#[test]
fn on_response_only_handles_get() {
new_test_ext().execute_with(|| {
let module: IsmpModuleCallback<Test> = IsmpModuleCallback::default();

let mock_response = Response::Post(PostResponse {
post: Post {
source: <Test as crate::Config>::CoretimeChain::get(),
dest: <Test as crate::Config>::CoretimeChain::get(),
nonce: Default::default(),
from: Default::default(),
to: Default::default(),
timeout_timestamp: Default::default(),
data: Default::default(),
},
response: Default::default(),
timeout_timestamp: Default::default(),
});

assert_err!(module.on_response(mock_response), IsmpCustomError::NotSupported);
});
}

#[test]
fn on_timeout_only_handles_get() {
new_test_ext().execute_with(|| {
// TODO
});
}

#[test]
fn on_timeout_works() {
new_test_ext().execute_with(|| {
Expand Down

0 comments on commit 42c069e

Please sign in to comment.