Skip to content

Commit

Permalink
lp-gateway: Update integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cdamian committed Aug 16, 2024
1 parent 4b6cc1d commit d82316a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions libs/traits/src/liquidity_pools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ pub trait LPMessage: Sized {
///
/// Hash - hash of the message that should be recovered.
/// Router - the address of the recovery router.
fn initiate_recovery_message(hash: [u8; 32], router: [u8; 20]) -> Self;
fn initiate_recovery_message(hash: [u8; 32], router: [u8; 32]) -> Self;

/// Creates a message used for disputing message recovery.
///
/// Hash - hash of the message that should be disputed.
/// Router - the address of the recovery router.
fn dispute_recovery_message(hash: [u8; 32], router: [u8; 20]) -> Self;
fn dispute_recovery_message(hash: [u8; 32], router: [u8; 32]) -> Self;
}

pub trait RouterProvider<Domain>: Sized {
Expand Down
12 changes: 6 additions & 6 deletions pallets/liquidity-pools-gateway/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,15 @@ pub mod pallet {
MessageRecoveryInitiated {
domain: Domain,
message_hash: MessageHash,
recovery_router: [u8; 20],
recovery_router: [u8; 32],
messaging_router: T::RouterId,
},

/// Message recovery was disputed.
MessageRecoveryDisputed {
domain: Domain,
message_hash: MessageHash,
recovery_router: [u8; 20],
recovery_router: [u8; 32],
messaging_router: T::RouterId,
},
}
Expand Down Expand Up @@ -513,14 +513,14 @@ pub mod pallet {
origin: OriginFor<T>,
domain: Domain,
message_hash: MessageHash,
recovery_router: [u8; 20],
recovery_router: [u8; 32],
messaging_router: T::RouterId,
) -> DispatchResult {
T::AdminOrigin::ensure_origin(origin)?;

let message = T::Message::initiate_recovery_message(message_hash, recovery_router);

Self::send_recovery_message(domain.clone(), message, messaging_router.clone())?;
Self::send_recovery_message(domain, message, messaging_router.clone())?;

Self::deposit_event(Event::<T>::MessageRecoveryInitiated {
domain,
Expand All @@ -542,14 +542,14 @@ pub mod pallet {
origin: OriginFor<T>,
domain: Domain,
message_hash: MessageHash,
recovery_router: [u8; 20],
recovery_router: [u8; 32],
messaging_router: T::RouterId,
) -> DispatchResult {
T::AdminOrigin::ensure_origin(origin)?;

let message = T::Message::dispute_recovery_message(message_hash, recovery_router);

Self::send_recovery_message(domain.clone(), message, messaging_router.clone())?;
Self::send_recovery_message(domain, message, messaging_router.clone())?;

Self::deposit_event(Event::<T>::MessageRecoveryDisputed {
domain,
Expand Down
10 changes: 5 additions & 5 deletions pallets/liquidity-pools-gateway/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{pallet as pallet_liquidity_pools_gateway, EnsureLocal, GatewayMessag

pub const TEST_SESSION_ID: u32 = 1;
pub const TEST_EVM_CHAIN: EVMChainId = 1;
pub const TEST_DOMAIN: Domain = Domain::EVM(TEST_EVM_CHAIN);
pub const TEST_DOMAIN: Domain = Domain::Evm(TEST_EVM_CHAIN);
pub const TEST_DOMAIN_ADDRESS: DomainAddress =
DomainAddress::Evm(TEST_EVM_CHAIN, H160::repeat_byte(1));

Expand All @@ -37,8 +37,8 @@ pub enum Message {
Simple,
Pack(Vec<Message>),
Proof([u8; 32]),
InitiateMessageRecovery(([u8; 32], [u8; 20])),
DisputeMessageRecovery(([u8; 32], [u8; 20])),
InitiateMessageRecovery(([u8; 32], [u8; 32])),
DisputeMessageRecovery(([u8; 32], [u8; 32])),
}

impl Debug for Message {
Expand Down Expand Up @@ -116,11 +116,11 @@ impl LPMessage for Message {
}
}

fn initiate_recovery_message(hash: [u8; 32], router: [u8; 20]) -> Self {
fn initiate_recovery_message(hash: [u8; 32], router: [u8; 32]) -> Self {
Self::InitiateMessageRecovery((hash, router))
}

fn dispute_recovery_message(hash: [u8; 32], router: [u8; 20]) -> Self {
fn dispute_recovery_message(hash: [u8; 32], router: [u8; 32]) -> Self {
Self::DisputeMessageRecovery((hash, router))
}
}
Expand Down
20 changes: 10 additions & 10 deletions pallets/liquidity-pools-gateway/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ mod extrinsics {
#[test]
fn success() {
new_test_ext().execute_with(|| {
let recovery_router = [1u8; 20];
let recovery_router = [1u8; 32];

Routers::<Runtime>::set(BoundedVec::try_from(vec![ROUTER_ID_1]).unwrap());

Expand Down Expand Up @@ -911,7 +911,7 @@ mod extrinsics {
#[test]
fn bad_origin() {
new_test_ext().execute_with(|| {
let recovery_router = [1u8; 20];
let recovery_router = [1u8; 32];

assert_noop!(
LiquidityPoolsGateway::initiate_message_recovery(
Expand All @@ -929,7 +929,7 @@ mod extrinsics {
#[test]
fn not_enough_routers_for_domain() {
new_test_ext().execute_with(|| {
let recovery_router = [1u8; 20];
let recovery_router = [1u8; 32];

assert_noop!(
LiquidityPoolsGateway::initiate_message_recovery(
Expand All @@ -947,7 +947,7 @@ mod extrinsics {
#[test]
fn messaging_router_not_found() {
new_test_ext().execute_with(|| {
let recovery_router = [1u8; 20];
let recovery_router = [1u8; 32];

Routers::<Runtime>::set(BoundedVec::try_from(vec![ROUTER_ID_1]).unwrap());

Expand Down Expand Up @@ -979,7 +979,7 @@ mod extrinsics {
#[test]
fn message_sender_error() {
new_test_ext().execute_with(|| {
let recovery_router = [1u8; 20];
let recovery_router = [1u8; 32];

Routers::<Runtime>::set(BoundedVec::try_from(vec![ROUTER_ID_1]).unwrap());

Expand Down Expand Up @@ -1017,7 +1017,7 @@ mod extrinsics {
#[test]
fn success() {
new_test_ext().execute_with(|| {
let recovery_router = [1u8; 20];
let recovery_router = [1u8; 32];

Routers::<Runtime>::set(BoundedVec::try_from(vec![ROUTER_ID_1]).unwrap());

Expand Down Expand Up @@ -1053,7 +1053,7 @@ mod extrinsics {
#[test]
fn bad_origin() {
new_test_ext().execute_with(|| {
let recovery_router = [1u8; 20];
let recovery_router = [1u8; 32];

assert_noop!(
LiquidityPoolsGateway::dispute_message_recovery(
Expand All @@ -1071,7 +1071,7 @@ mod extrinsics {
#[test]
fn not_enough_routers_for_domain() {
new_test_ext().execute_with(|| {
let recovery_router = [1u8; 20];
let recovery_router = [1u8; 32];

assert_noop!(
LiquidityPoolsGateway::dispute_message_recovery(
Expand All @@ -1089,7 +1089,7 @@ mod extrinsics {
#[test]
fn messaging_router_not_found() {
new_test_ext().execute_with(|| {
let recovery_router = [1u8; 20];
let recovery_router = [1u8; 32];

Routers::<Runtime>::set(BoundedVec::try_from(vec![ROUTER_ID_1]).unwrap());

Expand Down Expand Up @@ -1121,7 +1121,7 @@ mod extrinsics {
#[test]
fn message_sender_error() {
new_test_ext().execute_with(|| {
let recovery_router = [1u8; 20];
let recovery_router = [1u8; 32];

Routers::<Runtime>::set(BoundedVec::try_from(vec![ROUTER_ID_1]).unwrap());

Expand Down
8 changes: 4 additions & 4 deletions pallets/liquidity-pools/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ pub enum Message<BatchContent = BatchMessages> {
/// The hash of the message which shall be recovered
hash: [u8; 32],
/// The address of the router
router: [u8; 20],
router: [u8; 32],
},
/// Dispute the recovery of a message.
///
Expand All @@ -237,7 +237,7 @@ pub enum Message<BatchContent = BatchMessages> {
/// The hash of the message which shall be disputed
hash: [u8; 32],
/// The address of the router
router: [u8; 20],
router: [u8; 32],
},
/// A batch of ordered messages.
/// Don't allow nested batch messages.
Expand Down Expand Up @@ -575,11 +575,11 @@ impl LPMessage for Message {
Message::MessageProof { hash }
}

fn initiate_recovery_message(hash: [u8; 32], router: [u8; 20]) -> Self {
fn initiate_recovery_message(hash: [u8; 32], router: [u8; 32]) -> Self {
Message::InitiateMessageRecovery { hash, router }
}

fn dispute_recovery_message(hash: [u8; 32], router: [u8; 20]) -> Self {
fn dispute_recovery_message(hash: [u8; 32], router: [u8; 32]) -> Self {
Message::DisputeMessageRecovery { hash, router }
}
}
Expand Down

0 comments on commit d82316a

Please sign in to comment.