File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ use utils::test_logger;
49
49
use secp256k1:: key:: { PublicKey , SecretKey } ;
50
50
use secp256k1:: Secp256k1 ;
51
51
52
+ use std:: collections:: HashSet ;
52
53
use std:: sync:: { Arc , Mutex } ;
53
54
use std:: io:: Cursor ;
54
55
@@ -435,13 +436,19 @@ pub fn do_test(data: &[u8]) {
435
436
436
437
macro_rules! process_events {
437
438
( $node: expr, $fail: expr) => { {
439
+ // In case we get 256 payments we may have a hash collision, resulting in the
440
+ // second claim/fail call not finding the duplicate-hash HTLC, so we have to
441
+ // deduplicate the calls here.
442
+ let mut claim_set = HashSet :: new( ) ;
438
443
for event in nodes[ $node] . get_and_clear_pending_events( ) {
439
444
match event {
440
445
events:: Event :: PaymentReceived { payment_hash, .. } => {
441
- if $fail {
442
- assert!( nodes[ $node] . fail_htlc_backwards( & payment_hash) ) ;
443
- } else {
444
- assert!( nodes[ $node] . claim_funds( PaymentPreimage ( payment_hash. 0 ) ) ) ;
446
+ if claim_set. insert( payment_hash. 0 ) {
447
+ if $fail {
448
+ assert!( nodes[ $node] . fail_htlc_backwards( & payment_hash) ) ;
449
+ } else {
450
+ assert!( nodes[ $node] . claim_funds( PaymentPreimage ( payment_hash. 0 ) ) ) ;
451
+ }
445
452
}
446
453
} ,
447
454
events:: Event :: PaymentSent { .. } => { } ,
You can’t perform that action at this time.
0 commit comments