Skip to content

Commit 1c362b1

Browse files
committed
add getzmqnotifications integration test
1 parent b8fa99d commit 1c362b1

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

integration_test/run.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ bitcoind -regtest $BLOCKFILTERARG $FALLBACKFEEARG \
3434
-rpcport=12349 \
3535
-server=1 \
3636
-txindex=1 \
37-
-printtoconsole=0 &
37+
-printtoconsole=0 \
38+
-zmqpubrawblock=tcp://0.0.0.0:28332 \
39+
-zmqpubrawtx=tcp://0.0.0.0:28333 &
3840
PID2=$!
3941

4042
# Let it connect to the other node.

integration_test/src/main.rs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#[macro_use]
1414
extern crate lazy_static;
1515

16+
use std::cmp::Ordering;
1617
use std::collections::HashMap;
1718
use std::str::FromStr;
1819

@@ -32,7 +33,7 @@ use bitcoin::{
3233
Transaction, TxIn, TxOut, Txid, Witness,
3334
};
3435
use bitcoincore_rpc::bitcoincore_rpc_json::{
35-
GetBlockTemplateModes, GetBlockTemplateRules, ScanTxOutRequest,
36+
GetBlockTemplateModes, GetBlockTemplateRules, GetZmqNotificationsResult, ScanTxOutRequest,
3637
};
3738

3839
lazy_static! {
@@ -226,6 +227,7 @@ fn main() {
226227
test_add_ban(&cl);
227228
test_set_network_active(&cl);
228229
test_get_index_info(&cl);
230+
test_get_zmq_notifications(&cl);
229231
test_stop(cl);
230232
}
231233

@@ -1426,6 +1428,38 @@ fn test_get_index_info(cl: &Client) {
14261428
}
14271429
}
14281430

1431+
fn test_get_zmq_notifications(cl: &Client) {
1432+
let mut zmq_info = cl.get_zmq_notifications().unwrap();
1433+
1434+
// it doesn't matter in which order Bitcoin Core returns the result,
1435+
// but checking it is easier if it has a known order
1436+
zmq_info.sort_by(|a, b| {
1437+
if a.address < b.address {
1438+
Ordering::Less
1439+
} else if a.address == b.address {
1440+
Ordering::Equal
1441+
} else {
1442+
Ordering::Greater
1443+
}
1444+
});
1445+
1446+
assert!(
1447+
zmq_info
1448+
== vec![
1449+
GetZmqNotificationsResult {
1450+
notification_type: "pubrawblock".to_owned(),
1451+
address: "tcp://0.0.0.0:28332".to_owned(),
1452+
hwm: 1000
1453+
},
1454+
GetZmqNotificationsResult {
1455+
notification_type: "pubrawtx".to_owned(),
1456+
address: "tcp://0.0.0.0:28333".to_owned(),
1457+
hwm: 1000
1458+
},
1459+
]
1460+
);
1461+
}
1462+
14291463
fn test_stop(cl: Client) {
14301464
println!("Stopping: '{}'", cl.stop().unwrap());
14311465
}

0 commit comments

Comments
 (0)