ml-testing-toolkit 18.16.5 → 18.17.0-snapshot.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,10 +48,7 @@ const getConnection = async () => {
48
48
  }
49
49
 
50
50
  // TLS/SSL support
51
- const mongoOptions = {
52
- useNewUrlParser: true,
53
- useUnifiedTopology: true
54
- }
51
+ const mongoOptions = {}
55
52
 
56
53
  if (systemConfig.DB.SSL_ENABLED) {
57
54
  mongoOptions.tls = true
@@ -140,8 +140,24 @@ const handleTransferIlp = (context, response) => {
140
140
  response.body.TxInfAndSts.ExctnConf = generatedFulfilment
141
141
  }
142
142
  }
143
+
143
144
  if (context.request.method === 'get' && response.method === 'put' && pathMatch.test(response.path)) {
144
- delete response.body.fulfilment
145
+ const transferId = response.path.match(pathMatch)[1]
146
+ const storedTransfer = context.storedTransfers?.[transferId]
147
+
148
+ // Check if stored request exists and is within 30 seconds
149
+ if (storedTransfer) {
150
+ if (storedTransfer.request.ilpPacket) {
151
+ const generatedFulfilment = ilpObj.calculateFulfil(storedTransfer.request.ilpPacket).replace('"', '')
152
+ response.body.fulfilment = generatedFulfilment
153
+ } else if (storedTransfer.request.CdtTrfTxInf?.VrfctnOfTerms?.IlpV4PrepPacket) {
154
+ const generatedFulfilment = ilpV4Obj.calculateFulfil(storedTransfer.request.CdtTrfTxInf.VrfctnOfTerms.IlpV4PrepPacket).replace('"', '')
155
+ response.body.TxInfAndSts.ExctnConf = generatedFulfilment
156
+ }
157
+ delete context.storedTransfers[transferId]
158
+ } else {
159
+ delete response.body.fulfilment
160
+ }
145
161
  }
146
162
  }
147
163
 
@@ -318,6 +318,23 @@ const generateAsyncCallback = async (item, context, req) => {
318
318
  return
319
319
  }
320
320
  } else {
321
+ // Store transfers early - right after validation
322
+ const transferPathMatch = /\/transfers\/([^/]+)$/
323
+ const fxTransferPathMatch = /\/fxTransfers\/([^/]+)$/
324
+ if (req.method === 'post' && (transferPathMatch.test(req.path) || fxTransferPathMatch.test(req.path))) {
325
+ if (!context.storedTransfers) {
326
+ context.storedTransfers = {}
327
+ }
328
+ const isFxTransfer = fxTransferPathMatch.test(req.path)
329
+ const transferId = req.path.match(isFxTransfer ? fxTransferPathMatch : transferPathMatch)[1]
330
+ customLogger.logMessage('debug', 'Storing transfer for validation', { additionalData: { transferId }, request: req })
331
+
332
+ context.storedTransfers[transferId] = {
333
+ request: req.payload,
334
+ type: isFxTransfer ? 'fxTransfer' : 'transfer'
335
+ }
336
+ }
337
+
321
338
  // Getting callback info from callback map file
322
339
  try {
323
340
  const cbMapRawdata = await utils.readFileAsync(item.callbackMapFile)