1313#[ macro_use]
1414extern crate lazy_static;
1515
16+ use std:: cmp:: Ordering ;
1617use std:: collections:: HashMap ;
1718use std:: str:: FromStr ;
1819
@@ -32,7 +33,7 @@ use bitcoin::{
3233 Transaction , TxIn , TxOut , Txid , Witness ,
3334} ;
3435use bitcoincore_rpc:: bitcoincore_rpc_json:: {
35- GetBlockTemplateModes , GetBlockTemplateRules , ScanTxOutRequest ,
36+ GetBlockTemplateModes , GetBlockTemplateRules , GetZmqNotificationsResult , ScanTxOutRequest ,
3637} ;
3738
3839lazy_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+
14291463fn test_stop ( cl : Client ) {
14301464 println ! ( "Stopping: '{}'" , cl. stop( ) . unwrap( ) ) ;
14311465}
0 commit comments