From 42c069ef074c30e67d3d387ccaaec6cac55ba0fe Mon Sep 17 00:00:00 2001 From: Sergej Date: Fri, 12 Apr 2024 09:49:23 +0200 Subject: [PATCH] new tests --- pallets/regions/src/benchmarking.rs | 2 +- pallets/regions/src/lib.rs | 2 ++ pallets/regions/src/tests.rs | 32 ++++++++++++++++++++++++++++- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/pallets/regions/src/benchmarking.rs b/pallets/regions/src/benchmarking.rs index 8bba2a09..4128f705 100644 --- a/pallets/regions/src/benchmarking.rs +++ b/pallets/regions/src/benchmarking.rs @@ -1,4 +1,4 @@ -//! Benchmarking setup for pallet-parachain-template +//! Benchmarking setup for pallet-regions use super::*; diff --git a/pallets/regions/src/lib.rs b/pallets/regions/src/lib.rs index 8af5245f..0d106b56 100644 --- a/pallets/regions/src/lib.rs +++ b/pallets/regions/src/lib.rs @@ -66,6 +66,8 @@ pub mod pallet { + From; /// Native currency implementation + // + // NOTE: Isn't used since we don't have a reward mechanism for ISMP relayers. type NativeCurrency: Mutate; /// The Coretime chain from which we read region state. diff --git a/pallets/regions/src/tests.rs b/pallets/regions/src/tests.rs index 8b1d0a86..396fb5b9 100644 --- a/pallets/regions/src/tests.rs +++ b/pallets/regions/src/tests.rs @@ -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; @@ -86,6 +86,36 @@ fn on_response_works() { }); } +#[test] +fn on_response_only_handles_get() { + new_test_ext().execute_with(|| { + let module: IsmpModuleCallback = IsmpModuleCallback::default(); + + let mock_response = Response::Post(PostResponse { + post: Post { + source: ::CoretimeChain::get(), + dest: ::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(|| {