Skip to content

Commit 77b7594

Browse files
committed
Check for exact events in the monitor unit test for Payjoin broadcast detection
1 parent 93b6816 commit 77b7594

File tree

1 file changed

+9
-3
lines changed
  • payjoin/src/core/receive/v2

1 file changed

+9
-3
lines changed

payjoin/src/core/receive/v2/mod.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ impl Receiver<Monitor> {
12441244
tx.input.get(i).expect("sender_input_indexes should return valid indices");
12451245
sender_witnesses.push((input.script_sig.clone(), input.witness.clone()));
12461246
}
1247-
// Payjoin transaction with segwit inputs was detected. Log the signatures and complete the session
1247+
// Payjoin transaction with SegWit inputs was detected. Log the signatures and complete the session.
12481248
return MaybeFatalOrSuccessTransition::success(SessionEvent::Closed(
12491249
SessionOutcome::Success(sender_witnesses),
12501250
));
@@ -1435,9 +1435,15 @@ pub mod test {
14351435
assert!(matches!(res, OptionalTransitionOutcome::Progress(_)));
14361436
assert!(persister.inner.read().expect("Shouldn't be poisoned").is_closed);
14371437
assert_eq!(persister.inner.read().expect("Shouldn't be poisoned").events.len(), 1);
1438-
// TODO: check for exact events
1438+
assert_eq!(
1439+
persister.inner.read().expect("Shouldn't be poisoned").events.last(),
1440+
Some(&SessionEvent::Closed(SessionOutcome::Success(vec![(
1441+
ScriptBuf::default(),
1442+
Witness::default()
1443+
)])))
1444+
);
14391445

1440-
// fallback was broadcasted, should progress to success
1446+
// Fallback was broadcasted, should progress to success
14411447
let persister = InMemoryTestPersister::default();
14421448
let res = monitor
14431449
.check_payment(

0 commit comments

Comments
 (0)