mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 20:29:23 +00:00
Resolve #405
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
use dockertest::{
|
||||
PullPolicy, StartPolicy, LogOptions, LogAction, LogPolicy, LogSource, Image,
|
||||
TestBodySpecification, DockerOperations, DockerTest,
|
||||
};
|
||||
|
||||
#[cfg(feature = "bitcoin")]
|
||||
mod bitcoin {
|
||||
use super::*;
|
||||
use crate::networks::{Network, Bitcoin};
|
||||
|
||||
#[test]
|
||||
@@ -13,14 +19,47 @@ mod bitcoin {
|
||||
check::<IsTrue<{ Bitcoin::DUST >= bitcoin_serai::wallet::DUST }>>();
|
||||
}
|
||||
|
||||
async fn bitcoin() -> Bitcoin {
|
||||
let bitcoin = Bitcoin::new("http://serai:seraidex@127.0.0.1:18443".to_string()).await;
|
||||
fn spawn_bitcoin() -> DockerTest {
|
||||
serai_docker_tests::build("bitcoin".to_string());
|
||||
|
||||
let composition = TestBodySpecification::with_image(
|
||||
Image::with_repository("serai-dev-bitcoin").pull_policy(PullPolicy::Never),
|
||||
)
|
||||
.replace_cmd(vec![
|
||||
"bitcoind".to_string(),
|
||||
"-txindex".to_string(),
|
||||
"-regtest".to_string(),
|
||||
format!("-rpcuser=serai"),
|
||||
format!("-rpcpassword=seraidex"),
|
||||
"-rpcbind=0.0.0.0".to_string(),
|
||||
"-rpcallowip=0.0.0.0/0".to_string(),
|
||||
"-rpcport=8332".to_string(),
|
||||
])
|
||||
.set_start_policy(StartPolicy::Strict)
|
||||
.set_log_options(Some(LogOptions {
|
||||
action: LogAction::Forward,
|
||||
policy: LogPolicy::OnError,
|
||||
source: LogSource::Both,
|
||||
}))
|
||||
.set_publish_all_ports(true);
|
||||
|
||||
let mut test = DockerTest::new().with_network(dockertest::Network::Isolated);
|
||||
test.provide_container(composition);
|
||||
test
|
||||
}
|
||||
|
||||
async fn bitcoin(ops: &DockerOperations) -> Bitcoin {
|
||||
let handle = ops.handle("serai-dev-bitcoin").host_port(8332).unwrap();
|
||||
// TODO: Replace with a check if the node has booted
|
||||
tokio::time::sleep(core::time::Duration::from_secs(20)).await;
|
||||
let bitcoin = Bitcoin::new(format!("http://serai:seraidex@{}:{}", handle.0, handle.1)).await;
|
||||
bitcoin.fresh_chain().await;
|
||||
bitcoin
|
||||
}
|
||||
|
||||
test_network!(
|
||||
Bitcoin,
|
||||
spawn_bitcoin,
|
||||
bitcoin,
|
||||
bitcoin_key_gen,
|
||||
bitcoin_scanner,
|
||||
@@ -33,10 +72,44 @@ mod bitcoin {
|
||||
|
||||
#[cfg(feature = "monero")]
|
||||
mod monero {
|
||||
use super::*;
|
||||
use crate::networks::{Network, Monero};
|
||||
|
||||
async fn monero() -> Monero {
|
||||
let monero = Monero::new("http://127.0.0.1:18081".to_string());
|
||||
fn spawn_monero() -> DockerTest {
|
||||
serai_docker_tests::build("monero".to_string());
|
||||
|
||||
let composition = TestBodySpecification::with_image(
|
||||
Image::with_repository("serai-dev-monero").pull_policy(PullPolicy::Never),
|
||||
)
|
||||
.replace_cmd(vec![
|
||||
"monerod".to_string(),
|
||||
"--regtest".to_string(),
|
||||
"--offline".to_string(),
|
||||
"--fixed-difficulty=1".to_string(),
|
||||
"--rpc-bind-ip=0.0.0.0".to_string(),
|
||||
format!("--rpc-login=serai:seraidex"),
|
||||
"--rpc-access-control-origins=*".to_string(),
|
||||
"--confirm-external-bind".to_string(),
|
||||
"--non-interactive".to_string(),
|
||||
])
|
||||
.set_start_policy(StartPolicy::Strict)
|
||||
.set_log_options(Some(LogOptions {
|
||||
action: LogAction::Forward,
|
||||
policy: LogPolicy::OnError,
|
||||
source: LogSource::Both,
|
||||
}))
|
||||
.set_publish_all_ports(true);
|
||||
|
||||
let mut test = DockerTest::new().with_network(dockertest::Network::Isolated);
|
||||
test.provide_container(composition);
|
||||
test
|
||||
}
|
||||
|
||||
async fn monero(ops: &DockerOperations) -> Monero {
|
||||
let handle = ops.handle("serai-dev-monero").host_port(18081).unwrap();
|
||||
// TODO: Replace with a check if the node has booted
|
||||
tokio::time::sleep(core::time::Duration::from_secs(20)).await;
|
||||
let monero = Monero::new(format!("http://serai:seraidex@{}:{}", handle.0, handle.1));
|
||||
while monero.get_latest_block_number().await.unwrap() < 150 {
|
||||
monero.mine_block().await;
|
||||
}
|
||||
@@ -45,6 +118,7 @@ mod monero {
|
||||
|
||||
test_network!(
|
||||
Monero,
|
||||
spawn_monero,
|
||||
monero,
|
||||
monero_key_gen,
|
||||
monero_scanner,
|
||||
|
||||
Reference in New Issue
Block a user