-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4bdbdd
commit 08180cc
Showing
5 changed files
with
119 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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:[email protected]: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, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters