Skip to content

Commit

Permalink
lp-gateway: Add tests for outbound message extrinsics
Browse files Browse the repository at this point in the history
  • Loading branch information
cdamian committed Jan 30, 2024
1 parent 1d45c92 commit 27b3abe
Show file tree
Hide file tree
Showing 7 changed files with 333 additions and 10 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pallets/liquidity-pools-gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ cfg-utils = { path = "../../libs/utils", default-features = false }

[dev-dependencies]
cfg-mocks = { path = "../../libs/mocks", features = ["std"] }
cfg-primitives = { path = "../../libs/primitives" }
hex-literal = "0.4.1"
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.43" }
Expand Down
3 changes: 2 additions & 1 deletion pallets/liquidity-pools-gateway/routers/src/mock.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::str::FromStr;

use cfg_mocks::{pallet_mock_liquidity_pools, pallet_mock_routers, MessageMock, RouterMock};
use cfg_primitives::{BLOCK_STORAGE_LIMIT, MAX_POV_SIZE};
use cfg_primitives::{OutboundMessageNonce, BLOCK_STORAGE_LIMIT, MAX_POV_SIZE};
use cfg_traits::TryConvert;
use cfg_types::domain_address::DomainAddress;
use cumulus_primitives_core::{
Expand Down Expand Up @@ -153,6 +153,7 @@ impl pallet_liquidity_pools_gateway::Config for Runtime {
type MaxIncomingMessageSize = MaxIncomingMessageSize;
type Message = MessageMock;
type OriginRecovery = MockOriginRecovery;
type OutboundMessageNonce = OutboundMessageNonce;
type Router = RouterMock<Runtime>;
type RuntimeEvent = RuntimeEvent;
type RuntimeOrigin = RuntimeOrigin;
Expand Down
9 changes: 7 additions & 2 deletions pallets/liquidity-pools-gateway/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ impl<T: Config> From<RelayerMessageDecodingError> for Error<T> {
pub mod pallet {
const BYTES_U32: usize = 4;
const BYTES_ACCOUNT_20: usize = 20;

/// Some gateway routers do not return an actual weight when sending a
/// message, thus, this default is required, and it's based on:
///
/// https://github.com/centrifuge/centrifuge-chain/pull/1696#discussion_r1456370592
const DEFAULT_WEIGHT_REF_TIME: u64 = 5_000_000_000;

use frame_support::dispatch::PostDispatchInfo;
Expand Down Expand Up @@ -537,7 +542,7 @@ pub mod pallet {

FailedOutboundMessages::<T>::insert(nonce, (domain, sender, message, e.error));

Err(e.error)
Ok(())
}
}
}
Expand Down Expand Up @@ -576,7 +581,7 @@ pub mod pallet {
error: e.error,
});

Err(e.error)
Ok(())
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions pallets/liquidity-pools-gateway/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use cfg_mocks::{
pallet_mock_liquidity_pools, pallet_mock_routers, pallet_mock_try_convert, MessageMock,
RouterMock,
};
use cfg_primitives::OutboundMessageNonce;
use cfg_types::domain_address::DomainAddress;
use frame_system::EnsureRoot;
use sp_core::{crypto::AccountId32, ConstU128, ConstU16, ConstU32, ConstU64, H256};
Expand Down Expand Up @@ -111,6 +112,7 @@ impl pallet_liquidity_pools_gateway::Config for Runtime {
type MaxIncomingMessageSize = MaxIncomingMessageSize;
type Message = MessageMock;
type OriginRecovery = MockOriginRecovery;
type OutboundMessageNonce = OutboundMessageNonce;
type Router = RouterMock<Runtime>;
type RuntimeEvent = RuntimeEvent;
type RuntimeOrigin = RuntimeOrigin;
Expand Down
Loading

0 comments on commit 27b3abe

Please sign in to comment.