Skip to content

Commit

Permalink
Fix smoke tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yrong committed Apr 6, 2024
1 parent 1e6dac0 commit 3439213
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 10 deletions.
55 changes: 54 additions & 1 deletion smoketest/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion smoketest/make-bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion smoketest/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
15 changes: 8 additions & 7 deletions smoketest/tests/transfer_polkadot_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down Expand Up @@ -72,25 +72,26 @@ 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);

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::<TokenMintedFilter>()
if let Ok(transfers) = erc20_dot
.event::<TransferFilter>()
.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;
}
}
Expand Down

0 comments on commit 3439213

Please sign in to comment.