Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Fix more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bkontur committed Jul 31, 2023
1 parent 872813b commit 0f824eb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion parachains/runtimes/assets/asset-hub-polkadot/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ fn test_that_buying_ed_refund_does_not_refund() {
));

let mut trader = <XcmConfig as xcm_executor::Config>::Trader::new();
let ctx = XcmContext { origin: None, message_id: XcmHash::default(), topic: None };

// Set Alice as block author, who will receive fees
RuntimeHelper::<Runtime>::run_to_block(2, Some(AccountId::from(ALICE)));
Expand Down Expand Up @@ -369,6 +370,7 @@ fn test_asset_xcm_trader_not_possible_for_non_sufficient_assets() {
));

let mut trader = <XcmConfig as xcm_executor::Config>::Trader::new();
let ctx = XcmContext { origin: None, message_id: XcmHash::default(), topic: None };

// Set Alice as block author, who will receive fees
RuntimeHelper::<Runtime>::run_to_block(2, Some(AccountId::from(ALICE)));
Expand All @@ -387,7 +389,7 @@ fn test_asset_xcm_trader_not_possible_for_non_sufficient_assets() {
let asset: MultiAsset = (asset_multilocation, asset_amount_needed).into();

// Make sure again buy_weight does return an error
assert_noop!(trader.buy_weight(bought, asset.into()), XcmError::TooExpensive);
assert_noop!(trader.buy_weight(bought, asset.into(), &ctx), XcmError::TooExpensive);

// Drop trader
drop(trader);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ fn test_asset_xcm_trader() {
(asset_multilocation, asset_amount_needed + asset_amount_extra).into();

let mut trader = <XcmConfig as xcm_executor::Config>::Trader::new();
let ctx = XcmContext { origin: None, message_id: XcmHash::default(), topic: None };

// Lets buy_weight and make sure buy_weight does not return an error
let unused_assets = trader.buy_weight(bought, asset.into(), &ctx).expect("Expected Ok");
Expand Down
5 changes: 3 additions & 2 deletions primitives/utility/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,16 +527,17 @@ mod tests {
FeeChargerAssetsHandleRefund,
>;
let mut trader = <Trader as WeightTrader>::new();
let ctx = XcmContext { origin: None, message_id: XcmHash::default(), topic: None };

// prepare test data
let asset: MultiAsset = (Here, AMOUNT).into();
let payment = Assets::from(asset);
let weight_to_buy = Weight::from_parts(1_000, 1_000);

// lets do first call (success)
assert_ok!(trader.buy_weight(weight_to_buy, payment.clone()));
assert_ok!(trader.buy_weight(weight_to_buy, payment.clone(), &ctx));

// lets do second call (error)
assert_eq!(trader.buy_weight(weight_to_buy, payment), Err(XcmError::NotWithdrawable));
assert_eq!(trader.buy_weight(weight_to_buy, payment, &ctx), Err(XcmError::NotWithdrawable));
}
}

0 comments on commit 0f824eb

Please sign in to comment.