This repository was archived by the owner on Nov 15, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -49,3 +49,21 @@ fn call_size() {
4949 If the limit is too strong, maybe consider increase the limit to 300." ,
5050 ) ;
5151}
52+
53+ #[ test]
54+ fn sanity_check_teleport_assets_weight ( ) {
55+ // This test sanity checks that at least 50 teleports can exist in a block.
56+ // Usually when XCM runs into an issue, it will return a weight of `Weight::MAX`,
57+ // so this test will certainly ensure that this problem does not occur.
58+ use frame_support:: dispatch:: GetDispatchInfo ;
59+ let weight = pallet_xcm:: Call :: < Runtime > :: teleport_assets {
60+ dest : Box :: new ( xcm:: VersionedMultiLocation :: V1 ( MultiLocation :: here ( ) ) ) ,
61+ beneficiary : Box :: new ( xcm:: VersionedMultiLocation :: V1 ( MultiLocation :: here ( ) ) ) ,
62+ assets : Box :: new ( ( Concrete ( MultiLocation :: here ( ) ) , Fungible ( 200_000 ) ) . into ( ) ) ,
63+ fee_asset_item : 0 ,
64+ }
65+ . get_dispatch_info ( )
66+ . weight ;
67+
68+ assert ! ( weight * 50 < BlockWeights :: get( ) . max_block) ;
69+ }
Original file line number Diff line number Diff line change @@ -31,7 +31,9 @@ trait WeighMultiAssets {
3131 fn weigh_multi_assets ( & self , balances_weight : Weight ) -> Weight ;
3232}
3333
34- // TODO wild case
34+ // Westend only knows about one asset, the balances pallet.
35+ const MAX_ASSETS : u32 = 1 ;
36+
3537impl WeighMultiAssets for MultiAssetFilter {
3638 fn weigh_multi_assets ( & self , balances_weight : Weight ) -> Weight {
3739 match self {
@@ -44,7 +46,7 @@ impl WeighMultiAssets for MultiAssetFilter {
4446 AssetTypes :: Unknown => Weight :: MAX ,
4547 } )
4648 . fold ( 0 , |acc, x| acc. saturating_add ( x) ) ,
47- _ => Weight :: MAX ,
49+ Self :: Wild ( _ ) => ( MAX_ASSETS as Weight ) . saturating_mul ( balances_weight ) ,
4850 }
4951 }
5052}
You can’t perform that action at this time.
0 commit comments