(node_factory)
| 4727 | |
| 4728 | |
| 4729 | def test_sql_during_change(node_factory): |
| 4730 | l1 = node_factory.get_node() |
| 4731 | |
| 4732 | labels = [f"test_sql_during_delete{i:02}" for i in range(10)] |
| 4733 | for l in labels: |
| 4734 | l1.rpc.invoice(100, l, l) |
| 4735 | assert l1.rpc.sql("SELECT amount_msat, description, status FROM invoices ORDER BY description") == {'rows': [[100, l, 'unpaid'] for l in labels]} |
| 4736 | |
| 4737 | # It should wait on correct values |
| 4738 | l1.daemon.wait_for_logs(['lightningd: waiting on invoices created 11$', |
| 4739 | 'lightningd: waiting on invoices updated 1$', |
| 4740 | 'lightningd: waiting on invoices deleted 1$']) |
| 4741 | |
| 4742 | # Should notice extra one (note shorter expiry) |
| 4743 | l = f"test_sql_during_delete{11}" |
| 4744 | l1.rpc.invoice(100, l, l, expiry=10) |
| 4745 | labels.append(l) |
| 4746 | assert l1.rpc.sql("SELECT amount_msat, description, status FROM invoices ORDER BY description") == {'rows': [[100, l, 'unpaid'] for l in labels]} |
| 4747 | |
| 4748 | l1.daemon.wait_for_log('invoices: records created, inserting from 11') |
| 4749 | assert not l1.daemon.is_in_log('invoices: records updated') |
| 4750 | assert not l1.daemon.is_in_log('invoices: total reload due to delete') |
| 4751 | |
| 4752 | # Should notice delete. |
| 4753 | l1.rpc.delinvoice(labels[0], 'unpaid') |
| 4754 | del labels[0] |
| 4755 | assert l1.rpc.sql("SELECT amount_msat, description, status FROM invoices ORDER BY description") == {'rows': [[100, l, 'unpaid'] for l in labels]} |
| 4756 | |
| 4757 | l1.daemon.wait_for_log('invoices: total reload due to delete') |
| 4758 | |
| 4759 | # Should notice change once invoice has expired. |
| 4760 | wait_for(lambda: only_one(l1.rpc.listinvoices(label=labels[-1])['invoices'])['status'] != 'unpaid', timeout=10 + TIMEOUT) |
| 4761 | assert l1.rpc.sql("SELECT amount_msat, description, status FROM invoices ORDER BY description") == {'rows': [[100, l, 'unpaid'] for l in labels[:-1]] + [[100, labels[-1], 'expired']]} |
| 4762 | l1.daemon.wait_for_log('invoices: records updated, updating from 1') |
| 4763 | |
| 4764 | |
| 4765 | def test_listchannels_broken_message(node_factory): |
nothing calls this directly
no test coverage detected