test(fba): verify signed delivery ACK loss and original event recovery
This commit is contained in:
@@ -33,6 +33,16 @@ test('tax mode is explicit, defaults to BUY and rejects aliases, duplicate and u
|
||||
for(const args of [['--tax-mode','REFUND'],['--tax-mode','tax_refund'],['--tax-mode',''],['--taxMode','TAX_REFUND'],
|
||||
['--tax-mode','TAX_REFUND','--tax-mode','BUY_DECLARATION']])assert.throws(()=>parseCoreArguments(args))
|
||||
})
|
||||
|
||||
test('explicit single signature mode runs only that mode and reports the narrowed scope', async()=>{
|
||||
const cfg=parseCoreArguments(['--execute','--environment','TEST','--run-id','single-mode','--signature-mode','ROOT_FIRST'])
|
||||
assert.deepEqual(executionPlan(cfg).modes,['ROOT_FIRST'])
|
||||
assert.doesNotMatch(executionPlan(cfg).reports.join(','),/child_first/)
|
||||
const seen=[]
|
||||
const summary=await runFbaCore(cfg,{env:env(),readers:readers(),outputRoot:root(),createContext:mode=>({context:{},async run(){seen.push(mode);return pass()}})})
|
||||
assert.equal(summary.success,true);assert.deepEqual(seen,['ROOT_FIRST']);assert.equal(summary.modes.length,1)
|
||||
for(const args of [['--signature-mode','ALL'],['--signature-mode','root_first'],['--signature-mode','ROOT_FIRST','--signature-mode','CHILD_FIRST']])assert.throws(()=>parseCoreArguments(args))
|
||||
})
|
||||
test('both tax modes pass unchanged to all three existing contexts and persist on all report surfaces',async()=>{
|
||||
for(const taxMode of ['BUY_DECLARATION','TAX_REFUND']){
|
||||
const outputRoot=root(),cfg={...config(),taxMode},seen=[]
|
||||
@@ -119,3 +129,32 @@ test('reports redact dynamically created account secrets and environment/token v
|
||||
assert.equal(value.password,'[REDACTED]');assert.equal(value.pdaToken,'[REDACTED]')
|
||||
assert.equal(value.message,'failure [REDACTED]');assert.equal(value.nested.value,'safe')
|
||||
})
|
||||
|
||||
test('delivery fault requires one explicit mode and verified proof plus restoration, even after caught run failures', async()=>{
|
||||
assert.throws(()=>parseCoreArguments(['--plan','--verify-delivery-event-recovery']))
|
||||
const cfg=parseCoreArguments(['--execute','--environment','TEST','--run-id','fault-one','--signature-mode','ROOT_FIRST','--verify-delivery-event-recovery'])
|
||||
assert.equal(executionPlan(cfg).verifyDeliveryEventRecovery,true)
|
||||
for(const failure of ['none','context','proof','restore']) {
|
||||
const outputRoot=root();let cleanups=0,prepares=0
|
||||
const r={...readers(),readFleetInventory:async scope=>({scope,balances:[],positions:[],ledger:[]})}
|
||||
const summary=await runFbaCore(cfg,{env:{...env(),CHONGCHONG_ENV:'test'},readers:r,outputRoot,
|
||||
faultFactory:()=>({prepare:async()=>{prepares++},cleanup:async()=>{
|
||||
cleanups++;if(failure==='restore')throw Error('private failure')
|
||||
return {restored:true,healthy:true,proxyStopped:true}
|
||||
}}),createContext:()=>({context:{},createdResources:{},async run(){
|
||||
await this.context.f40DeliveryEventFaultExecutor.prepare({marker:'F40',customerId:'90',deliveryId:'91'})
|
||||
await this.context.f40ReadOnlyInventoryEvidence({marker:'F40',customerId:'90',warehouseId:'92'})
|
||||
if(failure==='context')throw Error('private failure')
|
||||
const report=pass()
|
||||
if(failure!=='proof')report.createdResources.phase5RootFulfillment.deliveryEventRecovery={status:'VERIFIED'}
|
||||
return report
|
||||
}})})
|
||||
assert.equal(summary.success,failure==='none')
|
||||
assert.equal(cleanups,1);assert.equal(prepares,1)
|
||||
const evidencePath=join(outputRoot,cfg.outputDir,'evidence')
|
||||
assert.ok(existsSync(join(evidencePath,'root_first-delivery-scope.json')))
|
||||
assert.ok(existsSync(join(evidencePath,'root_first-0001-inventory.json')))
|
||||
const report=JSON.parse(readFileSync(join(outputRoot,cfg.outputDir,'root_first.json'),'utf8'))
|
||||
if(failure==='restore')assert.equal(report.deliveryRestorationFailed,true)
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user