From 933dd4cdefe9bc0f9cdc441c72b23d94d5c7764b Mon Sep 17 00:00:00 2001 From: ouyangxq <775153912@qq.com> Date: Sat, 3 Oct 2026 08:20:27 +0800 Subject: [PATCH] test(fba): retain parent proof across isolated fragment contexts --- .../phase5-root-fulfillment.mjs | 4 +++- scripts/test-event-fault-executor.test.mjs | 12 +++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/admin-test-env-modules/phase5-root-fulfillment.mjs b/scripts/admin-test-env-modules/phase5-root-fulfillment.mjs index 5d16542fa..3cbf1b110 100644 --- a/scripts/admin-test-env-modules/phase5-root-fulfillment.mjs +++ b/scripts/admin-test-env-modules/phase5-root-fulfillment.mjs @@ -449,7 +449,8 @@ async function sendFragment(context, producer, picker, merchantToken, index) { export async function withDeliveryEventRecovery(context, faultScope, warehouseId, index, sign) { const executor = context.context.f40DeliveryEventFaultExecutor if (!executor || index !== 0) return sign() - const proof = context.createdResources.phase5RootFulfillment + const proof = context.context.f40RootFulfillmentProof + if (!proof) throw Error('F40 parent fulfillment proof required') if (proof.deliveryEventRecovery) throw Error('F40 delivery recovery already attempted') const reader = context.context.f40ReadOnlyInventoryEvidence if (typeof reader !== 'function') throw Error('F40 complete inventory evidence reader required') @@ -521,6 +522,7 @@ async function runRootFulfillment(context) { const scope = Object.create(context) scope.marker = `${context.marker}-F40` scope.context = { ...context.context, orderDestinationType: 'FBA', orderFulfillmentType: 'STANDARD', + f40RootFulfillmentProof: proof, orderStopAtApproved:cancelRemainder, orderProfile: { taxMode, fulfillmentType: 'STANDARD' },f40TaxMode:taxMode,f40TaxEvidence:proof.taxCustoms, waitSplitVariant: { skuCount: 1, packageCountPerSku: 2, packageCounts: [2] }, diff --git a/scripts/test-event-fault-executor.test.mjs b/scripts/test-event-fault-executor.test.mjs index 5b0df0ed4..53d4c8c0c 100644 --- a/scripts/test-event-fault-executor.test.mjs +++ b/scripts/test-event-fault-executor.test.mjs @@ -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`