Support deferred payments with travel deals
Verify and publish checkpoint container / container (push) Successful in 11m29s

This commit is contained in:
Quintine committed 2026-11-16 14:17:48 +11:00
1 parent 9536c77062
commit 5e294215be
16 files changed
+603 -100

No files matched your search

+14 -7
View File
@@ -119,11 +119,11 @@ void test('a released deal cannot retain an unfulfilled live travel receipt', ()
reject(corrupted, f.target, f.currentEnd);
});
void test('travel terms reject payment combinations, multiparty packets and malformed claims', () => {
void test('travel terms reject invalid payment, participant and malformed travel claims', () => {
const f = fixture(), term: Term = { kind: 'ship', territory: f.shipmentTerritory, minimum: 1, answer: true };
const basic = { type: 'dealOffer', target: f.target, terms: 'Agreed travel.', travel: term } satisfies Action;
reject(f.game, f.asker, { ...basic, payment: { kind: 'deferredBribe', payer: f.target,
recipient: f.asker, amount: 1, dueTurn: f.game.turn } });
recipient: f.asker, amount: 1, dueTurn: f.game.turn - 1 } });
reject(f.game, f.asker, { type: 'dealOffer', targets: [f.target, f.asker], terms: 'Travel.', travel: term });
reject(f.game, f.asker, { ...basic, travel: { ...term, minimum: 0 } });
reject(f.game, f.asker, { ...basic, travel: { ...term, answer: 'yes' } });
@@ -162,7 +162,7 @@ void test('final consent to a conflicting obligation rolls back without disturbi
assert.equal(status(completed, f.target, first.id), 'fulfilled');
});
void test('a pending travel term prevents final consent to a separate current-turn deferred bribe', () => {
void test('a pending travel term can coexist with a separately accepted current-turn deferred bribe', () => {
const f = fixture(), offered = offer(f.game, f.asker, f.target,
{ kind: 'ship', territory: f.shipmentTerritory, minimum: 1, answer: true });
let game = accept(offered.game, f.target, offered.id);
@@ -171,15 +171,22 @@ void test('a pending travel term prevents final consent to a separate current-tu
const payment = game.deals!.at(-1)!;
assert.notEqual(payment.id, offered.id);
assert.equal(payment.status, 'offered');
const before = structuredClone(game);
reject(game, f.target, { type: 'dealRespond', deal: payment.id, accept: true });
assert.deepEqual(game, before);
const cash = player(game, f.target).spice, incoming = player(game, f.asker).bribes;
assert.ok(cash >= f.shipmentCost + 1);
game = accept(game, f.target, payment.id);
assert.equal(game.deals!.find(deal => deal.id === offered.id)!.status, 'active');
assert.equal(game.deals!.find(deal => deal.id === payment.id)!.status, 'offered');
assert.equal(game.deals!.find(deal => deal.id === payment.id)!.status, 'active');
assert.equal(game.deals!.find(deal => deal.id === payment.id)!.paymentStatus, 'pending');
assert.equal(status(game, f.target, offered.id), 'pending');
assert.equal(receipt(game, offered.id).released, false);
game = act(game, f.target, {type:'dealPay', deal:payment.id});
assert.equal(player(game, f.target).spice, cash - 1);
assert.equal(player(game, f.asker).bribes, incoming + 1);
assert.equal(game.deals!.find(deal => deal.id === payment.id)!.paymentStatus, 'paid');
const completed = settle(act(game, f.target, f.shipmentAction));
assert.equal(status(completed, f.target, offered.id), 'fulfilled');
assert.equal(player(completed, f.target).spice, cash - 1 - f.shipmentCost);
assert.deepEqual(inventory(completed), f.originalCards);
});
void test('final travel consent rejects a target with a live native Truthtrance bribe promise', () => {