parent
0dcb4e56be
commit
f5643a4ea4
@ -1,2 +1,2 @@
|
||||
[workspace]
|
||||
members = ["monero-harness", "xmr-btc", "swap"]
|
||||
members = ["monero-harness"]
|
||||
|
@ -1,31 +0,0 @@
|
||||
use monero_harness::Monero;
|
||||
use spectral::prelude::*;
|
||||
use testcontainers::clients::Cli;
|
||||
|
||||
const ALICE_FUND_AMOUNT: u64 = 1_000_000_000_000;
|
||||
const BOB_FUND_AMOUNT: u64 = 0;
|
||||
|
||||
#[tokio::test]
|
||||
async fn init_accounts_for_alice_and_bob() {
|
||||
let tc = Cli::default();
|
||||
let (monero, _container) = Monero::new(&tc).unwrap();
|
||||
monero
|
||||
.init(ALICE_FUND_AMOUNT, BOB_FUND_AMOUNT)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let got_balance_alice = monero
|
||||
.alice_wallet_rpc_client()
|
||||
.get_balance(0)
|
||||
.await
|
||||
.expect("failed to get alice's balance");
|
||||
|
||||
let got_balance_bob = monero
|
||||
.bob_wallet_rpc_client()
|
||||
.get_balance(0)
|
||||
.await
|
||||
.expect("failed to get bob's balance");
|
||||
|
||||
assert_that!(got_balance_alice).is_equal_to(ALICE_FUND_AMOUNT);
|
||||
assert_that!(got_balance_bob).is_equal_to(BOB_FUND_AMOUNT);
|
||||
}
|
@ -1,21 +1,51 @@
|
||||
use monero_harness::Monero;
|
||||
use spectral::prelude::*;
|
||||
use std::time::Duration;
|
||||
use testcontainers::clients::Cli;
|
||||
|
||||
fn init_cli() -> Cli {
|
||||
Cli::default()
|
||||
}
|
||||
use tokio::time;
|
||||
|
||||
#[tokio::test]
|
||||
async fn connect_to_monerod() {
|
||||
let tc = init_cli();
|
||||
let (monero, _container) = Monero::new(&tc).unwrap();
|
||||
let cli = monero.monerod_rpc_client();
|
||||
async fn init_miner_and_mine_to_miner_address() {
|
||||
let tc = Cli::default();
|
||||
let (monerod, _monerod_container) = Monero::new_monerod(&tc).unwrap();
|
||||
|
||||
let (miner_wallet, _wallet_container) = Monero::new_wallet(&tc, "miner").await.unwrap();
|
||||
|
||||
let address = miner_wallet
|
||||
.wallet_rpc_client()
|
||||
.get_address(0)
|
||||
.await
|
||||
.unwrap()
|
||||
.address;
|
||||
|
||||
monerod.start_miner(&address).await.unwrap();
|
||||
|
||||
let block_height = monerod
|
||||
.monerod_rpc_client()
|
||||
.get_block_count()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
miner_wallet
|
||||
.wait_for_wallet_height(block_height)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let got_miner_balance = miner_wallet
|
||||
.wallet_rpc_client()
|
||||
.get_balance(0)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_that!(got_miner_balance).is_greater_than(0);
|
||||
|
||||
time::delay_for(Duration::from_millis(1010)).await;
|
||||
|
||||
let header = cli
|
||||
.get_block_header_by_height(0)
|
||||
// after a bit more than 1 sec another block should have been mined
|
||||
let block_height = monerod
|
||||
.monerod_rpc_client()
|
||||
.get_block_count()
|
||||
.await
|
||||
.expect("failed to get block 0");
|
||||
.unwrap();
|
||||
|
||||
assert_that!(header.height).is_equal_to(0);
|
||||
assert_that(&block_height).is_greater_than(70);
|
||||
}
|
||||
|
Loading…
Reference in new issue