Upgrade to testcontainers v0.12

pull/204/head
Thomas Eizinger 3 years ago
parent 7a9569ffd4
commit 8c83f7e2e1
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96

41
Cargo.lock generated

@ -321,7 +321,7 @@ dependencies = [
"reqwest", "reqwest",
"serde", "serde",
"serde_json", "serde_json",
"testcontainers", "testcontainers 0.11.0",
"thiserror", "thiserror",
"tokio 1.0.2", "tokio 1.0.2",
"tracing", "tracing",
@ -726,6 +726,16 @@ dependencies = [
"subtle 2.4.0", "subtle 2.4.0",
] ]
[[package]]
name = "crypto-mac"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4857fd85a0c34b3c3297875b747c1e02e06b6a0ea32dd892d8192b9ce0813ea6"
dependencies = [
"generic-array 0.14.4",
"subtle 2.4.0",
]
[[package]] [[package]]
name = "csv" name = "csv"
version = "1.1.5" version = "1.1.5"
@ -1382,6 +1392,16 @@ dependencies = [
"digest 0.9.0", "digest 0.9.0",
] ]
[[package]]
name = "hmac"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15"
dependencies = [
"crypto-mac 0.10.0",
"digest 0.9.0",
]
[[package]] [[package]]
name = "hmac-drbg" name = "hmac-drbg"
version = "0.2.0" version = "0.2.0"
@ -2008,7 +2028,7 @@ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
"spectral", "spectral",
"testcontainers", "testcontainers 0.12.0",
"tokio 1.0.2", "tokio 1.0.2",
"tracing", "tracing",
"tracing-log", "tracing-log",
@ -3513,7 +3533,7 @@ dependencies = [
"structopt", "structopt",
"strum", "strum",
"tempfile", "tempfile",
"testcontainers", "testcontainers 0.12.0",
"thiserror", "thiserror",
"time", "time",
"tokio 1.0.2", "tokio 1.0.2",
@ -3602,6 +3622,21 @@ dependencies = [
"sha2 0.9.2", "sha2 0.9.2",
] ]
[[package]]
name = "testcontainers"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5e3ed6e3598dbf32cba8cb356b881c085e0adea57597f387723430dd94b4084"
dependencies = [
"hex 0.4.2",
"hmac 0.10.1",
"log",
"rand 0.8.2",
"serde",
"serde_json",
"sha2 0.9.2",
]
[[package]] [[package]]
name = "textwrap" name = "textwrap"
version = "0.11.0" version = "0.11.0"

