2020-10-19 21:18:27 -04:00
|
|
|
use monero_harness::Monero;
|
2020-09-28 02:18:50 -04:00
|
|
|
use spectral::prelude::*;
|
2020-11-01 18:02:28 -05:00
|
|
|
use std::time::Duration;
|
2020-09-28 02:18:50 -04:00
|
|
|
use testcontainers::clients::Cli;
|
2020-11-01 18:02:28 -05:00
|
|
|
use tokio::time;
|
2021-03-28 18:54:48 -04:00
|
|
|
use tracing_subscriber::util::SubscriberInitExt;
|
2021-01-10 20:55:19 -05:00
|
|
|
|
2020-09-28 02:18:50 -04:00
|
|
|
#[tokio::test]
|
2020-11-01 18:02:28 -05:00
|
|
|
async fn init_miner_and_mine_to_miner_address() {
|
2021-03-28 18:54:48 -04:00
|
|
|
let _guard = tracing_subscriber::fmt()
|
|
|
|
.with_env_filter("warn,test=debug,monero_harness=debug,monero_rpc=debug")
|
|
|
|
.set_default();
|
2021-01-10 20:55:19 -05:00
|
|
|
|
2020-11-01 18:02:28 -05:00
|
|
|
let tc = Cli::default();
|
2021-03-02 18:56:49 -05:00
|
|
|
let (monero, _monerod_container) = Monero::new(&tc, vec![]).await.unwrap();
|
2020-11-01 18:02:28 -05:00
|
|
|
|
2020-11-02 19:46:25 -05:00
|
|
|
monero.init(vec![]).await.unwrap();
|
|
|
|
|
2020-11-02 00:00:35 -05:00
|
|
|
let monerod = monero.monerod();
|
|
|
|
let miner_wallet = monero.wallet("miner").unwrap();
|
2020-11-01 18:02:28 -05:00
|
|
|
|
2020-11-02 00:00:35 -05:00
|
|
|
let got_miner_balance = miner_wallet.balance().await.unwrap();
|
2020-11-01 18:02:28 -05:00
|
|
|
assert_that!(got_miner_balance).is_greater_than(0);
|
|
|
|
|
2021-01-15 00:58:16 -05:00
|
|
|
time::sleep(Duration::from_millis(1010)).await;
|
2020-09-28 02:18:50 -04:00
|
|
|
|
2020-11-01 18:02:28 -05:00
|
|
|
// after a bit more than 1 sec another block should have been mined
|
2020-11-02 19:49:53 -05:00
|
|
|
let block_height = monerod.client().get_block_count().await.unwrap();
|
2020-09-28 02:18:50 -04:00
|
|
|
|
2020-11-01 18:02:28 -05:00
|
|
|
assert_that(&block_height).is_greater_than(70);
|
2020-09-28 02:18:50 -04:00
|
|
|
}
|