Skip to content

Commit 5f12d2b

Browse files
committed
Fix tests
1 parent 42ed35f commit 5f12d2b

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

Diff for: client/src/format.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,10 @@ pub fn print_list_unspent(utxos: Vec<WalletOutput>, format: Format) {
152152
pub fn print_server_info(info: ServerInfo, format: Format) {
153153
match format {
154154
Format::Text => {
155-
println!("CHAIN: {}", info.network);
156-
println!(" Height {}", info.tip.height);
157-
println!(" Hash {}", info.tip.hash);
155+
println!("Network: {}", info.network);
156+
println!("Height {}", info.tip.height);
157+
println!("Hash {}", info.tip.hash);
158+
println!("Progress {:.2}%", info.progress * 100.0);
158159
}
159160
Format::Json => {
160161
println!("{}", serde_json::to_string_pretty(&info).unwrap());

Diff for: client/src/rpc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,7 @@ async fn get_server_info(client: &reqwest::Client, rpc: &BitcoinRpc, tip: ChainA
15911591
blocks: info.blocks,
15921592
headers: info.headers,
15931593
},
1594-
progress: if info.headers >= tip.height {
1594+
progress: if info.headers != 0 && info.headers >= tip.height {
15951595
tip.height as f32 / info.headers as f32
15961596
} else {
15971597
0.0

Diff for: client/tests/fetcher_tests.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use spaces_client::source::{
88
BitcoinBlockSource, BitcoinRpc, BitcoinRpcAuth, BlockEvent, BlockFetcher,
99
};
1010
use spaces_protocol::{bitcoin::BlockHash, constants::ChainAnchor};
11+
use spaces_protocol::bitcoin::Network;
1112
use spaces_testutil::TestRig;
1213

1314
async fn setup(blocks: u64) -> Result<(TestRig, u64, BlockHash)> {
@@ -27,8 +28,9 @@ fn test_block_fetching_from_bitcoin_rpc() -> Result<()> {
2728
let fetcher_rpc = BitcoinBlockSource::new(BitcoinRpc::new(
2829
&rig.bitcoind.rpc_url(),
2930
BitcoinRpcAuth::UserPass("user".to_string(), "password".to_string()),
31+
true
3032
));
31-
let (fetcher, receiver) = BlockFetcher::new(fetcher_rpc.clone(), 8);
33+
let (fetcher, receiver) = BlockFetcher::new(Network::Regtest, fetcher_rpc.clone(), 8);
3234
fetcher.start(ChainAnchor { hash, height: 0 });
3335

3436
let timeout = Duration::from_secs(5);

0 commit comments

Comments
 (0)