summaryrefslogtreecommitdiff
path: root/instrumentation/src
diff options
context:
space:
mode:
Diffstat (limited to 'instrumentation/src')
-rw-r--r--instrumentation/src/btc.rs12
-rw-r--r--instrumentation/src/eth.rs33
-rw-r--r--instrumentation/src/main.rs18
-rw-r--r--instrumentation/src/utils.rs17
4 files changed, 38 insertions, 42 deletions
diff --git a/instrumentation/src/btc.rs b/instrumentation/src/btc.rs
index 964f302..1495d08 100644
--- a/instrumentation/src/btc.rs
+++ b/instrumentation/src/btc.rs
@@ -31,6 +31,7 @@ use btc_wire::{
WireState,
};
use common::{currency::CurrencyBtc, metadata::OutMetadata, postgres::NoTls, rand_slice};
+use indicatif::ProgressBar;
use tempfile::TempDir;
use crate::utils::{
@@ -248,9 +249,7 @@ impl DerefMut for BtcCtx {
}
impl BtcCtx {
- pub fn config(test_name: &str, config: &str) {
- // Generate temporary dirs
- let ctx = TestCtx::new(test_name);
+ pub fn config(ctx: TestCtx, config: &str) {
// Bitcoin config
let config = PathBuf::from_str("instrumentation/conf")
.unwrap()
@@ -323,7 +322,7 @@ impl BtcCtx {
ctx.init_db();
// Generate wallet
cmd_redirect_ok(
- "btc-wire",
+ &ctx.wire_bin_path,
&["-c", ctx.conf.to_str().unwrap(), "initwallet"],
&ctx.log("cmd"),
"wire initwallet",
@@ -1119,6 +1118,9 @@ pub fn config(ctx: TestCtx) {
for n in 0..5 {
let config_name = format!("bitcoin_auth{}.conf", n);
ctx.step(format!("Config {}", config_name));
- BtcCtx::config(&format!("config/{config_name}"), &config_name);
+ BtcCtx::config(
+ TestCtx::new(&format!("config/{config_name}"), ProgressBar::hidden()),
+ &config_name,
+ );
}
}
diff --git a/instrumentation/src/eth.rs b/instrumentation/src/eth.rs
index f6aa719..f215fd3 100644
--- a/instrumentation/src/eth.rs
+++ b/instrumentation/src/eth.rs
@@ -247,19 +247,6 @@ impl EthCtx {
"create account",
)
}
- cmd_redirect_ok(
- "geth",
- &[
- "--datadir",
- ctx.wire2_dir.to_str().unwrap(),
- "account",
- "new",
- "--password",
- pswd_path.to_str().unwrap(),
- ],
- &ctx.log("geth2"),
- "create account",
- );
let list = cmd_out(
"geth",
&[
@@ -269,7 +256,8 @@ impl EthCtx {
"list",
],
);
- let addr = &list.lines().nth(1).unwrap()[13..][..40];
+ let reserve = &list[13..][..40];
+ let client = &list.lines().nth(1).unwrap()[13..][..40];
let genesis = format!(
"{{
\"config\": {{
@@ -284,16 +272,19 @@ impl EthCtx {
\"istanbulBlock\": 0,
\"berlinBlock\": 0,
\"londonBlock:\": 0,
- \"ethash\": {{}}
+ \"clique\": {{
+ \"period\": 1
+ }}
}},
\"difficulty\": \"1\",
\"gasLimit\": \"0\",
\"baseFeePerGas\": null,
+ \"extraData\": \"0x0000000000000000000000000000000000000000000000000000000000000000{}0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\",
\"alloc\": {{
\"{}\": {{ \"balance\": \"10000000000000000000\" }}
}}
}}",
- addr
+ reserve, client
);
std::fs::write(ctx.wire_dir.join("genesis.json"), genesis.as_bytes()).unwrap();
@@ -330,6 +321,7 @@ impl EthCtx {
&unused_port().to_string(),
"--port",
&unused_port().to_string(),
+ "--rpc.enabledeprecatedpersonal"
],
&ctx.log("geth"),
);
@@ -338,7 +330,7 @@ impl EthCtx {
// Generate wallet
let out = cmd_out(
- "eth-wire",
+ &ctx.wire_bin_path,
&["-c", ctx.conf.to_str().unwrap(), "initwallet"],
);
@@ -426,6 +418,8 @@ impl EthCtx {
&[
"--datadir",
self.ctx.wire2_dir.to_str().unwrap(),
+ "--keystore",
+ self.ctx.wire_dir.join("keystore").to_str().unwrap(),
"import",
path,
],
@@ -440,12 +434,15 @@ impl EthCtx {
&[
"--datadir",
self.ctx.wire2_dir.to_str().unwrap(),
+ "--keystore",
+ self.ctx.wire_dir.join("keystore").to_str().unwrap(),
"--miner.gasprice",
"10",
"--authrpc.port",
&unused_port().to_string(),
"--port",
&unused_port().to_string(),
+ "--rpc.enabledeprecatedpersonal"
],
&self.ctx.log("geth2"),
);
@@ -488,6 +485,7 @@ impl EthCtx {
&unused_port().to_string(),
"--port",
&unused_port().to_string(),
+ "--rpc.enabledeprecatedpersonal"
],
&self.ctx.log("geth"),
);
@@ -556,6 +554,7 @@ impl EthCtx {
fn _mine(rpc: &mut Rpc, addr: &H160, mut amount: u16, passwd: &str) {
rpc.unlock_account(addr, passwd).ok();
+ rpc.miner_set_etherbase(addr).ok();
let mut rpc = rpc.subscribe_new_head().unwrap();
rpc.miner_start().unwrap();
diff --git a/instrumentation/src/main.rs b/instrumentation/src/main.rs
index f196d7d..12971ad 100644
--- a/instrumentation/src/main.rs
+++ b/instrumentation/src/main.rs
@@ -17,7 +17,7 @@
use std::{
panic::catch_unwind,
path::PathBuf,
- time::{Duration, Instant},
+ time::{Duration, Instant}, sync::{Arc, Mutex},
};
use clap::Parser;
@@ -110,34 +110,34 @@ pub fn main() {
let pb = m.add(ProgressBar::new_spinner());
pb.set_style(start_style.clone());
pb.set_prefix(*name);
- pb.set_message("RUN");
+ pb.set_message("Init");
pb.enable_steady_tick(Duration::from_millis(1000));
let join = s.spawn(move || {
let start = Instant::now();
- let ctx = TestCtx::new(name);
- let tmp = ctx.clone();
+ let ctx: TestCtx = TestCtx::new(name, pb.clone());
+ let out = Arc::new(Mutex::new(String::new()));
+ let tmp = out.clone();
set_hook(Box::new(move |info| {
let mut buf = Vec::new();
color_backtrace::BacktracePrinter::new()
.print_panic_info(info, &mut NoColor::new(&mut buf))
.ok();
let str = String::from_utf8(buf).unwrap_or_default();
- tmp.out.lock().unwrap().push_str(&str);
+ tmp.lock().unwrap().push_str(&str);
}));
let tmp = ctx.clone();
let result = catch_unwind(|| {
action(tmp);
});
- let lock = ctx.out.lock().unwrap();
if result.is_ok() {
pb.set_style(ok_style.clone());
pb.finish_with_message("OK");
} else {
pb.set_style(err_style.clone());
- pb.finish_with_message("ERR");
+ pb.finish();
}
-
- (result, start.elapsed(), lock.clone())
+ let out: String = out.lock().unwrap().clone();
+ (result, start.elapsed(), out)
});
(join, name)
})
diff --git a/instrumentation/src/utils.rs b/instrumentation/src/utils.rs
index 835764a..5509754 100644
--- a/instrumentation/src/utils.rs
+++ b/instrumentation/src/utils.rs
@@ -16,14 +16,12 @@
use std::{
fmt::Display,
- fmt::Write as _,
io::Write as _,
net::{Ipv4Addr, SocketAddrV4, TcpListener, TcpStream},
ops::{Deref, DerefMut},
path::{Path, PathBuf},
process::{Child, Command, Stdio},
str::FromStr,
- sync::{Arc, Mutex},
thread::sleep,
time::{Duration, Instant},
};
@@ -35,6 +33,7 @@ use common::{
rand_slice,
url::Url,
};
+use indicatif::ProgressBar;
use signal_child::{signal::Signal, Signalable};
use tempfile::TempDir;
@@ -200,11 +199,11 @@ pub fn retry(mut lambda: impl FnMut() -> bool) {
#[derive(Clone)]
pub struct TestCtx {
pub log_dir: String,
- pub out: Arc<Mutex<String>>,
+ pub pb: ProgressBar,
}
impl TestCtx {
- pub fn new(name: &str) -> Self {
+ pub fn new(name: &str, pb: ProgressBar) -> Self {
// Create log dir
let log_dir = format!("log/{name}");
std::fs::remove_dir_all(&log_dir).ok();
@@ -213,10 +212,7 @@ impl TestCtx {
let pwd: String = (0..30).map(|_| fastrand::alphanumeric()).collect();
std::env::set_var("PASSWORD", pwd);
- Self {
- log_dir,
- out: Arc::new(Mutex::new(String::new())),
- }
+ Self { log_dir, pb }
}
pub fn log(&self, name: &str) -> String {
@@ -224,8 +220,7 @@ impl TestCtx {
}
pub fn step(&self, disp: impl Display) {
- let it: &mut String = &mut self.out.lock().unwrap();
- writeln!(it, "{disp}").unwrap();
+ self.pb.set_message(format!("{disp}"))
}
}
@@ -238,7 +233,7 @@ pub struct TalerCtx {
pub taler_conf: TalerConfig,
ctx: TestCtx,
db: ChildGuard,
- wire_bin_path: String,
+ pub wire_bin_path: String,
stressed: bool,
gateway: Option<ChildGuard>,
pub gateway_url: String,