88use std:: collections:: HashMap ;
99
1010#[ cfg( not( feature = "v28_and_below" ) ) ]
11- use bitcoin:: {
12- absolute, transaction, consensus, Amount , OutPoint , ScriptBuf , Sequence , Transaction ,
13- TxIn , TxOut , Txid , Witness ,
14- } ;
15-
11+ use bitcoin:: hashes:: Hash ;
1612#[ cfg( not( feature = "v28_and_below" ) ) ]
1713use bitcoin:: hex:: DisplayHex ;
1814#[ cfg( not( feature = "v28_and_below" ) ) ]
19- use bitcoin:: hashes:: Hash ;
20-
15+ use bitcoin:: {
16+ absolute, consensus, transaction, Amount , OutPoint , ScriptBuf , Sequence , Transaction , TxIn ,
17+ TxOut , Txid , Witness ,
18+ } ;
2119use integration_test:: { Node , NodeExt as _, Wallet } ;
2220use node:: mtype;
2321use node:: vtype:: * ; // All the version specific types.
@@ -85,8 +83,8 @@ fn hidden__get_orphan_txs__modelled() {
8583 // Generate a couple of orphan transactions by spending from non-existing UTXOs.
8684 const NUM_ORPHANS : u8 = 3 ;
8785 let address = node1. client . new_address ( ) . expect ( "failed to get new address" ) ;
88- let orphans: Vec < Transaction > = ( 0 ..NUM_ORPHANS ) . map ( |i| {
89- Transaction {
86+ let orphans: Vec < Transaction > = ( 0 ..NUM_ORPHANS )
87+ . map ( |i| Transaction {
9088 version : transaction:: Version :: ONE ,
9189 lock_time : absolute:: LockTime :: ZERO ,
9290 input : vec ! [ TxIn {
@@ -102,8 +100,8 @@ fn hidden__get_orphan_txs__modelled() {
102100 value: Amount :: from_sat( 100_000 ) ,
103101 script_pubkey: address. script_pubkey( ) ,
104102 } ] ,
105- }
106- } ) . collect ( ) ;
103+ } )
104+ . collect ( ) ;
107105
108106 // The receiving node needs to be out of IBD to start accepting transactions.
109107 node2. mine_a_block ( ) ;
@@ -114,50 +112,50 @@ fn hidden__get_orphan_txs__modelled() {
114112 let tx_bytes = consensus:: encode:: serialize ( orphan) ;
115113 let tx_hex: String = tx_bytes. as_hex ( ) . to_string ( ) ;
116114 // HACK: We should use sendmsgtopeer directly but it's not implemented yet.
117- node1. client
115+ node1
116+ . client
118117 . call :: < HashMap < String , String > > (
119118 "sendmsgtopeer" ,
120119 & [ PEER_ID . into ( ) , "tx" . into ( ) , tx_hex. into ( ) ] ,
121- ) . unwrap ( ) ;
120+ )
121+ . unwrap ( ) ;
122122 }
123123
124124 let json_v0: GetOrphanTxs = node2. client . get_orphan_txs ( ) . expect ( "getorphantxs" ) ;
125- let json_v1: GetOrphanTxsVerboseOne = node2. client . get_orphan_txs_verbosity_1 ( ) . expect ( "getorphantxs 1" ) ;
126- let json_v2: GetOrphanTxsVerboseTwo = node2. client . get_orphan_txs_verbosity_2 ( ) . expect ( "getorphantxs 2" ) ;
125+ let json_v1: GetOrphanTxsVerboseOne =
126+ node2. client . get_orphan_txs_verbosity_1 ( ) . expect ( "getorphantxs 1" ) ;
127+ let json_v2: GetOrphanTxsVerboseTwo =
128+ node2. client . get_orphan_txs_verbosity_2 ( ) . expect ( "getorphantxs 2" ) ;
127129
128130 let model_v0: mtype:: GetOrphanTxs = json_v0. into_model ( ) ;
129131 let model_v1: mtype:: GetOrphanTxsVerboseOne = json_v1. into_model ( ) . unwrap ( ) ;
130132 let model_v2: mtype:: GetOrphanTxsVerboseTwo = json_v2. into_model ( ) . unwrap ( ) ;
131133
132-
133134 assert_eq ! ( model_v0. 0 . len( ) , NUM_ORPHANS as usize ) ;
134135 assert_eq ! ( model_v1. 0 . len( ) , NUM_ORPHANS as usize ) ;
135136 assert_eq ! ( model_v2. 0 . len( ) , NUM_ORPHANS as usize ) ;
136137
137138 for orphan in orphans. iter ( ) {
138139 assert ! ( model_v0. 0 . contains( & orphan. compute_txid( ) ) ) ;
139140
140- match model_v1. 0
141- . iter ( )
142- . filter ( |e| e. txid == orphan. compute_txid ( ) )
143- . next_back ( ) {
141+ match model_v1. 0 . iter ( ) . filter ( |e| e. txid == orphan. compute_txid ( ) ) . next_back ( ) {
144142 Some ( e) => {
145143 assert_eq ! ( e. wtxid, orphan. compute_wtxid( ) ) ;
146144 assert_eq ! ( e. bytes as usize , orphan. total_size( ) ) ;
147145 assert_eq ! ( e. vsize as usize , orphan. vsize( ) ) ;
148146 assert_eq ! ( e. weight, orphan. weight( ) . to_wu( ) ) ;
149147 // node2 received all orphans from node1, which is node2's peer=0
150148 assert_eq ! ( e. from, vec![ 0 ] ) ;
151- } ,
149+ }
152150 None => {
153- panic ! ( "Orphan with txid={} not found in `getorphantxs 1` response" , orphan. compute_txid( ) ) ;
151+ panic ! (
152+ "Orphan with txid={} not found in `getorphantxs 1` response" ,
153+ orphan. compute_txid( )
154+ ) ;
154155 }
155156 }
156157
157- match model_v2. 0
158- . iter ( )
159- . filter ( |e| e. txid == orphan. compute_txid ( ) )
160- . next_back ( ) {
158+ match model_v2. 0 . iter ( ) . filter ( |e| e. txid == orphan. compute_txid ( ) ) . next_back ( ) {
161159 Some ( e) => {
162160 assert_eq ! ( e. wtxid, orphan. compute_wtxid( ) ) ;
163161 assert_eq ! ( e. bytes as usize , orphan. total_size( ) ) ;
@@ -166,9 +164,12 @@ fn hidden__get_orphan_txs__modelled() {
166164 // node2 received all orphans from node1, which is node2's peer=0
167165 assert_eq ! ( e. from, vec![ 0 ] ) ;
168166 assert_eq ! ( e. transaction, * orphan) ;
169- } ,
167+ }
170168 None => {
171- panic ! ( "Orphan with txid={} not found in `getorphantxs 2` response" , orphan. compute_txid( ) ) ;
169+ panic ! (
170+ "Orphan with txid={} not found in `getorphantxs 2` response" ,
171+ orphan. compute_txid( )
172+ ) ;
172173 }
173174 }
174175 }
0 commit comments