@@ -21,7 +21,9 @@ use util::test_utils;
21
21
use util:: ser:: { ReadableArgs , Writeable } ;
22
22
23
23
use bitcoin:: blockdata:: block:: { Block , BlockHeader } ;
24
+ use bitcoin:: blockdata:: constants:: genesis_block;
24
25
use bitcoin:: hash_types:: BlockHash ;
26
+ use bitcoin:: network:: constants:: Network ;
25
27
26
28
use std:: collections:: HashMap ;
27
29
use std:: mem;
@@ -208,7 +210,7 @@ fn do_test_unconf_chan(reload_node: bool, reorg_after_reload: bool) {
208
210
mem:: drop ( channel_state) ;
209
211
210
212
let mut headers = Vec :: new ( ) ;
211
- let mut header = BlockHeader { version : 0x20000000 , prev_blockhash : Default :: default ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
213
+ let mut header = BlockHeader { version : 0x20000000 , prev_blockhash : genesis_block ( Network :: Testnet ) . header . block_hash ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
212
214
headers. push ( header. clone ( ) ) ;
213
215
for _i in 2 ..100 {
214
216
header = BlockHeader { version : 0x20000000 , prev_blockhash : header. block_hash ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
@@ -319,7 +321,7 @@ fn test_set_outpoints_partial_claiming() {
319
321
check_spends ! ( remote_txn[ 2 ] , remote_txn[ 0 ] ) ;
320
322
321
323
// Connect blocks on node A to advance height towards TEST_FINAL_CLTV
322
- let prev_header_100 = connect_blocks ( & nodes[ 1 ] , 100 , 0 , false , Default :: default ( ) ) ;
324
+ let block_hash_100 = connect_blocks ( & nodes[ 1 ] , 100 , 0 , false , genesis_block ( Network :: Testnet ) . header . block_hash ( ) ) ;
323
325
// Provide node A with both preimage
324
326
nodes[ 0 ] . node . claim_funds ( payment_preimage_1, & None , 3_000_000 ) ;
325
327
nodes[ 0 ] . node . claim_funds ( payment_preimage_2, & None , 3_000_000 ) ;
@@ -328,8 +330,8 @@ fn test_set_outpoints_partial_claiming() {
328
330
nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
329
331
330
332
// Connect blocks on node A commitment transaction
331
- let header = BlockHeader { version : 0x20000000 , prev_blockhash : prev_header_100 , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
332
- connect_block ( & nodes[ 0 ] , & Block { header, txdata : vec ! [ remote_txn[ 0 ] . clone( ) ] } , 101 ) ;
333
+ let header_101 = BlockHeader { version : 0x20000000 , prev_blockhash : block_hash_100 , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
334
+ connect_block ( & nodes[ 0 ] , & Block { header : header_101 , txdata : vec ! [ remote_txn[ 0 ] . clone( ) ] } , 101 ) ;
333
335
check_closed_broadcast ! ( nodes[ 0 ] , false ) ;
334
336
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
335
337
// Verify node A broadcast tx claiming both HTLCs
@@ -361,8 +363,8 @@ fn test_set_outpoints_partial_claiming() {
361
363
} ;
362
364
363
365
// Broadcast partial claim on node A, should regenerate a claiming tx with HTLC dropped
364
- let header = BlockHeader { version : 0x20000000 , prev_blockhash : header . block_hash ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
365
- connect_block ( & nodes[ 0 ] , & Block { header, txdata : vec ! [ partial_claim_tx. clone( ) ] } , 102 ) ;
366
+ let header_102 = BlockHeader { version : 0x20000000 , prev_blockhash : header_101 . block_hash ( ) , merkle_root : Default :: default ( ) , time : 42 , bits : 42 , nonce : 42 } ;
367
+ connect_block ( & nodes[ 0 ] , & Block { header : header_102 , txdata : vec ! [ partial_claim_tx. clone( ) ] } , 102 ) ;
366
368
{
367
369
let mut node_txn = nodes[ 0 ] . tx_broadcaster . txn_broadcasted . lock ( ) . unwrap ( ) ;
368
370
assert_eq ! ( node_txn. len( ) , 1 ) ;
@@ -373,7 +375,7 @@ fn test_set_outpoints_partial_claiming() {
373
375
nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
374
376
375
377
// Disconnect last block on node A, should regenerate a claiming tx with HTLC dropped
376
- disconnect_block ( & nodes[ 0 ] , & header , 102 ) ;
378
+ disconnect_block ( & nodes[ 0 ] , & header_102 , 102 ) ;
377
379
{
378
380
let mut node_txn = nodes[ 0 ] . tx_broadcaster . txn_broadcasted . lock ( ) . unwrap ( ) ;
379
381
assert_eq ! ( node_txn. len( ) , 1 ) ;
@@ -383,8 +385,8 @@ fn test_set_outpoints_partial_claiming() {
383
385
}
384
386
385
387
//// Disconnect one more block and then reconnect multiple no transaction should be generated
386
- disconnect_block ( & nodes[ 0 ] , & header , 101 ) ;
387
- connect_blocks ( & nodes[ 1 ] , 15 , 101 , false , prev_header_100 ) ;
388
+ disconnect_block ( & nodes[ 0 ] , & header_101 , 101 ) ;
389
+ connect_blocks ( & nodes[ 1 ] , 15 , 101 , false , block_hash_100 ) ;
388
390
{
389
391
let mut node_txn = nodes[ 0 ] . tx_broadcaster . txn_broadcasted . lock ( ) . unwrap ( ) ;
390
392
assert_eq ! ( node_txn. len( ) , 0 ) ;
0 commit comments