Skip to content

Commit

Permalink
Shorten upgrade test, make it more reliable
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristianBorst committed Jan 21, 2025
1 parent f23f195 commit c43faa6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
44 changes: 30 additions & 14 deletions integration_tests/test_runner/src/bootstrapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ use clarity::Uint256;
use deep_space::private_key::CosmosPrivateKey;
use deep_space::private_key::PrivateKey;
use deep_space::Contact;
use num::Zero;
use std::fs::File;
use std::io::{BufRead, BufReader, Read, Write};
use std::os::fd::{FromRawFd, IntoRawFd};
use std::path::Path;
use std::process::{Command, ExitStatus, Stdio};
use std::thread;
use std::time::Duration;
use std::time::{Duration, Instant};
use web30::client::Web3;
use web30::jsonrpc::error::Web3Error;

Expand Down Expand Up @@ -251,21 +252,36 @@ pub async fn send_erc20s_to_evm_users(

// The users have been funded, skip sending erc20s
info!("Checking for existing balances, might skip funding");
if !web3
.get_erc20_balance(
*erc20_contracts.first().unwrap(),
*destinations.first().unwrap(),
)
.await
.unwrap()
.is_zero()
{
return Ok(());

// There's a potential for the jsonrpc endpoint to be slow to start (especially in CI on the upgrade test)
// so we give the endpoint a bit to spin up before concluding that
let start = Instant::now();
let mut current_balance = Uint256::zero();
while start - Instant::now() < OPERATION_TIMEOUT {
match web3
.get_erc20_balance(
*erc20_contracts.first().unwrap(),
*destinations.first().unwrap(),
)
.await
{
Ok(balance) => {
current_balance = balance;
break;
}
Err(_) => {
continue;
}
}
}

info!("Actually funding EVM users with the ERC20s");
for erc20 in erc20_contracts {
send_erc20_bulk(amount, erc20, &destinations, web3).await;
if current_balance.is_zero() {
info!("Actually funding EVM users with the ERC20s");
for erc20 in erc20_contracts {
send_erc20_bulk(amount, erc20, &destinations, web3).await;
}
} else {
info!("Skipping funding, balances already exist");
}
Ok(())
}
Expand Down
5 changes: 1 addition & 4 deletions integration_tests/test_runner/src/tests/upgrade.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use crate::utils::{
execute_upgrade_proposal, wait_for_block, UpgradeProposalParams, ValidatorKeys, EVM_USER_KEYS,
};
use althea_proto::cosmos_sdk_proto::cosmos::distribution::v1beta1::{
query_client::QueryClient as DistributionQueryClient, QueryParamsRequest,
};
use clarity::Address as EthAddress;
use deep_space::client::ChainStatus;
use deep_space::{Contact, CosmosPrivateKey};
Expand All @@ -16,7 +13,7 @@ use super::microtx_fees::microtx_fees_test;
use super::native_token::native_token_test;

pub const UPGRADE_NAME: &str = "example";
const UPGRADE_BLOCK_DELTA: u64 = 20;
const UPGRADE_BLOCK_DELTA: u64 = 30;

/// Perform a series of integration tests to seed the system with data, then submit and pass a chain
/// upgrade proposal
Expand Down

0 comments on commit c43faa6

Please sign in to comment.