@@ -8138,7 +8138,7 @@ fn test_preimage_storage() {
8138
8138
create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: known ( ) , InitFeatures :: known ( ) ) . 0 . contents . short_channel_id ;
8139
8139
8140
8140
{
8141
- let ( payment_hash, payment_secret) = nodes[ 1 ] . node . create_inbound_payment ( Some ( 100_000 ) , 1008 , 42 ) ;
8141
+ let ( payment_hash, payment_secret) = nodes[ 1 ] . node . create_inbound_payment ( Some ( 100_000 ) , 7200 , 42 ) ;
8142
8142
8143
8143
let logger = test_utils:: TestLogger :: new ( ) ;
8144
8144
let net_graph_msg_handler = & nodes[ 0 ] . net_graph_msg_handler ;
@@ -8176,19 +8176,29 @@ fn test_secret_timeout() {
8176
8176
8177
8177
let ( payment_hash, payment_secret_1) = nodes[ 1 ] . node . create_inbound_payment ( Some ( 100_000 ) , 2 , 0 ) ;
8178
8178
8179
- // We should fail to register the same payment hash twice, at least until we've connected two
8180
- // blocks .
8179
+ // We should fail to register the same payment hash twice, at least until we've connected a
8180
+ // block with time 7200 + CHAN_CONFIRM_DEPTH + 2 .
8181
8181
if let Err ( APIError :: APIMisuseError { err } ) = nodes[ 1 ] . node . create_inbound_payment_for_hash ( payment_hash, Some ( 100_000 ) , 2 , 0 ) {
8182
8182
assert_eq ! ( err, "Duplicate payment hash" ) ;
8183
8183
} else { panic ! ( ) ; }
8184
- connect_blocks ( & nodes[ 1 ] , 1 ) ;
8184
+ let mut block = Block {
8185
+ header : BlockHeader {
8186
+ version : 0x2000000 ,
8187
+ prev_blockhash : nodes[ 1 ] . blocks . borrow ( ) . last ( ) . unwrap ( ) . 0 . block_hash ( ) ,
8188
+ merkle_root : Default :: default ( ) ,
8189
+ time : nodes[ 1 ] . blocks . borrow ( ) . len ( ) as u32 + 7200 + 1 , bits : 42 , nonce : 42 } ,
8190
+ txdata : vec ! [ ] ,
8191
+ } ;
8192
+ connect_block ( & nodes[ 1 ] , & block) ;
8185
8193
if let Err ( APIError :: APIMisuseError { err } ) = nodes[ 1 ] . node . create_inbound_payment_for_hash ( payment_hash, Some ( 100_000 ) , 2 , 0 ) {
8186
8194
assert_eq ! ( err, "Duplicate payment hash" ) ;
8187
8195
} else { panic ! ( ) ; }
8188
8196
8189
8197
// If we then connect the second block, we should be able to register the same payment hash
8190
8198
// again with a different user_payment_id (this time getting a new payment secret).
8191
- connect_blocks ( & nodes[ 1 ] , 1 ) ;
8199
+ block. header . prev_blockhash = block. header . block_hash ( ) ;
8200
+ block. header . time += 1 ;
8201
+ connect_block ( & nodes[ 1 ] , & block) ;
8192
8202
let our_payment_secret = nodes[ 1 ] . node . create_inbound_payment_for_hash ( payment_hash, Some ( 100_000 ) , 2 , 42 ) . unwrap ( ) ;
8193
8203
assert_ne ! ( payment_secret_1, our_payment_secret) ;
8194
8204
0 commit comments