Skip to content

Commit

Permalink
fix: remove tests for TransactionExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscoaguirre committed Dec 4, 2024
1 parent 07b1129 commit 8243209
Showing 1 changed file with 0 additions and 74 deletions.
74 changes: 0 additions & 74 deletions substrate/frame/transaction-payment/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -841,77 +841,3 @@ fn genesis_default_works() {
assert_eq!(<NextFeeMultiplier<Runtime>>::get(), Multiplier::saturating_from_integer(1));
});
}

#[test]
fn no_fee_and_no_weight_for_other_origins() {
ExtBuilder::default().build().execute_with(|| {
let ext = Ext::from(0);

let mut info = CALL.get_dispatch_info();
info.extension_weight = ext.weight(CALL);

// Ensure we test the refund.
assert!(info.extension_weight != Weight::zero());

let len = CALL.encoded_size();

let origin = frame_system::RawOrigin::Root.into();
let (pre, origin) = ext.validate_and_prepare(origin, CALL, &info, len, 0).unwrap();

assert!(origin.as_system_ref().unwrap().is_root());

let pd_res = Ok(());
let mut post_info = frame_support::dispatch::PostDispatchInfo {
actual_weight: Some(info.total_weight()),
pays_fee: Default::default(),
};

<Ext as TransactionExtension<RuntimeCall>>::post_dispatch(
pre,
&info,
&mut post_info,
len,
&pd_res,
)
.unwrap();

assert_eq!(post_info.actual_weight, Some(info.call_weight));
})
}

#[test]
fn fungible_adapter_no_zero_refund_action() {
type FungibleAdapterT = payment::FungibleAdapter<Balances, DealWithFees>;

ExtBuilder::default().balance_factor(10).build().execute_with(|| {
System::set_block_number(10);

let dummy_acc = 1;
let (actual_fee, no_tip) = (10, 0);
let already_paid = <FungibleAdapterT as OnChargeTransaction<Runtime>>::withdraw_fee(
&dummy_acc,
CALL,
&CALL.get_dispatch_info(),
actual_fee,
no_tip,
).expect("Account must have enough funds.");

// Correction action with no expected side effect.
assert!(<FungibleAdapterT as OnChargeTransaction<Runtime>>::correct_and_deposit_fee(
&dummy_acc,
&CALL.get_dispatch_info(),
&default_post_info(),
actual_fee,
no_tip,
already_paid,
).is_ok());

// Ensure no zero amount deposit event is emitted.
let events = System::events();
assert!(!events
.iter()
.any(|record| matches!(record.event, RuntimeEvent::Balances(pallet_balances::Event::Deposit { amount, .. }) if amount.is_zero())),
"No zero amount deposit amount event should be emitted.",
);
});
}

0 comments on commit 8243209

Please sign in to comment.