From 0627a68e4e9bc96c00ae7ac7b51da0a79be9625d Mon Sep 17 00:00:00 2001 From: Alistair Singh Date: Thu, 21 Dec 2023 11:22:33 +0200 Subject: [PATCH] check relayer get paid rewards (#1081) --- parachain/pallets/inbound-queue/src/test.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/parachain/pallets/inbound-queue/src/test.rs b/parachain/pallets/inbound-queue/src/test.rs index 5102695086..c283ef89ad 100644 --- a/parachain/pallets/inbound-queue/src/test.rs +++ b/parachain/pallets/inbound-queue/src/test.rs @@ -17,7 +17,9 @@ use crate::mock::*; fn test_submit_happy_path() { new_tester().execute_with(|| { let relayer: AccountId = Keyring::Bob.into(); - let origin = RuntimeOrigin::signed(relayer); + let channel_sovereign = sibling_sovereign_account::(ASSET_HUB_PARAID.into()); + + let origin = RuntimeOrigin::signed(relayer.clone()); // Submit message let message = Message { @@ -28,6 +30,11 @@ fn test_submit_happy_path() { data: Default::default(), }, }; + + let initial_fund = InitialFund::get(); + assert_eq!(Balances::balance(&relayer), 0); + assert_eq!(Balances::balance(&channel_sovereign), initial_fund); + assert_ok!(InboundQueue::submit(origin.clone(), message.clone())); expect_events(vec![InboundQueueEvent::MessageReceived { channel_id: hex!("c173fac324158e77fb5840738a1a541f633cbec8884c6a601c567d2b376a0539") @@ -39,6 +46,13 @@ fn test_submit_happy_path() { ], } .into()]); + + let reward = Parameters::get().rewards.local; + assert!(Balances::balance(&relayer) >= reward, "relayer was rewarded"); + assert!( + Balances::balance(&channel_sovereign) <= initial_fund - reward, + "sovereign account paid reward" + ); }); } @@ -49,7 +63,7 @@ fn test_submit_xcm_invalid_channel() { let origin = RuntimeOrigin::signed(relayer); // Deposit funds into sovereign account of parachain 1001 - let sovereign_account = sibling_sovereign_account::(1001u32.into()); + let sovereign_account = sibling_sovereign_account::(TEMPLATE_PARAID.into()); println!("account: {}", sovereign_account); let _ = Balances::mint_into(&sovereign_account, 10000);