ml-testing-toolkit 18.17.0-snapshot.11 → 18.17.0-snapshot.12
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.
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ml-testing-toolkit",
|
|
3
3
|
"description": "Testing Toolkit for Mojaloop implementations",
|
|
4
|
-
"version": "18.17.0-snapshot.
|
|
4
|
+
"version": "18.17.0-snapshot.12",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Vijaya Kumar Guthi, ModusBox Inc. ",
|
|
7
7
|
"contributors": [
|
|
@@ -166,11 +166,7 @@ const handleTransferIlp = (context, response) => {
|
|
|
166
166
|
customLogger.logMessage('warn', 'No ILP packet or IlpV4PrepPacket found in stored transfer request', { additionalData: { transferId, storedTransfer } })
|
|
167
167
|
}
|
|
168
168
|
// Remove the stored transfer from objectStore
|
|
169
|
-
objectStore.
|
|
170
|
-
objectStore.set('storedTransfers', {
|
|
171
|
-
...objectStore.get('storedTransfers', undefined),
|
|
172
|
-
[transferId]: undefined
|
|
173
|
-
})
|
|
169
|
+
objectStore.deleteObject('storedTransfers', transferId)
|
|
174
170
|
} else {
|
|
175
171
|
delete response.body.fulfilment
|
|
176
172
|
}
|
package/src/lib/objectStore.js
CHANGED
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
******/
|
|
30
30
|
|
|
31
31
|
const _ = require('lodash')
|
|
32
|
+
const { logger } = require('./logger')
|
|
32
33
|
|
|
33
34
|
const storedObject = {
|
|
34
35
|
data: {
|
|
@@ -77,13 +78,17 @@ const push = (key, item, value, user) => {
|
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
const clear = (object, interval) => {
|
|
80
|
-
|
|
81
|
-
for (const
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
try {
|
|
82
|
+
for (const context in storedObject) {
|
|
83
|
+
for (const item in storedObject[context][object]) {
|
|
84
|
+
const timeDiff = Date.now() - storedObject[context][object][item].insertedDate
|
|
85
|
+
if (timeDiff > interval) {
|
|
86
|
+
delete storedObject[context][object][item]
|
|
87
|
+
}
|
|
85
88
|
}
|
|
86
89
|
}
|
|
90
|
+
} catch (err) {
|
|
91
|
+
logger.error('Error clearing old objects', err)
|
|
87
92
|
}
|
|
88
93
|
}
|
|
89
94
|
|
|
@@ -97,6 +102,15 @@ const popObject = (key, item, user) => {
|
|
|
97
102
|
return null
|
|
98
103
|
}
|
|
99
104
|
|
|
105
|
+
const deleteObject = (key, item, user) => {
|
|
106
|
+
const context = init(key, user)
|
|
107
|
+
if (Object.prototype.hasOwnProperty.call(storedObject[context][key], item)) {
|
|
108
|
+
delete storedObject[context][key][item]
|
|
109
|
+
return true
|
|
110
|
+
}
|
|
111
|
+
return false
|
|
112
|
+
}
|
|
113
|
+
|
|
100
114
|
const clearOldObjects = () => {
|
|
101
115
|
const interval = 10 * 60 * 1000
|
|
102
116
|
clear('transactions', interval)
|
|
@@ -120,5 +134,6 @@ module.exports = {
|
|
|
120
134
|
initObjectStore,
|
|
121
135
|
push,
|
|
122
136
|
clear,
|
|
123
|
-
popObject
|
|
137
|
+
popObject,
|
|
138
|
+
deleteObject
|
|
124
139
|
}
|