From 343921360234e31870f33c6c4d7b2acb556b1dc1 Mon Sep 17 00:00:00 2001 From: ron Date: Sat, 6 Apr 2024 23:15:05 +0800 Subject: [PATCH] Fix smoke tests --- smoketest/Cargo.lock | 55 +++++++++++++++++++++- smoketest/make-bindings.sh | 2 +- smoketest/src/constants.rs | 2 +- smoketest/tests/transfer_polkadot_token.rs | 15 +++--- 4 files changed, 64 insertions(+), 10 deletions(-) diff --git a/smoketest/Cargo.lock b/smoketest/Cargo.lock index 5586f962de..b9dbef6854 100644 --- a/smoketest/Cargo.lock +++ b/smoketest/Cargo.lock @@ -896,6 +896,12 @@ dependencies = [ "thiserror", ] +[[package]] +name = "common-path" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2382f75942f4b3be3690fe4f86365e9c853c1587d6ee58212cebf6e2a9ccd101" + [[package]] name = "concurrent-queue" version = "2.4.0" @@ -1233,6 +1239,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive-syn-parse" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d65d7ce8132b7c0e54497a4d9a55a1c2a0912a0d786cf894472ba818fba45762" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.55", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -1276,6 +1293,33 @@ dependencies = [ "subtle", ] +[[package]] +name = "docify" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a2f138ad521dc4a2ced1a4576148a6a610b4c5923933b062a263130a6802ce" +dependencies = [ + "docify_macros", +] + +[[package]] +name = "docify_macros" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a081e51fb188742f5a7a1164ad752121abcb22874b21e2c3b0dd040c515fdad" +dependencies = [ + "common-path", + "derive-syn-parse", + "once_cell", + "proc-macro2", + "quote", + "regex", + "syn 2.0.55", + "termcolor", + "toml", + "walkdir", +] + [[package]] name = "downcast-rs" version = "1.2.0" @@ -4477,6 +4521,7 @@ dependencies = [ name = "sp-arithmetic" version = "23.0.0" dependencies = [ + "docify", "integer-sqrt", "num-traits", "parity-scale-codec", @@ -4809,7 +4854,6 @@ dependencies = [ "smallvec", "sp-arithmetic 23.0.0", "sp-debug-derive 14.0.0", - "sp-std 14.0.0", ] [[package]] @@ -5112,6 +5156,15 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + [[package]] name = "thiserror" version = "1.0.56" diff --git a/smoketest/make-bindings.sh b/smoketest/make-bindings.sh index 9f19656d40..0ce4c7c137 100755 --- a/smoketest/make-bindings.sh +++ b/smoketest/make-bindings.sh @@ -6,7 +6,7 @@ mkdir -p src/contracts # Generate Rust bindings for contracts forge bind --module --overwrite \ - --select 'IGateway|WETH9|GatewayUpgradeMock|AgentExecutor' \ + --select 'IGateway|WETH9|GatewayUpgradeMock|ERC20' \ --bindings-path src/contracts \ --root ../contracts diff --git a/smoketest/src/constants.rs b/smoketest/src/constants.rs index 84613afd84..a0ff29af36 100644 --- a/smoketest/src/constants.rs +++ b/smoketest/src/constants.rs @@ -27,7 +27,7 @@ pub const GATEWAY_PROXY_CONTRACT: [u8; 20] = hex!("EDa338E4dC46038493b885327842f pub const WETH_CONTRACT: [u8; 20] = hex!("87d1f7fdfEe7f651FaBc8bFCB6E086C278b77A7d"); pub const AGENT_EXECUTOR_CONTRACT: [u8; 20] = hex!("2ffA5ecdBe006d30397c7636d3e015EEE251369F"); -pub const ERC20_DOT_CONTRACT: [u8; 20] = hex!("97d3fC1832792ae4f1D48fEA3E00dc73A9101bf9"); +pub const ERC20_DOT_CONTRACT: [u8; 20] = hex!("B501F2C3051dC8919FAFf398326a705B1f33402A"); pub const ERC20_DOT_TOKEN_ID: [u8; 32] = hex!("83ca7bdddc0205caa1d663fdba16db38a4c702f4dcc07b8589d5ed912610a19d"); diff --git a/smoketest/tests/transfer_polkadot_token.rs b/smoketest/tests/transfer_polkadot_token.rs index cdd63793f9..f9c3b5a763 100644 --- a/smoketest/tests/transfer_polkadot_token.rs +++ b/smoketest/tests/transfer_polkadot_token.rs @@ -7,7 +7,7 @@ use ethers::{ use futures::StreamExt; use snowbridge_smoketest::{ constants::*, - contracts::{agent_executor, agent_executor::TokenMintedFilter}, + contracts::{erc20, erc20::TransferFilter}, helper::AssetHubConfig, parachains::assethub::{ api::runtime_types::{ @@ -72,9 +72,8 @@ async fn transfer_polkadot_token() { .await .expect("call success"); - let agent_executor_addr: Address = AGENT_EXECUTOR_CONTRACT.into(); - let agent_executor = - agent_executor::AgentExecutor::new(agent_executor_addr, ethereum_client.clone()); + let erc20_dot_address: Address = ERC20_DOT_CONTRACT.into(); + let erc20_dot = erc20::ERC20::new(erc20_dot_address, ethereum_client.clone()); let wait_for_blocks = 500; let mut stream = ethereum_client.subscribe_blocks().await.unwrap().take(wait_for_blocks); @@ -82,15 +81,17 @@ async fn transfer_polkadot_token() { let mut transfer_event_found = false; while let Some(block) = stream.next().await { println!("Polling ethereum block {:?} for transfer event", block.number.unwrap()); - if let Ok(transfers) = agent_executor - .event::() + if let Ok(transfers) = erc20_dot + .event::() .at_block_hash(block.hash.unwrap()) .query() .await { for transfer in transfers { println!("Transfer event found at ethereum block {:?}", block.number.unwrap()); - println!("token id {:?}", transfer.token_id); + println!("from {:?}", transfer.from); + println!("to {:?}", transfer.to); + assert_eq!(transfer.value, amount.into()); transfer_event_found = true; } }