Add comprehensive tests for multi-output transaction tracking defect fix #85

Merged
russellballestrini merged 2 commits from feature/multi-output-refunds into master 2025-10-03 11:45:00 -04:00

2 commits

Author SHA1 Message Date
f85cd3907c Fix SQLAlchemy initialization issue in multi-output transaction tests
Remove spec parameter from MagicMock to avoid triggering SQLAlchemy mapper
initialization during test setup. Tests remain effective by validating actual
crypto watcher logic while mocking only the database object interfaces.
2025-10-03 11:40:34 -04:00
8301e23c3f Add comprehensive tests for multi-output transaction tracking defect fix
This adds complete test coverage for the critical fix where multi-output refund transactions
now set both refund_tx_hash AND swept_tx_hash to prevent re-sweeping already swept payments.

Key test scenarios covered:
- Multi-output refund transaction creation (XMR and DOGE)
- Shop sweep amount calculation: max(0, received_amount - refund_amount)
- Prevention of double-sweep attempts when swept_tx_hash is already set
- Same transaction hash handling for both refund and sweep monitoring
- Real-world defect scenario using actual transaction hash from logs
- Edge cases including full refunds and negative amount protection

The tests validate that the "insufficient funds" error has been resolved by ensuring
payments with existing swept_tx_hash are not swept again.
2025-10-03 11:32:37 -04:00