test(fba): retain parent proof across isolated fragment contexts
This commit is contained in:
@@ -449,7 +449,8 @@ async function sendFragment(context, producer, picker, merchantToken, index) {
|
|||||||
export async function withDeliveryEventRecovery(context, faultScope, warehouseId, index, sign) {
|
export async function withDeliveryEventRecovery(context, faultScope, warehouseId, index, sign) {
|
||||||
const executor = context.context.f40DeliveryEventFaultExecutor
|
const executor = context.context.f40DeliveryEventFaultExecutor
|
||||||
if (!executor || index !== 0) return sign()
|
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')
|
if (proof.deliveryEventRecovery) throw Error('F40 delivery recovery already attempted')
|
||||||
const reader = context.context.f40ReadOnlyInventoryEvidence
|
const reader = context.context.f40ReadOnlyInventoryEvidence
|
||||||
if (typeof reader !== 'function') throw Error('F40 complete inventory evidence reader required')
|
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)
|
const scope = Object.create(context)
|
||||||
scope.marker = `${context.marker}-F40`
|
scope.marker = `${context.marker}-F40`
|
||||||
scope.context = { ...context.context, orderDestinationType: 'FBA', orderFulfillmentType: 'STANDARD',
|
scope.context = { ...context.context, orderDestinationType: 'FBA', orderFulfillmentType: 'STANDARD',
|
||||||
|
f40RootFulfillmentProof: proof,
|
||||||
orderStopAtApproved:cancelRemainder,
|
orderStopAtApproved:cancelRemainder,
|
||||||
orderProfile: { taxMode, fulfillmentType: 'STANDARD' },f40TaxMode:taxMode,f40TaxEvidence:proof.taxCustoms,
|
orderProfile: { taxMode, fulfillmentType: 'STANDARD' },f40TaxMode:taxMode,f40TaxEvidence:proof.taxCustoms,
|
||||||
waitSplitVariant: { skuCount: 1, packageCountPerSku: 2, packageCounts: [2] },
|
waitSplitVariant: { skuCount: 1, packageCountPerSku: 2, packageCounts: [2] },
|
||||||
|
|||||||
@@ -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()=>{
|
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 calls=[],restoration={restored:true,healthy:true,proxyStopped:true}
|
||||||
const inventory={scope:{...deliveryScope,warehouseId:'9',coverage:'CUSTOMER_WAREHOUSE_COMPLETE'},balances:[],positions:[],ledger:[]}
|
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}},
|
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.equal(await withDeliveryEventRecovery(context,deliveryScope,'9',0,async()=>{calls.push('sign');return 'signed'}),'signed')
|
||||||
assert.deepEqual(calls,['inventory','prepare','sign','proof','inventory','cleanup'])
|
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'))
|
await withDeliveryEventRecovery(context,deliveryScope,'9',1,async()=>calls.push('second'))
|
||||||
assert.equal(calls.at(-1),'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/)
|
await assert.rejects(withDeliveryEventRecovery(context,deliveryScope,'9',0,async()=>{throw Error('sign failed')}),/sign failed/)
|
||||||
assert.equal(calls.at(-1),'cleanup')
|
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',()=>{
|
test('Python DELIVERY SQL uses actual payload, original Lastleg retry, and Order database without inventory queries',()=>{
|
||||||
const result=spawnSync('python',['-c',String.raw`
|
const result=spawnSync('python',['-c',String.raw`
|
||||||
|
|||||||
Reference in New Issue
Block a user