@ -14,7 +14,7 @@ reqwest = { version = "0.11", default-features = false, features = ["json", "nat
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"
spectral = "0.6" spectral = "0.6"
testcontainers = "0.11" testcontainers = "0.12"
tokio = { version = "1.0", default-features = false, features = ["rt-multi-thread", "time", "macros"] } tokio = { version = "1.0", default-features = false, features = ["rt-multi-thread", "time", "macros"] }
tracing = "0.1" tracing = "0.1"
tracing-log = "0.1" tracing-log = "0.1"

@ -1,6 +1,6 @@
use std::{collections::HashMap, env::var, thread::sleep, time::Duration}; use std::{collections::HashMap, env::var, thread::sleep, time::Duration};
use testcontainers::{ use testcontainers::{
core::{Container, Docker, Port, WaitForMessage}, core::{Container, Docker, WaitForMessage},
Image, Image,
}; };
@ -13,7 +13,6 @@ pub const WALLET_RPC_PORT: u16 = 48083;
pub struct Monero { pub struct Monero {
tag: String, tag: String,
args: Args, args: Args,
ports: Option<Vec<Port>>,
entrypoint: Option<String>, entrypoint: Option<String>,
wait_for_message: String, wait_for_message: String,
} }
@ -57,10 +56,6 @@ impl Image for Monero {
HashMap::new() HashMap::new()
} }
fn ports(&self) -> Option<Vec<Port>> {
self.ports.clone()
}
fn with_args(self, args: <Self as Image>::Args) -> Self { fn with_args(self, args: <Self as Image>::Args) -> Self {
Monero { args, ..self } Monero { args, ..self }
} }
@ -82,7 +77,6 @@ impl Default for Monero {
Monero { Monero {
tag: "v0.16.0.3".into(), tag: "v0.16.0.3".into(),
args: Args::default(), args: Args::default(),
ports: None,
entrypoint: Some("".into()), entrypoint: Some("".into()),
wait_for_message: "core RPC server started ok".to_string(), wait_for_message: "core RPC server started ok".to_string(),
} }
@ -97,13 +91,6 @@ impl Monero {
} }
} }
pub fn with_mapped_port<P: Into<Port>>(mut self, port: P) -> Self {
let mut ports = self.ports.unwrap_or_default();
ports.push(port.into());
self.ports = Some(ports);
self
}
pub fn wallet(name: &str, daemon_address: String) -> Self { pub fn wallet(name: &str, daemon_address: String) -> Self {
let wallet = WalletArgs::new(name, daemon_address, WALLET_RPC_PORT); let wallet = WalletArgs::new(name, daemon_address, WALLET_RPC_PORT);
let default = Monero::default(); let default = Monero::default();

@ -183,13 +183,14 @@ impl<'c> Monerod {
let monerod_rpc_port: u16 = let monerod_rpc_port: u16 =
port_check::free_local_port().ok_or_else(|| anyhow!("Could not retrieve free port"))?; port_check::free_local_port().ok_or_else(|| anyhow!("Could not retrieve free port"))?;
let image = image::Monero::default().with_mapped_port(Port { let image = image::Monero::default();
local: monerod_rpc_port,
internal: MONEROD_RPC_PORT,
});
let run_args = RunArgs::default() let run_args = RunArgs::default()
.with_name(name.clone()) .with_name(name.clone())
.with_network(network.clone()); .with_network(network.clone())
.with_mapped_port(Port {
local: monerod_rpc_port,
internal: MONEROD_RPC_PORT,
});
let docker = cli.run_with_args(image, run_args); let docker = cli.run_with_args(image, run_args);
Ok(( Ok((
@ -227,15 +228,16 @@ impl<'c> MoneroWalletRpc {
port_check::free_local_port().ok_or_else(|| anyhow!("Could not retrieve free port"))?; port_check::free_local_port().ok_or_else(|| anyhow!("Could not retrieve free port"))?;
let daemon_address = format!("{}:{}", monerod.name, MONEROD_RPC_PORT); let daemon_address = format!("{}:{}", monerod.name, MONEROD_RPC_PORT);
let image = image::Monero::wallet(&name, daemon_address).with_mapped_port(Port { let image = image::Monero::wallet(&name, daemon_address);
local: wallet_rpc_port,
internal: WALLET_RPC_PORT,
});
let network = monerod.network.clone(); let network = monerod.network.clone();
let run_args = RunArgs::default() let run_args = RunArgs::default()
.with_name(name) .with_name(name)
.with_network(network.clone()); .with_network(network.clone())
.with_mapped_port(Port {
local: wallet_rpc_port,
internal: WALLET_RPC_PORT,
});
let docker = cli.run_with_args(image, run_args); let docker = cli.run_with_args(image, run_args);
// create new wallet // create new wallet

@ -71,4 +71,4 @@ port_check = "0.1"
serde_cbor = "0.11" serde_cbor = "0.11"
spectral = "0.6" spectral = "0.6"
tempfile = "3" tempfile = "3"
testcontainers = "0.11" testcontainers = "0.12"

@ -1,6 +1,6 @@
use std::collections::HashMap; use std::collections::HashMap;
use testcontainers::{ use testcontainers::{
core::{Container, Docker, Port, WaitForMessage}, core::{Container, Docker, WaitForMessage},
Image, Image,
}; };
@ -55,10 +55,6 @@ impl Image for Bitcoind {
HashMap::new() HashMap::new()
} }
fn ports(&self) -> Option<Vec<Port>> {
None
}
fn with_args(self, args: <Self as Image>::Args) -> Self { fn with_args(self, args: <Self as Image>::Args) -> Self {
Bitcoind { args, ..self } Bitcoind { args, ..self }
} }

@ -2,7 +2,7 @@ use crate::testutils::bitcoind;
use bitcoin::Network; use bitcoin::Network;
use std::collections::HashMap; use std::collections::HashMap;
use testcontainers::{ use testcontainers::{
core::{Container, Docker, Port, WaitForMessage}, core::{Container, Docker, WaitForMessage},
Image, Image,
}; };
@ -51,10 +51,6 @@ impl Image for Electrs {
HashMap::new() HashMap::new()
} }
fn ports(&self) -> Option<Vec<Port>> {
None
}
fn with_args(self, args: <Self as Image>::Args) -> Self { fn with_args(self, args: <Self as Image>::Args) -> Self {
Electrs { args, ..self } Electrs { args, ..self }
} }

Loading…
Cancel
Save