fix(order): enforce versioned platform commands and submissions
This commit is contained in:
@@ -38,6 +38,20 @@ test('frozen edit command preserves original version, key and nested payload thr
|
||||
assert.throws(() => r.orderMutationCommand(snapshot, payload, ''), /key/)
|
||||
})
|
||||
|
||||
test('submit command carries only frozen expectedVersion with the same original replay key',()=>{
|
||||
const r=runtime(),detail={order:{version:4}}
|
||||
const command=r.orderMutationCommand(detail,{},'submit-original')
|
||||
detail.order.version=9
|
||||
assert.deepEqual(plain(command),{headers:{'Idempotency-Key':'submit-original'},body:{expectedVersion:4}})
|
||||
assert.match(source,/const submitCommand = orderMutationCommand\(submitBefore, \{\}, submitKey\)/)
|
||||
assert.match(source,/submit replay keeps version and history unchanged/)
|
||||
assert.match(source,/submit same key different version conflicts/)
|
||||
assert.match(source,/submit new key cannot submit already submitted order/)
|
||||
for(const name of ['pre-approval-submit','incomplete-submit','cancelled-submit','cancelled-submit-proof']) {
|
||||
assert.match(source,new RegExp(`orderMutationCommand\\([^\\n]+(?:\\n[^\\n]+)?newIdempotencyKey\\('${name}'\\)`))
|
||||
}
|
||||
})
|
||||
|
||||
test('zero-drift validator detects changes in every aggregate and preserves array ordering', () => {
|
||||
const r = runtime(), before = { order: { version: 2 }, cargoes: [{ id: '1', amount: 2 }], parties: [], internalNotes: [], statusHistory: [{ id: 'h1' }, { id: 'h2' }] }
|
||||
r.assertOrderUnchanged(before, structuredClone(before))
|
||||
|
||||
Reference in New Issue
Block a user