No prefix for wallets in monero harness

Prefixing docker-containers and -networks is a necessity to be able to spin up multiple containers and networks.
However, there is no reason to prefix the wallet names that live inside a container. One cannot add a wallet with
the same name twice, so the prefixing of wallets does not bring any advantage. When re-opening a wallet by name
the wallet name prefix is cumbersome and was thus removed.
pull/261/head
Daniel Karzel 3 years ago
parent 9f53dab3c6
commit 2bb1c1e177

@ -44,52 +44,42 @@ const WAIT_WALLET_SYNC_MILLIS: u64 = 1000;
pub struct Monero {
monerod: Monerod,
wallets: Vec<MoneroWalletRpc>,
prefix: String,
}
impl<'c> Monero {
/// Starts a new regtest monero container setup consisting out of 1 monerod
/// node and n wallets. The containers and network will be prefixed, either
/// randomly generated or as defined in `prefix` if provided. There will
/// be 1 miner wallet started automatically. Default monerod container
/// name will be: `prefix`_`monerod` Default miner wallet container name
/// will be: `prefix`_`miner` Default network will be: `prefix`_`monero`
/// node and n wallets. The docker container and network will be prefixed
/// with a randomly generated `prefix`. One miner wallet is started
/// automatically.
/// monerod container name is: `prefix`_`monerod`
/// network is: `prefix`_`monero`
/// miner wallet container name is: `miner`
pub async fn new(
cli: &'c Cli,
prefix: Option<String>,
additional_wallets: Vec<String>,
) -> Result<(Self, Vec<Container<'c, Cli, image::Monero>>)> {
let prefix = format!("{}_", prefix.unwrap_or_else(random_prefix));
let prefix = format!("{}_", random_prefix());
let monerod_name = format!("{}{}", prefix, MONEROD_DAEMON_CONTAINER_NAME);
let network = format!("{}{}", prefix, MONEROD_DEFAULT_NETWORK);
tracing::info!("Starting monerod... {}", monerod_name);
tracing::info!("Starting monerod: {}", monerod_name);
let (monerod, monerod_container) = Monerod::new(cli, monerod_name, network)?;
let mut containers = vec![monerod_container];
let mut wallets = vec![];
let miner = format!("{}{}", prefix, "miner");
tracing::info!("Starting miner wallet... {}", miner);
let miner = "miner";
tracing::info!("Starting miner wallet: {}", miner);
let (miner_wallet, miner_container) = MoneroWalletRpc::new(cli, &miner, &monerod).await?;
wallets.push(miner_wallet);
containers.push(miner_container);
for wallet in additional_wallets.iter() {
tracing::info!("Starting wallet: {}...", wallet);
let wallet = format!("{}{}", prefix, wallet);
tracing::info!("Starting wallet: {}", wallet);
let (wallet, container) = MoneroWalletRpc::new(cli, &wallet, &monerod).await?;
wallets.push(wallet);
containers.push(container);
}
Ok((
Self {
monerod,
wallets,
prefix,
},
containers,
))
Ok((Self { monerod, wallets }, containers))
}
pub fn monerod(&self) -> &Monerod {
@ -97,7 +87,6 @@ impl<'c> Monero {
}
pub fn wallet(&self, name: &str) -> Result<&MoneroWalletRpc> {
let name = format!("{}{}", self.prefix, name);
let wallet = self
.wallets
.iter()

@ -12,7 +12,7 @@ async fn init_miner_and_mine_to_miner_address() {
let _guard = init_tracing();
let tc = Cli::default();
let (monero, _monerod_container) = Monero::new(&tc, None, vec![]).await.unwrap();
let (monero, _monerod_container) = Monero::new(&tc, vec![]).await.unwrap();
monero.init(vec![]).await.unwrap();

@ -16,12 +16,9 @@ async fn fund_transfer_and_check_tx_key() {
let send_to_bob = 5_000_000_000;
let tc = Cli::default();
let (monero, _containers) = Monero::new(&tc, Some("test_".to_string()), vec![
"alice".to_string(),
"bob".to_string(),
])
.await
.unwrap();
let (monero, _containers) = Monero::new(&tc, vec!["alice".to_string(), "bob".to_string()])
.await
.unwrap();
let alice_wallet = monero.wallet("alice").unwrap();
let bob_wallet = monero.wallet("bob").unwrap();

@ -597,7 +597,7 @@ async fn init_test_wallets(
let xmr_wallet = swap::monero::Wallet::new_with_client(
monero.wallet(name).unwrap().client(),
monero::Network::default(),
"irrelevant_for_tests".to_string(),
name.to_string(),
);
let electrum_rpc_url = {

Loading…
Cancel
Save