xmr-btc-swap/monero-harness/tests/monerod.rs

33 lines
1.1 KiB
Rust
Raw Normal View History

use monero_harness::Monero;
2021-04-15 08:39:59 +00:00
use monero_rpc::monerod::MonerodRpc as _;
use spectral::prelude::*;
2020-11-01 23:02:28 +00:00
use std::time::Duration;
use testcontainers::clients::Cli;
2020-11-01 23:02:28 +00:00
use tokio::time;
use tracing_subscriber::util::SubscriberInitExt;
2021-01-11 01:55:19 +00:00
#[tokio::test]
2020-11-01 23:02:28 +00:00
async fn init_miner_and_mine_to_miner_address() {
let _guard = tracing_subscriber::fmt()
.with_env_filter("warn,test=debug,monero_harness=debug,monero_rpc=debug")
.set_default();
2021-01-11 01:55:19 +00:00
2020-11-01 23:02:28 +00:00
let tc = Cli::default();
let (monero, _monerod_container, _wallet_containers) = Monero::new(&tc, vec![]).await.unwrap();
2020-11-01 23:02:28 +00:00
monero.init_and_start_miner().await.unwrap();
2020-11-02 05:00:35 +00:00
let monerod = monero.monerod();
let miner_wallet = monero.wallet("miner").unwrap();
2020-11-01 23:02:28 +00:00
2020-11-02 05:00:35 +00:00
let got_miner_balance = miner_wallet.balance().await.unwrap();
2020-11-01 23:02:28 +00:00
assert_that!(got_miner_balance).is_greater_than(0);
time::sleep(Duration::from_millis(1010)).await;
2020-11-01 23:02:28 +00:00
// after a bit more than 1 sec another block should have been mined
2021-04-15 08:39:59 +00:00
let block_height = monerod.client().get_block_count().await.unwrap().count;
2020-11-01 23:02:28 +00:00
assert_that(&block_height).is_greater_than(70);
}