(msg)
| 103 | |
| 104 | |
| 105 | function parseMessage(msg) { |
| 106 | try { |
| 107 | let payload = Buffer.from(msg, "hex"); |
| 108 | let metaPos = payload.indexOf("\n"); |
| 109 | let meta = payload.slice(0, metaPos); |
| 110 | let metaArr = meta.toString("ascii").split(" "); |
| 111 | let pType = metaArr[0]; |
| 112 | let pID = metaArr[1]; |
| 113 | let raw = payload.slice(metaPos + 1, payload.length); |
| 114 | |
| 115 | return { |
| 116 | type: pType, |
| 117 | ID: pID, |
| 118 | rawMeta: meta, |
| 119 | meta: metaArr, |
| 120 | http: raw |
| 121 | } |
| 122 | } catch(e) { |
| 123 | fail(`Error while parsing incoming request: ${msg}`) |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | // Used to compare values from original and replayed responses |
| 128 | // Accepts request id, regexp pattern for searching the compared value (should include capture group), and callback which returns both original and replayed matched value. |
no test coverage detected