@@ -34,7 +34,7 @@ use sp_core::H160;
3434use sp_keyring:: AccountKeyring :: Alice ;
3535use sp_runtime:: {
3636 generic:: { Era , SignedPayload } ,
37- AccountId32 ,
37+ AccountId32 , Perbill ,
3838} ;
3939use testnet_parachains_constants:: rococo:: {
4040 consensus:: RELAY_CHAIN_SLOT_DURATION_MILLIS , fee:: WeightToFee ,
@@ -400,53 +400,61 @@ mod bridge_hub_westend_tests {
400400
401401 #[ test]
402402 pub fn can_calculate_weight_for_paid_export_message_with_reserve_transfer ( ) {
403- let estimated = bridge_hub_test_utils:: test_cases:: can_calculate_weight_for_paid_export_message_with_reserve_transfer :: <
404- Runtime ,
405- XcmConfig ,
406- WeightToFee ,
407- > ( ) ;
408-
409- // check if estimated value is sane
410- let max_expected = bp_bridge_hub_rococo:: BridgeHubRococoBaseXcmFeeInRocs :: get ( ) ;
411- assert ! (
412- estimated <= max_expected,
413- "calculated: {:?}, max_expected: {:?}, please adjust `bp_bridge_hub_rococo::BridgeHubRococoBaseXcmFeeInRocs` value" ,
414- estimated,
415- max_expected
416- ) ;
403+ bridge_hub_test_utils:: check_sane_fees_values (
404+ "bp_bridge_hub_rococo::BridgeHubRococoBaseXcmFeeInRocs" ,
405+ bp_bridge_hub_rococo:: BridgeHubRococoBaseXcmFeeInRocs :: get ( ) ,
406+ || {
407+ bridge_hub_test_utils:: test_cases:: can_calculate_weight_for_paid_export_message_with_reserve_transfer :: <
408+ Runtime ,
409+ XcmConfig ,
410+ WeightToFee ,
411+ > ( )
412+ } ,
413+ Perbill :: from_percent ( 33 ) ,
414+ Some ( -33 ) ,
415+ & format ! (
416+ "Estimate fee for `ExportMessage` for runtime: {:?}" ,
417+ <Runtime as frame_system:: Config >:: Version :: get( )
418+ ) ,
419+ )
417420 }
418421
419422 #[ test]
420423 pub fn can_calculate_fee_for_complex_message_delivery_transaction ( ) {
421- let estimated = from_parachain:: can_calculate_fee_for_complex_message_delivery_transaction :: <
422- RuntimeTestsAdapter ,
423- > ( collator_session_keys ( ) , construct_and_estimate_extrinsic_fee) ;
424-
425- // check if estimated value is sane
426- let max_expected = bp_bridge_hub_rococo:: BridgeHubRococoBaseDeliveryFeeInRocs :: get ( ) ;
427- assert ! (
428- estimated <= max_expected,
429- "calculated: {:?}, max_expected: {:?}, please adjust `bp_bridge_hub_rococo::BridgeHubRococoBaseDeliveryFeeInRocs` value" ,
430- estimated,
431- max_expected
432- ) ;
424+ bridge_hub_test_utils:: check_sane_fees_values (
425+ "bp_bridge_hub_rococo::BridgeHubRococoBaseDeliveryFeeInRocs" ,
426+ bp_bridge_hub_rococo:: BridgeHubRococoBaseDeliveryFeeInRocs :: get ( ) ,
427+ || {
428+ from_parachain:: can_calculate_fee_for_complex_message_delivery_transaction :: <
429+ RuntimeTestsAdapter ,
430+ > ( collator_session_keys ( ) , construct_and_estimate_extrinsic_fee)
431+ } ,
432+ Perbill :: from_percent ( 33 ) ,
433+ Some ( -33 ) ,
434+ & format ! (
435+ "Estimate fee for `single message delivery` for runtime: {:?}" ,
436+ <Runtime as frame_system:: Config >:: Version :: get( )
437+ ) ,
438+ )
433439 }
434440
435441 #[ test]
436442 pub fn can_calculate_fee_for_complex_message_confirmation_transaction ( ) {
437- let estimated =
438- from_parachain:: can_calculate_fee_for_complex_message_confirmation_transaction :: <
439- RuntimeTestsAdapter ,
440- > ( collator_session_keys ( ) , construct_and_estimate_extrinsic_fee) ;
441-
442- // check if estimated value is sane
443- let max_expected = bp_bridge_hub_rococo:: BridgeHubRococoBaseConfirmationFeeInRocs :: get ( ) ;
444- assert ! (
445- estimated <= max_expected,
446- "calculated: {:?}, max_expected: {:?}, please adjust `bp_bridge_hub_rococo::BridgeHubRococoBaseConfirmationFeeInRocs` value" ,
447- estimated,
448- max_expected
449- ) ;
443+ bridge_hub_test_utils:: check_sane_fees_values (
444+ "bp_bridge_hub_rococo::BridgeHubRococoBaseConfirmationFeeInRocs" ,
445+ bp_bridge_hub_rococo:: BridgeHubRococoBaseConfirmationFeeInRocs :: get ( ) ,
446+ || {
447+ from_parachain:: can_calculate_fee_for_complex_message_confirmation_transaction :: <
448+ RuntimeTestsAdapter ,
449+ > ( collator_session_keys ( ) , construct_and_estimate_extrinsic_fee)
450+ } ,
451+ Perbill :: from_percent ( 33 ) ,
452+ Some ( -33 ) ,
453+ & format ! (
454+ "Estimate fee for `single message confirmation` for runtime: {:?}" ,
455+ <Runtime as frame_system:: Config >:: Version :: get( )
456+ ) ,
457+ )
450458 }
451459}
452460
@@ -594,55 +602,43 @@ mod bridge_hub_bulletin_tests {
594602 ) ;
595603 }
596604
597- #[ test]
598- pub fn can_calculate_weight_for_paid_export_message_with_reserve_transfer ( ) {
599- let estimated = bridge_hub_test_utils:: test_cases:: can_calculate_weight_for_paid_export_message_with_reserve_transfer :: <
600- Runtime ,
601- XcmConfig ,
602- WeightToFee ,
603- > ( ) ;
604-
605- // check if estimated value is sane
606- let max_expected = bp_bridge_hub_rococo:: BridgeHubRococoBaseXcmFeeInRocs :: get ( ) ;
607- assert ! (
608- estimated <= max_expected,
609- "calculated: {:?}, max_expected: {:?}, please adjust `bp_bridge_hub_rococo::BridgeHubRococoBaseXcmFeeInRocs` value" ,
610- estimated,
611- max_expected
612- ) ;
613- }
614-
615605 #[ test]
616606 pub fn can_calculate_fee_for_complex_message_delivery_transaction ( ) {
617- let estimated =
618- from_grandpa_chain:: can_calculate_fee_for_complex_message_delivery_transaction :: <
619- RuntimeTestsAdapter ,
620- > ( collator_session_keys ( ) , construct_and_estimate_extrinsic_fee) ;
621-
622- // check if estimated value is sane
623- let max_expected = bp_bridge_hub_rococo:: BridgeHubRococoBaseDeliveryFeeInRocs :: get ( ) ;
624- assert ! (
625- estimated <= max_expected,
626- "calculated: {:?}, max_expected: {:?}, please adjust `bp_bridge_hub_rococo::BridgeHubRococoBaseDeliveryFeeInRocs` value" ,
627- estimated,
628- max_expected
629- ) ;
607+ bridge_hub_test_utils:: check_sane_fees_values (
608+ "bp_bridge_hub_rococo::BridgeHubRococoBaseDeliveryFeeInRocs" ,
609+ bp_bridge_hub_rococo:: BridgeHubRococoBaseDeliveryFeeInRocs :: get ( ) ,
610+ || {
611+ from_grandpa_chain:: can_calculate_fee_for_complex_message_delivery_transaction :: <
612+ RuntimeTestsAdapter ,
613+ > ( collator_session_keys ( ) , construct_and_estimate_extrinsic_fee)
614+ } ,
615+ Perbill :: from_percent ( 33 ) ,
616+ None , /* we don't want lowering according to the Bulletin setup, because
617+ * `from_grandpa_chain` is cheaper then `from_parachain_chain` */
618+ & format ! (
619+ "Estimate fee for `single message delivery` for runtime: {:?}" ,
620+ <Runtime as frame_system:: Config >:: Version :: get( )
621+ ) ,
622+ )
630623 }
631624
632625 #[ test]
633626 pub fn can_calculate_fee_for_complex_message_confirmation_transaction ( ) {
634- let estimated =
635- from_grandpa_chain:: can_calculate_fee_for_complex_message_confirmation_transaction :: <
636- RuntimeTestsAdapter ,
637- > ( collator_session_keys ( ) , construct_and_estimate_extrinsic_fee) ;
638-
639- // check if estimated value is sane
640- let max_expected = bp_bridge_hub_rococo:: BridgeHubRococoBaseConfirmationFeeInRocs :: get ( ) ;
641- assert ! (
642- estimated <= max_expected,
643- "calculated: {:?}, max_expected: {:?}, please adjust `bp_bridge_hub_rococo::BridgeHubRococoBaseConfirmationFeeInRocs` value" ,
644- estimated,
645- max_expected
646- ) ;
627+ bridge_hub_test_utils:: check_sane_fees_values (
628+ "bp_bridge_hub_rococo::BridgeHubRococoBaseConfirmationFeeInRocs" ,
629+ bp_bridge_hub_rococo:: BridgeHubRococoBaseConfirmationFeeInRocs :: get ( ) ,
630+ || {
631+ from_grandpa_chain:: can_calculate_fee_for_complex_message_confirmation_transaction :: <
632+ RuntimeTestsAdapter ,
633+ > ( collator_session_keys ( ) , construct_and_estimate_extrinsic_fee)
634+ } ,
635+ Perbill :: from_percent ( 33 ) ,
636+ None , /* we don't want lowering according to the Bulletin setup, because
637+ * `from_grandpa_chain` is cheaper then `from_parachain_chain` */
638+ & format ! (
639+ "Estimate fee for `single message confirmation` for runtime: {:?}" ,
640+ <Runtime as frame_system:: Config >:: Version :: get( )
641+ ) ,
642+ )
647643 }
648644}
0 commit comments