Remove wrapper functions

This commit is contained in:
Thomas Eizinger 2020-12-07 10:49:50 +11:00
parent ffb9d0e000
commit 619d359e91
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96
4 changed files with 9 additions and 41 deletions

View File

@ -35,6 +35,7 @@ use crate::{
},
rpc::{
monerod,
monerod_api::MonerodRpcApi,
wallet::{self, GetAddress, Refreshed, Transfer},
},
};
@ -118,10 +119,7 @@ impl<'c> Monero {
// generate the first 70 as bulk
let monerod = &self.monerod;
let block = monerod
.client()?
.generate_blocks(70, &miner_address)
.await?;
let block = monerod.client()?.generateblocks(70, &miner_address).await?;
tracing::info!("Generated {:?} blocks", block);
miner_wallet.refresh().await?;
@ -131,10 +129,7 @@ impl<'c> Monero {
let address = wallet.address().await?.address;
miner_wallet.transfer(&address, *amount).await?;
tracing::info!("Funded {} wallet with {}", wallet.name, amount);
monerod
.client()?
.generate_blocks(10, &miner_address)
.await?;
monerod.client()?.generateblocks(10, &miner_address).await?;
wallet.refresh().await?;
}
}
@ -142,7 +137,7 @@ impl<'c> Monero {
monerod.start_miner(&miner_address).await?;
tracing::info!("Waiting for miner wallet to catch up...");
let block_height = monerod.client()?.get_block_count_rpc().await?;
let block_height = monerod.client()?.get_block_count().await?;
miner_wallet
.wait_for_wallet_height(block_height)
.await
@ -302,6 +297,6 @@ impl<'c> MoneroWalletRpc {
async fn mine(monerod: monerod::Client, reward_address: String) -> Result<()> {
loop {
time::delay_for(Duration::from_secs(BLOCK_TIME_SECS)).await;
monerod.generate_blocks(1, &reward_address).await?;
monerod.generateblocks(1, &reward_address).await?;
}
}

View File

@ -15,28 +15,6 @@ impl Client {
base_url: reqwest::Url::parse(format!("http://127.0.0.1:{}/json_rpc", port).as_str())?,
})
}
pub async fn generate_blocks(
&self,
amount_of_blocks: u32,
wallet_address: &str,
) -> anyhow::Result<GenerateBlocks> {
let res: GenerateBlocks = self
.generateblocks(amount_of_blocks, wallet_address)
.await?;
Ok(res)
}
// TODO: We should not need wrapper functions, why does it not compile without?
pub async fn get_block_header_by_height_rpc(&self, height: u32) -> anyhow::Result<BlockHeader> {
let res: BlockHeader = self.get_block_header_by_height(height).await?;
Ok(res)
}
pub async fn get_block_count_rpc(&self) -> anyhow::Result<u32> {
let res: u32 = self.get_block_count().await?;
Ok(res)
}
}
#[derive(Clone, Debug, Serialize)]

View File

@ -1,4 +1,4 @@
use monero_harness::Monero;
use monero_harness::{rpc::monerod_api::MonerodRpcApi, Monero};
use spectral::prelude::*;
use std::time::Duration;
use testcontainers::clients::Cli;
@ -20,12 +20,7 @@ async fn init_miner_and_mine_to_miner_address() {
time::delay_for(Duration::from_millis(1010)).await;
// after a bit more than 1 sec another block should have been mined
let block_height = monerod
.client()
.unwrap()
.get_block_count_rpc()
.await
.unwrap();
let block_height = monerod.client().unwrap().get_block_count().await.unwrap();
assert_that(&block_height).is_greater_than(70);
}

View File

@ -1,4 +1,4 @@
use monero_harness::Monero;
use monero_harness::{rpc::monerod_api::MonerodRpcApi, Monero};
use spectral::prelude::*;
use testcontainers::clients::Cli;
@ -43,7 +43,7 @@ async fn fund_transfer_and_check_tx_key() {
.monerod()
.client()
.unwrap()
.generate_blocks(10, &miner_address)
.generateblocks(10, &miner_address)
.await
.unwrap();