commit 74d55ab427d989e1adfff9ce5b6de4206574e549
parent 0c4064febbb7239f06a1eed01bb8e00e6c09398f
Author: Antoine A <>
Date: Tue, 8 Jul 2025 12:07:54 +0200
common: remove online tests
Diffstat:
6 files changed, 117 insertions(+), 526 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
@@ -321,9 +321,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5"
[[package]]
name = "cc"
-version = "1.2.27"
+version = "1.2.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d487aa071b5f64da6f19a3e848e3578944b726ee5a4854b82172f02aa876bfdc"
+checksum = "5c1599538de2394445747c8cf7935946e3cc27e9625f889d979bfb2aaf569362"
dependencies = [
"shlex",
]
@@ -1307,9 +1307,9 @@ dependencies = [
[[package]]
name = "hyper-util"
-version = "0.1.14"
+version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dc2fdfdbff08affe55bb779f33b053aa1fe5dd5b54c257343c17edfa55711bdb"
+checksum = "7f66d5bd4c6f02bf0542fad85d626775bab9258cf795a4256dcaf3161114d1df"
dependencies = [
"bytes",
"futures-core",
@@ -3046,9 +3046,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tokio"
-version = "1.46.0"
+version = "1.46.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1140bb80481756a8cbe10541f37433b459c5aa1e727b4c020fbfebdc25bf3ec4"
+checksum = "0cc3a2344dafbe23a245241fe8b09735b521110d30fcefbbd5feb1797ca35d17"
dependencies = [
"backtrace",
"bytes",
diff --git a/instrumentation/src/btc.rs b/instrumentation/src/btc.rs
@@ -21,7 +21,7 @@ use std::{
time::Duration,
};
-use bitcoin::{Address, Amount, BlockHash, SignedAmount};
+use bitcoin::{Address, Amount};
use common::taler_common::{
api_common::{EddsaPublicKey, ShortHashCode},
types::base32::Base32,
@@ -39,189 +39,10 @@ use taler_common::{config::Config, types::payto::Payto};
use tempfile::TempDir;
use crate::utils::{
- ChildGuard, TalerCtx, TestCtx, cmd_redirect, patch_config, print_now, retry, retry_opt,
- transfer, unused_port,
+ ChildGuard, TalerCtx, TestCtx, cmd_redirect, patch_config, retry, retry_opt, transfer,
+ unused_port,
};
-pub const CLIENT: &str = "client";
-pub const WIRE: &str = "wire";
-
-fn unsigned(amount: SignedAmount) -> Amount {
- amount.abs().to_unsigned().unwrap()
-}
-
-fn wait_for_pending(since: &mut BlockHash, client_rpc: &mut Rpc, wire_rpc: &mut Rpc) {
- print_now("Wait for pending transactions mining:");
- 'l: loop {
- std::thread::sleep(Duration::from_secs(1)); // Wait for btc-wire to act
- let sync = client_rpc.list_since_block(Some(since), 1).unwrap();
- let sync2 = wire_rpc.list_since_block(Some(since), 1).unwrap();
- *since = sync.lastblock;
- for tx in sync
- .transactions
- .into_iter()
- .chain(sync2.transactions.into_iter())
- {
- if tx.confirmations == 0 {
- client_rpc.wait_for_new_block().unwrap();
- print_now(".");
- continue 'l;
- }
- }
- break;
- }
- println!();
-}
-
-pub fn online_test(config: Option<&Path>, base_url: &str) {
- todo!();
- /*let state = WireState::parse(config);
-
- if state.btc_config.network == Network::Bitcoin {
- panic!("You should never run this test on a real bitcoin network");
- }
- let mut rpc = Rpc::common(&state.btc_config).expect("Cannot connect to bitcoin node");
-
- // Load client
- match rpc.load_wallet(CLIENT) {
- Ok(_) => {}
- Err(rpc::Error::RPC {
- code: ErrorCode::RpcWalletNotFound,
- ..
- }) => {
- rpc.create_wallet(CLIENT, "").unwrap();
- }
- Err(rpc::Error::RPC {
- code: ErrorCode::RpcWalletError | ErrorCode::RpcWalletAlreadyLoaded,
- ..
- }) => {}
- Err(e) => panic!("{}", e),
- };
- let mut client_rpc = Rpc::wallet(&state.btc_config, CLIENT).unwrap();
- let client_addr = client_rpc.gen_addr().unwrap();
- let min_fund = Amount::from_sat(10_000);
- if client_rpc.get_balance().unwrap() < min_fund {
- println!(
- "Client need a minimum of {} BTC to run this test, send coins to this address: {}",
- min_fund.to_btc(),
- client_addr
- );
- print_now("Waiting for fund:");
- while client_rpc.get_balance().unwrap() < min_fund {
- client_rpc.wait_for_new_block().unwrap();
- print_now(".");
- }
- println!();
- }
- let mut since = client_rpc.list_since_block(None, 1).unwrap().lastblock;
- // Load wire
- let mut wire_rpc = Rpc::wallet(&state.btc_config, WIRE).unwrap();
- let wire_addr = wire_rpc.gen_addr().unwrap();
-
- wait_for_pending(&mut since, &mut client_rpc, &mut wire_rpc);
-
- // Load balances
- let client_balance = client_rpc.get_balance().unwrap();
- let wire_balance = wire_rpc.get_balance().unwrap();
- // Test amount
- let test_amount = Amount::from_sat(2000);
- let min_send_amount = rpc_utils::segwit_min_amount(); // To small to send back
- let min_bounce_amount = min_send_amount + Amount::from_sat(999); // To small after bounce fee
- let taler_test_amount = btc_to_taler(&test_amount.to_signed().unwrap(), state.currency);
-
- println!("Send transaction");
- let reserve_pub_key = Base32::rand();
- let credit_id = client_rpc
- .send_segwit_key(&wire_addr, &test_amount, &reserve_pub_key)
- .unwrap();
- let bounce_min_id = client_rpc
- .send(&wire_addr, &min_bounce_amount, None, false)
- .unwrap();
- let send_min_id = client_rpc
- .send(&wire_addr, &min_send_amount, None, false)
- .unwrap();
- let bounce_id = client_rpc
- .send(&wire_addr, &test_amount, None, false)
- .unwrap();
- let client_sent_amount_cost =
- test_amount + min_send_amount * 2 + min_bounce_amount + min_send_amount + test_amount;
- let client_sent_fees_cost: Amount = [credit_id, bounce_min_id, send_min_id, bounce_id]
- .into_iter()
- .map(|id| unsigned(client_rpc.get_tx(&id).unwrap().fee.unwrap()))
- .reduce(|acc, i| acc + i)
- .unwrap();
- let new_balance = client_rpc.get_balance().unwrap();
- assert_eq!(
- client_balance - client_sent_amount_cost - client_sent_fees_cost,
- new_balance
- );
-
- print_now("Wait for bounce:");
- 'l: loop {
- let sync = client_rpc.list_since_block(Some(&since), 1).unwrap();
- for tx in sync.transactions {
- if tx.category == Category::Receive {
- let (_, metadata) = client_rpc.get_tx_op_return(&tx.txid).unwrap();
- let metadata = OutMetadata::decode(&metadata).unwrap();
- match metadata {
- OutMetadata::Debit { .. } => {}
- OutMetadata::Bounce { bounced } => {
- let bounced = Txid::from_byte_array(bounced);
- if bounced == bounce_id {
- break 'l;
- } else if bounced == send_min_id {
- panic!("Bounced send min");
- } else if bounced == bounce_min_id {
- panic!("Bounced bounce min");
- }
- }
- }
- }
- }
- since = sync.lastblock;
- rpc.wait_for_new_block().unwrap();
- print_now(".");
- }
- println!();
- wait_for_pending(&mut since, &mut client_rpc, &mut wire_rpc);
-
- println!("Check balance");
- let new_wire_balance = wire_rpc.get_balance().unwrap();
- let new_client_balance = client_rpc.get_balance().unwrap();
- assert!(new_wire_balance > wire_balance + test_amount + min_bounce_amount + min_send_amount);
- assert!(
- new_wire_balance < wire_balance + test_amount * 2 + min_bounce_amount + min_send_amount
- );
-
- println!("Check incoming history");
- assert!(check_incoming(
- base_url,
- &[(reserve_pub_key, taler_test_amount.clone())]
- ));
-
- println!("Get back some money");
- let wtid = Base32::rand();
- /*transfer(
- base_url,
- &wtid,
- &state.base_url,
- Payto::new(BtcAccount(client_addr)).as_payto(),
- &taler_test_amount,
- );*/
- wait_for_pending(&mut since, &mut client_rpc, &mut wire_rpc);
-
- println!("Check balances");
- let last_client_balance = client_rpc.get_balance().unwrap();
- assert_eq!(new_client_balance + test_amount, last_client_balance);
-
- println!("Check outgoing history");
- /*assert!(check_outgoing(
- base_url,
- &state.base_url,
- &[(wtid, taler_test_amount)]
- ));*/*/
-}
-
pub struct BtcCtx {
btc_node: ChildGuard,
_btc_node2: ChildGuard,
diff --git a/instrumentation/src/eth.rs b/instrumentation/src/eth.rs
@@ -16,202 +16,30 @@
use std::{
ops::{Deref, DerefMut},
- path::{Path, PathBuf},
+ path::PathBuf,
sync::LazyLock,
- time::Duration,
};
-use common::{
- metadata::OutMetadata,
- taler_common::{
- api_common::{EddsaPublicKey, ShortHashCode},
- types::{base32::Base32, payto::Payto},
- },
+use common::taler_common::{
+ api_common::{EddsaPublicKey, ShortHashCode},
+ types::{base32::Base32, payto::Payto},
};
use depolymerizer_ethereum::{
- CONFIG_SOURCE, RpcExtended, SyncState,
+ CONFIG_SOURCE, RpcExtended,
config::{ServeCfg, WorkerCfg},
payto::EthAccount,
rpc::{Rpc, RpcClient, TransactionRequest, hex::Hex},
taler_util::{TRUNC, eth_to_taler},
};
-use ethereum_types::{H160, H256, U256};
+use ethereum_types::{H160, U256};
use taler_common::config::Config;
use crate::utils::{
- ChildGuard, TalerCtx, TestCtx, check_incoming, check_outgoing, cmd_out, cmd_redirect,
- cmd_redirect_ok, patch_config, print_now, retry, retry_opt, transfer,
+ ChildGuard, TalerCtx, TestCtx, cmd_out, cmd_redirect, cmd_redirect_ok, patch_config, retry,
+ retry_opt, transfer,
};
-const NETWORK_FEE: LazyLock<U256> = LazyLock::new(|| U256::from(166u32));
-
-fn wait_for_pending(rpc: &mut Rpc) {
- print_now("Wait for pending transactions mining:");
- let mut rpc = rpc.subscribe_new_head().unwrap();
- std::thread::sleep(Duration::from_secs(1)); // Wait for eth-wire to act
- while !rpc.pending_transactions().unwrap().is_empty() {
- rpc.next().unwrap();
- print_now(".");
- std::thread::sleep(Duration::from_secs(1)); // Wait for eth-wire to act
- }
- println!();
-}
-
-pub fn online_test(config: Option<&Path>, base_url: &str) {
- let cfg = Config::from_file(CONFIG_SOURCE, config).unwrap();
- let state = WorkerCfg::parse(&cfg).unwrap();
- // TODO eth network check
- let min_fund = U256::from(100_000 * TRUNC);
- let test_amount = U256::from(20_000 * TRUNC);
- let taler_test_amount = eth_to_taler(&test_amount, &state.currency);
-
- let mut rpc = Rpc::new(state.ipc_path).unwrap();
-
- // Load client
- let client_addr = rpc
- .list_accounts()
- .unwrap()
- .into_iter()
- .skip(1) // Skip etherbase if dev network
- .find(|addr| addr != &state.account.0) // Skip wire
- .unwrap_or_else(|| rpc.new_account("password").unwrap()); // Else create account
-
- rpc.unlock_account(&client_addr, "password").unwrap();
- if rpc.get_balance_latest(&client_addr).unwrap() < min_fund {
- println!(
- "Client need a minimum of {} WEI to run this test, send coins to this address: {}",
- min_fund.as_u64(),
- hex::encode(client_addr)
- );
- print_now("Waiting for fund:");
- let mut rpc = rpc.subscribe_new_head().unwrap();
- while rpc.get_balance_latest(&client_addr).unwrap() < min_fund {
- rpc.next().unwrap();
- print_now(".");
- }
- println!();
- }
-
- wait_for_pending(&mut rpc);
- // Load balances
- let client_balance = rpc.get_balance_latest(&client_addr).unwrap();
- let wire_balance = rpc.get_balance_latest(&state.account.0).unwrap();
- // Start sync state
- let latest = rpc.latest_block().unwrap();
- let mut sync_state = SyncState {
- tip_hash: latest.hash.unwrap(),
- tip_height: latest.number.unwrap(),
- conf_height: latest.number.unwrap(),
- };
-
- println!("Send transaction");
- let reserve_pub_key = Base32::rand();
- let credit_id = rpc
- .credit(
- client_addr,
- state.account.0,
- test_amount,
- reserve_pub_key.clone(),
- )
- .unwrap();
- let zero_id = rpc
- .send_transaction(&TransactionRequest {
- from: client_addr,
- to: state.account.0,
- value: U256::zero(),
- gas_price: None,
- data: Hex(vec![]),
- nonce: None,
- })
- .unwrap();
- let bounce_id = rpc
- .send_transaction(&TransactionRequest {
- from: client_addr,
- to: state.account.0,
- value: test_amount,
- gas_price: None,
- data: Hex(vec![]),
- nonce: None,
- })
- .unwrap();
- print_now("Wait for bounce:");
- let bounce = {
- let mut rpc = rpc.subscribe_new_head().unwrap();
- 'l: loop {
- let list = rpc
- .list_since_sync(&state.account.0, sync_state, 0)
- .unwrap();
- sync_state = list.state;
- for sync_tx in list.txs {
- let tx = sync_tx.tx;
- if tx.to.unwrap() == client_addr && tx.from.unwrap() == state.account.0 {
- let metadata = OutMetadata::decode(&tx.input).unwrap();
- match metadata {
- OutMetadata::Debit { .. } => {}
- OutMetadata::Bounce { bounced } => {
- let bounced = H256::from_slice(&bounced);
- if bounced == bounce_id {
- break 'l tx;
- } else if bounced == zero_id {
- panic!("Bounced zero");
- }
- }
- }
- }
- }
- rpc.next().unwrap();
- print_now(".");
- }
- };
- println!();
- wait_for_pending(&mut rpc);
-
- println!("Check balance");
- let new_client_balance = rpc.get_balance_latest(&client_addr).unwrap();
- let new_wire_balance = rpc.get_balance_latest(&state.account.0).unwrap();
- let client_sent_amount_cost = test_amount * U256::from(2u8);
- let client_sent_fees_cost = [credit_id, zero_id, bounce_id]
- .into_iter()
- .map(|id| {
- let receipt = rpc.get_transaction_receipt(&id).unwrap().unwrap();
- receipt.gas_used * receipt.effective_gas_price.unwrap()
- })
- .reduce(|acc, i| acc + i)
- .unwrap();
- assert_eq!(
- client_balance - client_sent_amount_cost - client_sent_fees_cost + bounce.value,
- new_client_balance
- );
- let receipt = rpc.get_transaction_receipt(&bounce.hash).unwrap().unwrap();
- let bounced_fee = receipt.gas_used * receipt.effective_gas_price.unwrap();
- assert_eq!(
- wire_balance + test_amount + (test_amount - bounce.value - bounced_fee),
- new_wire_balance
- );
-
- println!("Check incoming history");
- assert!(check_incoming(
- base_url,
- &[(reserve_pub_key, taler_test_amount.clone())]
- ));
-
- println!("Get back some money");
- let wtid = Base32::rand();
- transfer(
- base_url,
- &wtid,
- Payto::new(EthAccount(client_addr)).as_payto(),
- &taler_test_amount,
- );
- wait_for_pending(&mut rpc);
-
- println!("Check balances");
- let last_client_balance = rpc.get_balance_latest(&client_addr).unwrap();
- assert_eq!(new_client_balance + test_amount, last_client_balance);
-
- println!("Check outgoing history");
- assert!(check_outgoing(base_url, &[(wtid, taler_test_amount)]));
-}
+static NETWORK_FEE: LazyLock<U256> = LazyLock::new(|| U256::from(166u32));
struct EthCtx {
node: ChildGuard,
@@ -697,7 +525,7 @@ impl EthCtx {
|| {
let current = lambda(self);
if current != balance {
- // dbg!(current.abs_diff(balance), current.abs_diff(balance) / 30);
+ // dbg!(current.abs_diff(balance), current.abs_diff(balance) / 30);
}
balance == current
},
@@ -1121,7 +949,7 @@ pub fn bumpfee(tctx: TestCtx) {
ctx.step("Bump fee");
{
// Perform debit
- let mut client = ctx.client_balance();
+ let client = ctx.client_balance();
let wire = ctx.wire_balance();
let amount = ctx.amount(40000);
ctx.debit(amount, &Base32::rand());
diff --git a/instrumentation/src/main.rs b/instrumentation/src/main.rs
@@ -16,7 +16,6 @@
use std::{
panic::catch_unwind,
- path::PathBuf,
sync::{Arc, Mutex},
time::{Duration, Instant},
};
@@ -36,142 +35,108 @@ mod utils;
/// Depolymerizer instrumentation test
#[derive(clap::Parser, Debug)]
struct Args {
- #[clap(subcommand)]
- cmd: Cmd,
-}
-
-#[derive(clap::Subcommand, Debug)]
-enum Cmd {
- /// Perform online tests on running blockchain
- Online {
- /// Override default configuration file path
- #[clap(global = true, short, long)]
- config: Option<PathBuf>,
- },
- /// Perform offline tests on local private blockchain
- Offline {
- /// With tests to run
- #[clap(global = true, default_value = "")]
- filters: Vec<String>,
- },
+ /// With tests to run
+ #[clap(global = true, default_value = "")]
+ filters: Vec<String>,
}
pub fn main() {
- let args = Args::parse();
- match args.cmd {
- Cmd::Online { config } => {
- /*let taler_config = TalerConfig::load(config.as_deref());
- let base_url = format!("http://localhost:{}/", taler_config.port());
-
- match taler_config.currency {
- Currency::BTC(_) => btc::online_test(config.as_deref(), &base_url),
- Currency::ETH(_) => eth::online_test(config.as_deref(), &base_url),
- }
- println!("Instrumentation test successful");*/
+ let Args { filters } = Args::parse();
+ std::fs::remove_dir_all("log").ok();
+ std::fs::create_dir_all("log/bin").unwrap();
+
+ // Build binaries
+ let p = ProgressBar::new_spinner();
+ p.set_style(ProgressStyle::with_template("building {msg} {elapsed:.dim}").unwrap());
+ p.enable_steady_tick(Duration::from_millis(1000));
+ for name in ["depolymerizer-bitcoin", "depolymerizer-ethereum"] {
+ build_bin(&p, name, None, name);
+ build_bin(&p, name, Some("fail"), &format!("{name}-fail"));
+ }
+ p.finish_and_clear();
+
+ // Run tests
+ let m = MultiProgress::new();
+ let start_style =
+ &ProgressStyle::with_template("{prefix:.magenta} {msg} {elapsed:.dim}").unwrap();
+ let ok_style =
+ &ProgressStyle::with_template("{prefix:.magenta} {msg:.green} {elapsed:.dim}").unwrap();
+ let err_style =
+ &ProgressStyle::with_template("{prefix:.magenta} {msg:.red} {elapsed:.dim}").unwrap();
+
+ let start = Instant::now();
+ let db = Arc::new(TestDb::new());
+ let results: Vec<_> = std::thread::scope(|s| {
+ let tests: Vec<_> = TESTS
+ .iter()
+ .filter(|(_, name)| filters.is_empty() || filters.iter().any(|f| name.starts_with(f)))
+ .map(|(action, name)| {
+ let pb = m.add(ProgressBar::new_spinner());
+ pb.set_style(start_style.clone());
+ pb.set_prefix(*name);
+ pb.set_message("Init");
+ pb.enable_steady_tick(Duration::from_millis(1000));
+ let db = db.clone();
+ let join = s.spawn(move || {
+ let start = Instant::now();
+ let ctx: TestCtx = TestCtx::new(name, pb.clone(), db);
+ let out = Arc::new(Mutex::new(String::new()));
+ let tmp = out.clone();
+ set_hook(Box::new(move |_| {
+ let backtrace = std::backtrace::Backtrace::force_capture().to_string();
+ tmp.lock().unwrap().push_str(&backtrace);
+ }));
+ let tmp = ctx.clone();
+ let result = catch_unwind(|| {
+ action(tmp);
+ });
+ if result.is_ok() {
+ pb.set_style(ok_style.clone());
+ pb.finish_with_message("OK");
+ } else {
+ pb.set_style(err_style.clone());
+ pb.finish();
+ }
+ let out: String = out.lock().unwrap().clone();
+ (result, start.elapsed(), out, pb.message())
+ });
+ (join, name)
+ })
+ .collect();
+ tests
+ .into_iter()
+ .map(|(j, n)| (j.join().unwrap(), n))
+ .collect()
+ });
+
+ let len = results.len();
+ m.clear().unwrap();
+ for ((result, _, out, msg), name) in &results {
+ if result.is_err() {
+ println!("{} {}\n{}", name.magenta(), msg.red(), out.bright_black());
}
- Cmd::Offline { filters } => {
- std::fs::remove_dir_all("log").ok();
- std::fs::create_dir_all("log/bin").unwrap();
-
- // Build binaries
- let p = ProgressBar::new_spinner();
- p.set_style(ProgressStyle::with_template("building {msg} {elapsed:.dim}").unwrap());
- p.enable_steady_tick(Duration::from_millis(1000));
- for name in ["depolymerizer-bitcoin", "depolymerizer-ethereum"] {
- build_bin(&p, name, None, name);
- build_bin(&p, name, Some("fail"), &format!("{name}-fail"));
- }
- p.finish_and_clear();
-
- // Run tests
- let m = MultiProgress::new();
- let start_style =
- &ProgressStyle::with_template("{prefix:.magenta} {msg} {elapsed:.dim}").unwrap();
- let ok_style =
- &ProgressStyle::with_template("{prefix:.magenta} {msg:.green} {elapsed:.dim}")
- .unwrap();
- let err_style =
- &ProgressStyle::with_template("{prefix:.magenta} {msg:.red} {elapsed:.dim}")
- .unwrap();
-
- let start = Instant::now();
- let db = Arc::new(TestDb::new());
- let results: Vec<_> = std::thread::scope(|s| {
- let tests: Vec<_> = TESTS
- .iter()
- .filter(|(_, name)| {
- filters.is_empty() || filters.iter().any(|f| name.starts_with(f))
- })
- .map(|(action, name)| {
- let pb = m.add(ProgressBar::new_spinner());
- pb.set_style(start_style.clone());
- pb.set_prefix(*name);
- pb.set_message("Init");
- pb.enable_steady_tick(Duration::from_millis(1000));
- let db = db.clone();
- let join = s.spawn(move || {
- let start = Instant::now();
- let ctx: TestCtx = TestCtx::new(name, pb.clone(), db);
- let out = Arc::new(Mutex::new(String::new()));
- let tmp = out.clone();
- set_hook(Box::new(move |_| {
- let backtrace =
- std::backtrace::Backtrace::force_capture().to_string();
- tmp.lock().unwrap().push_str(&backtrace);
- }));
- let tmp = ctx.clone();
- let result = catch_unwind(|| {
- action(tmp);
- });
- if result.is_ok() {
- pb.set_style(ok_style.clone());
- pb.finish_with_message("OK");
- } else {
- pb.set_style(err_style.clone());
- pb.finish();
- }
- let out: String = out.lock().unwrap().clone();
- (result, start.elapsed(), out, pb.message())
- });
- (join, name)
- })
- .collect();
- tests
- .into_iter()
- .map(|(j, n)| (j.join().unwrap(), n))
- .collect()
- });
-
- let len = results.len();
- m.clear().unwrap();
- for ((result, _, out, msg), name) in &results {
- if result.is_err() {
- println!("{} {}\n{}", name.magenta(), msg.red(), out.bright_black());
- }
+ }
+ for ((result, time, _, msg), name) in results {
+ match result {
+ Ok(_) => {
+ println!(
+ "{} {} {}",
+ name.magenta(),
+ "OK".green(),
+ format_args!("{}s", time.as_secs()).bright_black()
+ );
}
- for ((result, time, _, msg), name) in results {
- match result {
- Ok(_) => {
- println!(
- "{} {} {}",
- name.magenta(),
- "OK".green(),
- format_args!("{}s", time.as_secs()).bright_black()
- );
- }
- Err(_) => {
- println!(
- "{} {} {}",
- name.magenta(),
- msg.red(),
- format_args!("{}s", time.as_secs()).bright_black()
- );
- }
- }
+ Err(_) => {
+ println!(
+ "{} {} {}",
+ name.magenta(),
+ msg.red(),
+ format_args!("{}s", time.as_secs()).bright_black()
+ );
}
- println!("{} tests in {}s", len, start.elapsed().as_secs());
}
}
+ println!("{} tests in {}s", len, start.elapsed().as_secs());
}
pub fn build_bin(p: &ProgressBar, name: &str, features: Option<&str>, bin_name: &str) {
diff --git a/instrumentation/src/utils.rs b/instrumentation/src/utils.rs
@@ -38,12 +38,6 @@ use common::{
use indicatif::ProgressBar;
use ini::Ini;
use tempfile::TempDir;
-use ureq::http::Response;
-
-pub fn print_now(disp: impl Display) {
- print!("{disp}");
- std::io::stdout().flush().unwrap();
-}
#[must_use]
pub fn check_incoming(base_url: &str, txs: &[(EddsaPublicKey, Amount)]) -> bool {
@@ -75,23 +69,6 @@ pub fn check_incoming(base_url: &str, txs: &[(EddsaPublicKey, Amount)]) -> bool
}
}
-pub fn http_code<T>(response: Result<Response<T>, ureq::Error>) -> u16 {
- match response {
- Ok(resp) => resp.status().as_u16(),
- Err(err) => match err {
- ureq::Error::StatusCode(err) => err,
- _ => unreachable!(),
- },
- }
-}
-
-pub fn gateway_error(path: &str, error: u16) {
- assert!(matches!(
- ureq::get(path).call(),
- Err(ureq::Error::StatusCode(err)) if err == error
- ))
-}
-
#[must_use]
pub fn check_gateway_down(base_url: &str) -> bool {
matches!(
diff --git a/makefile b/makefile
@@ -36,12 +36,12 @@ install-nobuild:
install: build install-nobuild
.PHONY: check
-check: install-nobuild
+check: install
cargo test
.PHONY: test
-test:
- RUST_BACKTRACE=true cargo run --profile dev --bin instrumentation -- offline
+test: install
+ RUST_BACKTRACE=true cargo run --profile dev --bin instrumentation
.PHONY: doc
doc: