diff --git a/bridges/snowbridge/pallets/outbound-queue-v2/src/mock.rs b/bridges/snowbridge/pallets/outbound-queue-v2/src/mock.rs index bbcfd3bdacdc..353747b23a5f 100644 --- a/bridges/snowbridge/pallets/outbound-queue-v2/src/mock.rs +++ b/bridges/snowbridge/pallets/outbound-queue-v2/src/mock.rs @@ -82,6 +82,9 @@ impl Verifier for MockVerifier { } const GATEWAY_ADDRESS: [u8; 20] = hex!["eda338e4dc46038493b885327842fd3e301cab39"]; +const WETH: [u8; 20] = hex!["C02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"]; +const ASSET_HUB_AGENT: [u8; 32] = + hex!["81c5ab2571199e3188135178f3c2c8e2d268be1313d029b30f534fa579b69b79"]; parameter_types! { pub const OwnParaId: ParaId = ParaId::new(1013); @@ -186,13 +189,13 @@ where pub fn mock_message(sibling_para_id: u32) -> Message { Message { origin: H256::from_low_u64_be(sibling_para_id as u64), - id: Default::default(), - fee: 0, + id: H256::from_low_u64_be(1), + fee: 1_000, commands: BoundedVec::try_from(vec![Command::UnlockNativeToken { - agent_id: Default::default(), - token: Default::default(), - recipient: Default::default(), - amount: 0, + agent_id: H256(ASSET_HUB_AGENT), + token: H160(WETH), + recipient: H160(GATEWAY_ADDRESS), + amount: 1_000_000, }]) .unwrap(), } diff --git a/bridges/snowbridge/pallets/outbound-queue-v2/src/test.rs b/bridges/snowbridge/pallets/outbound-queue-v2/src/test.rs index aadb9e520e1a..45e43e0c7c9d 100644 --- a/bridges/snowbridge/pallets/outbound-queue-v2/src/test.rs +++ b/bridges/snowbridge/pallets/outbound-queue-v2/src/test.rs @@ -17,7 +17,7 @@ use snowbridge_core::{ }, ChannelId, ParaId, }; -use sp_core::H256; +use sp_core::{hexdisplay::HexDisplay, H256}; #[test] fn submit_messages_and_commit() { @@ -247,3 +247,24 @@ fn encode_digest_item() { ); }); } + +#[test] +fn encode_mock_message() { + let message: Message = mock_message(1000); + let commands: Vec = message + .commands + .into_iter() + .map(|command| CommandWrapper { + kind: command.index(), + gas: ::GasMeter::maximum_dispatch_gas_used_at_most(&command), + payload: command.abi_encode(), + }) + .collect(); + + // Todo: print the abi-encoded message and try to decode with solidity test + let committed_message = + InboundMessage { origin: message.origin.0.to_vec(), nonce: 1, commands }; + let message_abi_encoded = committed_message.abi_encode(); + // print_hex(message_abi_encoded.as_slice()); + println!("{}", HexDisplay::from(&message_abi_encoded)); +}