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