store: widen payments.kind to accept 'tip' (tips were never stored) #102
Loading…
Reference in a new issue
No description provided.
Delete branch "wt/t_ecf204ad"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
insert_paymenthas acceptedkind = "tip"since the tip path landed, but thepaymentstable's CHECK only allowedinvoice/receipt. Every tip insert therefore failed with:That is not only the outbound card: the inbound path was broken too.
Node::ingest_tipwriteskind = "tip"first and returns on the error, so a received tip produced no payment row and no[tip]chat line, silently.What changed
src/store.rs: new stores getCHECK(kind IN ('invoice','receipt','tip')); stores written before this change are rebuilt on open bywiden_payment_kinds(SQLite cannot drop a CHECK), copying every row verbatim — ids, values andcreated_atincluded.src/node.rs: outboundtip()recordskind = "tip"with the tip's memo, matchingingest_tip; the_memoparameter is now used, so it is namedmemo. The[tip]chat line itself landed earlier in #96.Tests (TDD, RED first)
node::tests::outbound_tip_records_a_tip_payment_rowleft: "receipt", right: "tip"node::tests::an_inbound_tip_is_recorded_and_showninbound tip must be stored: CHECK constraint failedstore::at_rest::a_store_predating_tip_payments_is_widened_on_openVerification
cargo test --locked→ exit 0, 294 passed / 0 failed / 4 ignored (was 291)cargo clippy --locked --all-targets -- -D warnings→ exit 0rustfmt --edition 2024 --check src/{node,store}.rs→ 7/8 hunks, identical tomain(all inherited, none added)Scope note
The card that requested this allowed only
src/node.rs+tests/wallet.rs, and asked for the test intests/wallet.rs. Both were impossible:Node::startis the only public constructor and it bootstraps Tor, so aNodecannot be built fromtests/*.rs; and the requestedkind = "tip"row cannot be written at all without thesrc/store.rsschema change. The tests therefore live in the existing#[cfg(test)] mod testsinsrc/node.rs, next to the harness the wallet cards already use.insert_payment has allowed kind = "tip" since the tip path landed, but the payments table's CHECK only permitted invoice/receipt, so every tip insert failed ("CHECK constraint failed: kind IN ('invoice','receipt')"). That made the outbound tip row impossible and silently broke the inbound path too: ingest_tip returned early and neither the row nor the [tip] chat line was written. - recreate the table with the widened CHECK on open, copying rows verbatim (new stores get it from the schema directly) - outbound tip() records kind = "tip" with the tip's memo, matching ingest_tip - tests: outbound row, inbound round trip, pre-tip store migration Refs kanban t_ecf204ad05d7ada44967fb57296267fb572962186ec7436d