From cebd323bbd19ade207c8d256462bcc712928a69e Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Fri, 7 Jun 2024 13:06:03 +0200 Subject: [PATCH 1/3] Use `assert_ok!(` instead of unwrap --- .../bridge-hub-rococo/src/tests/snowbridge.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs index 1c1c51404aa4..8196b27cfe02 100644 --- a/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs +++ b/cumulus/parachains/integration-tests/emulated/tests/bridges/bridge-hub-rococo/src/tests/snowbridge.rs @@ -215,7 +215,7 @@ fn register_weth_token_from_ethereum_to_asset_hub() { // Construct RegisterToken message and sent to inbound queue let register_token_message = make_register_token_message(); - send_inbound_message(register_token_message.clone()).unwrap(); + assert_ok!(send_inbound_message(register_token_message.clone())); assert_expected_events!( BridgeHubRococo, @@ -250,10 +250,10 @@ fn send_token_from_ethereum_to_asset_hub() { type RuntimeEvent = ::RuntimeEvent; // Construct RegisterToken message and sent to inbound queue - send_inbound_message(make_register_token_message()).unwrap(); + assert_ok!(send_inbound_message(make_register_token_message())); // Construct SendToken message and sent to inbound queue - send_inbound_message(make_send_token_message()).unwrap(); + assert_ok!(send_inbound_message(make_send_token_message())); // Check that the message was sent assert_expected_events!( @@ -332,14 +332,14 @@ fn send_token_from_ethereum_to_penpal() { type RuntimeEvent = ::RuntimeEvent; // Construct RegisterToken message and sent to inbound queue - send_inbound_message(make_register_token_message()).unwrap(); + assert_ok!(send_inbound_message(make_register_token_message())); // Construct SendToken message to AssetHub(only for increase the nonce as the same order in // smoke test) - send_inbound_message(make_send_token_message()).unwrap(); + assert_ok!(send_inbound_message(make_send_token_message())); // Construct SendToken message and sent to inbound queue - send_inbound_message(make_send_token_to_penpal_message()).unwrap(); + assert_ok!(send_inbound_message(make_send_token_to_penpal_message())); assert_expected_events!( BridgeHubRococo, @@ -399,7 +399,7 @@ fn send_weth_asset_from_asset_hub_to_ethereum() { type RuntimeEvent = ::RuntimeEvent; // Construct RegisterToken message and sent to inbound queue - send_inbound_message(make_register_token_message()).unwrap(); + assert_ok!(send_inbound_message(make_register_token_message())); // Check that the register token message was sent using xcm assert_expected_events!( @@ -410,7 +410,7 @@ fn send_weth_asset_from_asset_hub_to_ethereum() { ); // Construct SendToken message and sent to inbound queue - send_inbound_message(make_send_token_message()).unwrap(); + assert_ok!(send_inbound_message(make_send_token_message())); // Check that the send token message was sent using xcm assert_expected_events!( From 041ded69da2d5728c1558baefb67e55e01f50312 Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Fri, 7 Jun 2024 13:16:59 +0200 Subject: [PATCH 2/3] Nit for universal_alias --- .../parachains/runtimes/assets/asset-hub-rococo/src/lib.rs | 6 ++---- .../parachains/runtimes/assets/asset-hub-westend/src/lib.rs | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs index 2bf09e6a7843..d75b07bd2b9f 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/lib.rs @@ -1644,10 +1644,8 @@ impl_runtime_apis! { } fn universal_alias() -> Result<(Location, Junction), BenchmarkError> { - match xcm_config::bridging::BridgingBenchmarksHelper::prepare_universal_alias() { - Some(alias) => Ok(alias), - None => Err(BenchmarkError::Skip) - } + xcm_config::bridging::BridgingBenchmarksHelper::prepare_universal_alias() + .ok_or(BenchmarkError::Skip) } fn transact_origin_and_runtime_call() -> Result<(Location, RuntimeCall), BenchmarkError> { diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs index d9249cdfc482..e9c2b10f719d 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/lib.rs @@ -1735,10 +1735,8 @@ impl_runtime_apis! { } fn universal_alias() -> Result<(Location, Junction), BenchmarkError> { - match xcm_config::bridging::BridgingBenchmarksHelper::prepare_universal_alias() { - Some(alias) => Ok(alias), - None => Err(BenchmarkError::Skip) - } + xcm_config::bridging::BridgingBenchmarksHelper::prepare_universal_alias() + .ok_or(BenchmarkError::Skip) } fn transact_origin_and_runtime_call() -> Result<(Location, RuntimeCall), BenchmarkError> { From 7376bd74799594ced919a99441cfb10eda35f69c Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Fri, 7 Jun 2024 13:19:03 +0200 Subject: [PATCH 3/3] Nit for `prepare_universal_alias` --- .../runtimes/assets/asset-hub-rococo/src/xcm_config.rs | 3 +-- .../runtimes/assets/asset-hub-westend/src/xcm_config.rs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs index 664d2b9c9dd5..cf5a3905e581 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/xcm_config.rs @@ -699,8 +699,7 @@ pub mod bridging { false => None, } }); - assert!(alias.is_some(), "we expect here BridgeHubRococo to Westend mapping at least"); - Some(alias.unwrap()) + Some(alias.expect("we expect here BridgeHubRococo to Westend mapping at least")) } } } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs index 35a42627ad71..ff1fc99cba8a 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/xcm_config.rs @@ -648,8 +648,7 @@ pub mod bridging { false => None, } }); - assert!(alias.is_some(), "we expect here BridgeHubWestend to Rococo mapping at least"); - Some(alias.unwrap()) + Some(alias.expect("we expect here BridgeHubWestend to Rococo mapping at least")) } } }