Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test fixture to send WETH to a non-existent account on AssetHub #1174

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions smoketest/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ lazy_static! {
.expect("cannot create keypair");
pub static ref BOB_PUBLIC: [u8; 32] = (*BOB).public().into();

pub static ref NOEXIST: Pair = Pair::from_string("//NoExist", None)
.expect("cannot create keypair");
pub static ref NOEXIST_PUBLIC: [u8; 32] = (*NOEXIST).public().into();

pub static ref REGISTER_TOKEN_FEE: u64 = env::var("REGISTER_TOKEN_FEE")
.unwrap_or("200000000000000000".to_string())
.parse()
Expand Down
6 changes: 4 additions & 2 deletions smoketest/tests/send_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ async fn send_token() {
.await
.unwrap();

println!("beneficiary: {:#?}", hex::encode::<Vec<u8>>((*NOEXIST_PUBLIC).into()));

// Lock tokens into vault
let amount: u128 = U256::from(value).low_u128();
let receipt = gateway
.send_token(
weth.address(),
ASSET_HUB_PARA_ID,
i_gateway::MultiAddress { kind: 1, data: (*BOB_PUBLIC).into() },
i_gateway::MultiAddress { kind: 1, data: (*NOEXIST_PUBLIC).into() },
destination_fee,
amount,
)
Expand Down Expand Up @@ -104,7 +106,7 @@ async fn send_token() {
AccountKey20 { network: None, key: WETH_CONTRACT.into() },
),
};
let expected_owner: AccountId32 = (*BOB_PUBLIC).into();
let expected_owner: AccountId32 = (*NOEXIST_PUBLIC).into();

let mut issued_event_found = false;
while let Some(Ok(block)) = blocks.next().await {
Expand Down
16 changes: 11 additions & 5 deletions smoketest/tests/send_token_to_penpal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ async fn send_token_to_penpal() {
.unwrap();
assert_eq!(receipt.status.unwrap().as_u64(), 1u64);

let destination_fee = 4_000_000_000;
// Sending to an account non-existent so the destination_fee here should cover the ED on penpal
// https://github.com/Snowfork/polkadot-sdk/blob/68ab248801fdadef7ef4923c21d6b9d55a5f15b4/cumulus/parachains/runtimes/testing/penpal/src/lib.rs#L265
let destination_fee = 40_000_000_000;
let fee = gateway
.quote_send_token_fee(weth.address(), PENPAL_PARA_ID, destination_fee)
.call()
Expand All @@ -74,8 +76,8 @@ async fn send_token_to_penpal() {
.send_token(
weth.address(),
PENPAL_PARA_ID,
i_gateway::MultiAddress { kind: 1, data: (*FERDIE_PUBLIC).into() },
4_000_000_000,
i_gateway::MultiAddress { kind: 1, data: (*NOEXIST_PUBLIC).into() },
destination_fee,
amount,
)
.value(fee)
Expand All @@ -86,7 +88,11 @@ async fn send_token_to_penpal() {
.unwrap()
.unwrap();

println!("receipt: {:#?}", receipt);
println!(
"receipt transaction hash: {:#?}, transaction block: {:#?}",
hex::encode(receipt.transaction_hash),
receipt.block_number
);

assert_eq!(receipt.status.unwrap().as_u64(), 1u64);

Expand Down Expand Up @@ -133,7 +139,7 @@ async fn send_token_to_penpal() {
.expect("block subscription")
.take(wait_for_blocks);

let penpal_expected_owner: AccountId32 = (*FERDIE_PUBLIC).into();
let penpal_expected_owner: AccountId32 = (*NOEXIST_PUBLIC).into();

issued_event_found = false;
while let Some(Ok(block)) = penpal_blocks.next().await {
Expand Down
11 changes: 11 additions & 0 deletions web/packages/test/scripts/configure-substrate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,24 @@ config_xcm_version() {
send_governance_transact_from_relaychain $ASSET_HUB_PARAID "$call"
}

config_penpal() {
# System::set_storage(CustomizableAssetFromSystemAssetHub,Ethereum)
local call=0x00040440770800eb78be69c327d8334d0927607220020109079edaa802
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's why we print the key value in Snowfork/polkadot-sdk#137 (comment)

send_governance_transact_from_relaychain $PENPAL_PARAID "$call"

# foreignAssets::force_create(WETH)
local call=0x3301020209079edaa802030087d1f7fdfee7f651fabc8bfcb6e086c278b77a7d00d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d0104
send_governance_transact_from_relaychain $PENPAL_PARAID "$call"
}

configure_substrate() {
set_gateway
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set_gateway
config_penpal &
set_gateway

Copy link
Contributor Author

@yrong yrong Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Penpal is not allowed to execute sudo operation through xcm, it's a test chain which itself has the sudo pallet.

Explicit the call here but not execute, only for a hint.

fund_accounts
wait_beacon_chain_ready
config_beacon_checkpoint
open_hrmp_channels
config_xcm_version
config_penpal
}

if [ -z "${from_start_services:-}" ]; then
Expand Down
2 changes: 2 additions & 0 deletions web/packages/test/scripts/set-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export PENPAL_CHANNEL_ID="0xa69fbbae90bb6096d59b1930bbcfc8a3ef23959d226b1861deb7
export PRIMARY_GOVERNANCE_CHANNEL_ID="0x0000000000000000000000000000000000000000000000000000000000000001"
export SECONDARY_GOVERNANCE_CHANNEL_ID="0x0000000000000000000000000000000000000000000000000000000000000002"

export PENPAL_PARAID="${PENPAL_PARAID:-2000}"

# Token decimal of the relaychain(KSM|ROC:12,DOT:10)
export FOREIGN_TOKEN_DECIMALS=12

Expand Down