test(fba): retain parent proof across isolated fragment contexts

This commit is contained in:
2026-10-03 08:20:27 +08:00
parent 51bf4e5558
commit 933dd4cdef
2 changed files with 10 additions and 6 deletions
+7 -5
View File
@@ -294,18 +294,20 @@ test('DELIVERY evidence failure still restores and restoration drift is a blocki
test('F40 hook faults only first signature, captures whole inventory and always cleans failed signing',async()=>{
const calls=[],restoration={restored:true,healthy:true,proxyStopped:true}
const inventory={scope:{...deliveryScope,warehouseId:'9',coverage:'CUSTOMER_WAREHOUSE_COMPLETE'},balances:[],positions:[],ledger:[]}
const context={context:{f40DeliveryEventFaultExecutor:{prepare:async s=>{assert.deepEqual(s,deliveryScope);calls.push('prepare')},
const parentProof={}
const context={context:{f40RootFulfillmentProof:parentProof,f40DeliveryEventFaultExecutor:{prepare:async s=>{assert.deepEqual(s,deliveryScope);calls.push('prepare')},
readProof:async()=>{calls.push('proof');return {...deliveryProof(),restored:true,restoration}},cleanup:async()=>{calls.push('cleanup');return restoration}},
f40ReadOnlyInventoryEvidence:async s=>{assert.equal(s.warehouseId,'9');calls.push('inventory');return structuredClone(inventory)}},createdResources:{phase5RootFulfillment:{}}}
f40ReadOnlyInventoryEvidence:async s=>{assert.equal(s.warehouseId,'9');calls.push('inventory');return structuredClone(inventory)}},createdResources:{phase3OrderSplitting:{}}}
assert.equal(await withDeliveryEventRecovery(context,deliveryScope,'9',0,async()=>{calls.push('sign');return 'signed'}),'signed')
assert.deepEqual(calls,['inventory','prepare','sign','proof','inventory','cleanup'])
assert.equal(context.createdResources.phase5RootFulfillment.deliveryEventRecovery.status,'VERIFIED')
assert.equal(parentProof.deliveryEventRecovery.status,'VERIFIED')
assert.equal(context.createdResources.phase5RootFulfillment,undefined)
await withDeliveryEventRecovery(context,deliveryScope,'9',1,async()=>calls.push('second'))
assert.equal(calls.at(-1),'second')
context.createdResources.phase5RootFulfillment={}
context.context.f40RootFulfillmentProof={}
await assert.rejects(withDeliveryEventRecovery(context,deliveryScope,'9',0,async()=>{throw Error('sign failed')}),/sign failed/)
assert.equal(calls.at(-1),'cleanup')
assert.equal(context.createdResources.phase5RootFulfillment.deliveryEventRecovery.restored,true)
assert.equal(context.context.f40RootFulfillmentProof.deliveryEventRecovery.restored,true)
})
test('Python DELIVERY SQL uses actual payload, original Lastleg retry, and Order database without inventory queries',()=>{
const result=spawnSync('python',['-c',String.raw`