commit 8b89769ed6216a24590eaa0482abd0652cab68f2
parent fa5a0d1464eb5d70ad8924ae374164cf126ebb5d
Author: Florian Dold <dold@taler.net>
Date: Thu, 20 Aug 2026 19:06:48 +0200
wallet-core: make database conformance assertions effective
Diffstat:
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/packages/taler-wallet-core/src/dbtx-conformance-cases.ts b/packages/taler-wallet-core/src/dbtx-conformance-cases.ts
@@ -1083,6 +1083,7 @@ export const conformanceCases: ConformanceCase[] = [
{
name: "a throwing transaction rolls back its writes",
async run(t, runner) {
+ let rejected = false;
try {
await runner.runReadWriteTx(async (tx) => {
await tx.upsertContractTerms({
@@ -1091,10 +1092,10 @@ export const conformanceCases: ConformanceCase[] = [
});
throw Error("deliberate abort");
});
- t.fail("the transaction should have rethrown");
} catch (e) {
- // expected
+ rejected = true;
}
+ t.ok(rejected, "the transaction must reject when its callback throws");
const got = await runner.runReadWriteTx((tx) =>
tx.getContractTerms("rollback-hash"),
);
@@ -1132,6 +1133,7 @@ export const conformanceCases: ConformanceCase[] = [
name: "scheduleOnCommit does not run when the transaction aborts",
async run(t, runner) {
let ran = false;
+ let rejected = false;
try {
await runner.runReadWriteTx(async (tx) => {
tx.scheduleOnCommit(() => {
@@ -1140,8 +1142,9 @@ export const conformanceCases: ConformanceCase[] = [
throw Error("deliberate abort");
});
} catch (e) {
- // expected
+ rejected = true;
}
+ t.ok(rejected, "the aborted transaction must reject");
t.equal(ran, false, "commit hooks must not fire on a rolled-back tx");
},
},
@@ -1238,10 +1241,8 @@ export const conformanceCases: ConformanceCase[] = [
},
{
- name: "reserve: row ids are never reused after delete",
+ name: "reserve: generated row ids are strictly increasing",
async run(t, runner) {
- // Callers persist this id on the exchange entry, so a reused id would
- // silently repoint an exchange at a different reserve.
const first = await runner.runReadWriteTx((tx) =>
tx.upsertReserve(makeReserve("rpub-r1")),
);
@@ -3776,9 +3777,7 @@ export const conformanceCases: ConformanceCase[] = [
await runner.runReadWriteTx((tx) => tx.upsertPeerPushCredit(first));
let rejected = false;
try {
- await runner.runReadWriteTx((tx) =>
- tx.upsertPeerPushCredit(duplicate),
- );
+ await runner.runReadWriteTx((tx) => tx.upsertPeerPushCredit(duplicate));
} catch {
rejected = true;
}