This repository has been archived by the owner on Oct 22, 2024. It is now read-only.
forked from paritytech/polkadot-sdk
-
Notifications
You must be signed in to change notification settings - Fork 1
Register token with inbound fixture #106
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cadd771
Register token with inbound fixture
yrong e5baada
Import snowbridge-pallet-inbound-queue-fixtures
yrong 8fc508e
Cleanup Cargo.toml
yrong 977cb9f
Update emulated test
yrong d3b3e97
Fix emulated test
yrong e4f4d59
Rename to register_token
yrong ddb0b09
Merge branch 'snowbridge' into ron/refactoring-inbound-fixture
yrong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,12 +13,17 @@ | |
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
use crate::*; | ||
use bridge_hub_rococo_runtime::EthereumBeaconClient; | ||
use codec::{Decode, Encode}; | ||
use emulated_integration_tests_common::xcm_emulator::ConvertLocation; | ||
use frame_support::pallet_prelude::TypeInfo; | ||
use hex_literal::hex; | ||
use parachains_common::rococo::snowbridge::EthereumNetwork; | ||
use rococo_westend_system_emulated_network::BridgeHubRococoParaSender as BridgeHubRococoSender; | ||
use snowbridge_core::outbound::OperatingMode; | ||
use snowbridge_pallet_inbound_queue_fixtures::{ | ||
register_token::make_register_token_message, send_token::make_send_token_message, | ||
}; | ||
use snowbridge_pallet_system; | ||
use snowbridge_router_primitives::inbound::{ | ||
Command, Destination, GlobalConsensusEthereumConvertsFor, MessageV1, VersionedMessage, | ||
|
@@ -187,21 +192,26 @@ fn register_weth_token_from_ethereum_to_asset_hub() { | |
// Fund AssetHub sovereign account so that it can pay execution fees. | ||
BridgeHubRococo::fund_para_sovereign(AssetHubRococo::para_id().into(), INITIAL_FUND); | ||
|
||
let message_id: H256 = [1; 32].into(); | ||
|
||
BridgeHubRococo::execute_with(|| { | ||
type RuntimeEvent = <BridgeHubRococo as Chain>::RuntimeEvent; | ||
type RuntimeOrigin = <BridgeHubRococo as Chain>::RuntimeOrigin; | ||
type EthereumInboundQueue = | ||
<BridgeHubRococo as BridgeHubRococoPallet>::EthereumInboundQueue; | ||
let message = VersionedMessage::V1(MessageV1 { | ||
chain_id: CHAIN_ID, | ||
command: Command::RegisterToken { token: WETH.into(), fee: XCM_FEE }, | ||
}); | ||
let (xcm, fee) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); | ||
|
||
assert_ok!(EthereumInboundQueue::burn_fees(AssetHubRococo::para_id().into(), fee)); | ||
let register_asset_message = make_register_token_message(); | ||
|
||
let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubRococo::para_id().into()).unwrap(); | ||
EthereumBeaconClient::store_execution_header( | ||
register_asset_message.message.proof.block_hash, | ||
register_asset_message.execution_header, | ||
0, | ||
H256::default(), | ||
); | ||
|
||
EthereumInboundQueue::submit( | ||
RuntimeOrigin::signed(BridgeHubRococoSender::get()), | ||
register_asset_message.message, | ||
) | ||
.unwrap(); | ||
Comment on lines
+203
to
+214
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm I'm not sure this change is a good one. What do you think is the benefit of changing this? I feel like the previous way is clearer to read and understand what is happening, imo. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To not expose the internal implementation details to the tests. |
||
|
||
assert_expected_events!( | ||
BridgeHubRococo, | ||
|
@@ -346,36 +356,42 @@ fn send_token_from_ethereum_to_asset_hub() { | |
// Fund ethereum sovereign on AssetHub | ||
AssetHubRococo::fund_accounts(vec![(AssetHubRococoReceiver::get(), INITIAL_FUND)]); | ||
|
||
let message_id: H256 = [1; 32].into(); | ||
|
||
BridgeHubRococo::execute_with(|| { | ||
type RuntimeEvent = <BridgeHubRococo as Chain>::RuntimeEvent; | ||
type RuntimeOrigin = <BridgeHubRococo as Chain>::RuntimeOrigin; | ||
type EthereumInboundQueue = | ||
<BridgeHubRococo as BridgeHubRococoPallet>::EthereumInboundQueue; | ||
// Construct RegisterToken message | ||
let message = VersionedMessage::V1(MessageV1 { | ||
chain_id: CHAIN_ID, | ||
command: Command::RegisterToken { token: WETH.into(), fee: XCM_FEE }, | ||
}); | ||
// Convert the message to XCM | ||
let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); | ||
// Send the XCM | ||
let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubRococo::para_id().into()).unwrap(); | ||
|
||
let register_asset_message = make_register_token_message(); | ||
|
||
EthereumBeaconClient::store_execution_header( | ||
register_asset_message.message.proof.block_hash, | ||
register_asset_message.execution_header, | ||
0, | ||
H256::default(), | ||
); | ||
|
||
EthereumInboundQueue::submit( | ||
RuntimeOrigin::signed(BridgeHubRococoSender::get()), | ||
register_asset_message.message, | ||
) | ||
.unwrap(); | ||
|
||
// Construct SendToken message | ||
let message = VersionedMessage::V1(MessageV1 { | ||
chain_id: CHAIN_ID, | ||
command: Command::SendToken { | ||
token: WETH.into(), | ||
destination: Destination::AccountId32 { id: AssetHubRococoReceiver::get().into() }, | ||
amount: 1_000_000_000, | ||
fee: XCM_FEE, | ||
}, | ||
}); | ||
// Convert the message to XCM | ||
let (xcm, _) = EthereumInboundQueue::do_convert(message_id, message).unwrap(); | ||
// Send the XCM | ||
let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubRococo::para_id().into()).unwrap(); | ||
let send_token_message = make_send_token_message(); | ||
|
||
EthereumBeaconClient::store_execution_header( | ||
send_token_message.message.proof.block_hash, | ||
send_token_message.execution_header, | ||
0, | ||
H256::default(), | ||
); | ||
|
||
EthereumInboundQueue::submit( | ||
RuntimeOrigin::signed(BridgeHubRococoSender::get()), | ||
send_token_message.message, | ||
) | ||
.unwrap(); | ||
|
||
// Check that the message was sent | ||
assert_expected_events!( | ||
|
@@ -436,7 +452,8 @@ fn send_weth_asset_from_asset_hub_to_ethereum() { | |
command: Command::RegisterToken { token: WETH.into(), fee: XCM_FEE }, | ||
}); | ||
// Converts the versioned message to XCM | ||
let (xcm, _) = EthereumInboundQueue::do_convert(message_id_register_token, message).unwrap(); | ||
let (xcm, _) = | ||
EthereumInboundQueue::do_convert(message_id_register_token, message).unwrap(); | ||
let _ = EthereumInboundQueue::send_xcm(xcm, AssetHubRococo::para_id().into()).unwrap(); | ||
|
||
// Check that the register token message was sent using xcm | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! :)