Skip to content

Commit d4983f5

Browse files
committed
add getzmqnotifications integration test
1 parent 85fa822 commit d4983f5

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

integration_test/run.sh

+3-1
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

+35-1
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
Sequence, SignedAmount, 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

@@ -1422,6 +1424,38 @@ fn test_get_index_info(cl: &Client) {
14221424
}
14231425
}
14241426

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

0 commit comments

Comments
 (0)