mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 01:21:01 +00:00
Companion for Polkadot#7563 (#2956)
* `XcmContext` to `buy_weight / refund_weight`
* Fix tests
* Fix more tests
* update lockfile for {"substrate", "polkadot"}
---------
Co-authored-by: parity-processbot <>
This commit is contained in:
@@ -146,8 +146,9 @@ impl<
|
||||
&mut self,
|
||||
weight: Weight,
|
||||
payment: xcm_executor::Assets,
|
||||
context: &XcmContext,
|
||||
) -> Result<xcm_executor::Assets, XcmError> {
|
||||
log::trace!(target: "xcm::weight", "TakeFirstAssetTrader::buy_weight weight: {:?}, payment: {:?}", weight, payment);
|
||||
log::trace!(target: "xcm::weight", "TakeFirstAssetTrader::buy_weight weight: {:?}, payment: {:?}, context: {:?}", weight, payment, context);
|
||||
|
||||
// Make sure we dont enter twice
|
||||
if self.0.is_some() {
|
||||
@@ -196,8 +197,8 @@ impl<
|
||||
Ok(unused)
|
||||
}
|
||||
|
||||
fn refund_weight(&mut self, weight: Weight) -> Option<MultiAsset> {
|
||||
log::trace!(target: "xcm::weight", "TakeFirstAssetTrader::refund_weight weight: {:?}", weight);
|
||||
fn refund_weight(&mut self, weight: Weight, context: &XcmContext) -> Option<MultiAsset> {
|
||||
log::trace!(target: "xcm::weight", "TakeFirstAssetTrader::refund_weight weight: {:?}, context: {:?}", weight, context);
|
||||
if let Some(AssetTraderRefunder {
|
||||
mut weight_outstanding,
|
||||
outstanding_concrete_asset: MultiAsset { id, fun },
|
||||
@@ -526,6 +527,7 @@ 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();
|
||||
@@ -533,9 +535,9 @@ mod tests {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user