Skip to content

Commit 2f8898d

Browse files
committed
Add wait for (new) block integration tests.
1 parent 69de1aa commit 2f8898d

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

integration_test/src/main.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,10 @@ fn main() {
209209
test_unloadwallet(&cl);
210210
test_loadwallet(&cl);
211211
test_backupwallet(&cl);
212+
test_wait_for_new_block(&cl);
213+
test_wait_for_block(&cl);
212214
//TODO import_multi(
213215
//TODO verify_message(
214-
//TODO wait_for_new_block(&self, timeout: u64) -> Result<json::BlockRef> {
215-
//TODO wait_for_block(
216216
//TODO get_descriptor_info(&self, desc: &str) -> Result<json::GetDescriptorInfoResult> {
217217
//TODO derive_addresses(&self, descriptor: &str, range: Option<[u32; 2]>) -> Result<Vec<Address>> {
218218
//TODO encrypt_wallet(&self, passphrase: &str) -> Result<()> {
@@ -1311,6 +1311,22 @@ fn test_backupwallet(_: &Client) {
13111311
assert!(wallet_client.backup_wallet(Some(&backup_path)).is_ok());
13121312
}
13131313

1314+
fn test_wait_for_new_block(cl: &Client) {
1315+
let height = cl.get_block_count().unwrap();
1316+
let hash = cl.get_block_hash(height).unwrap();
1317+
1318+
assert!(cl.wait_for_new_block(std::u64::MAX).is_err()); // JSON integer out of range
1319+
assert_eq!(cl.wait_for_new_block(100).unwrap(), json::BlockRef{hash, height});
1320+
}
1321+
1322+
fn test_wait_for_block(cl: &Client) {
1323+
let height = cl.get_block_count().unwrap();
1324+
let hash = cl.get_block_hash(height).unwrap();
1325+
1326+
assert!(cl.wait_for_block(&hash, std::u64::MAX).is_err()); // JSON integer out of range
1327+
assert_eq!(cl.wait_for_block(&hash, 0).unwrap(), json::BlockRef{hash, height});
1328+
}
1329+
13141330
fn test_get_index_info(cl: &Client) {
13151331
if version() >= 210000 {
13161332
let gii = cl.get_index_info().unwrap();

0 commit comments

Comments
 (0)