| 23 | const messagesSent = []; |
| 24 | |
| 25 | async function post(session, method, params) { |
| 26 | return new Promise((resolve, reject) => { |
| 27 | session.post(method, params, (error, success) => { |
| 28 | messagesSent.push(method); |
| 29 | if (error) { |
| 30 | process._rawDebug(`Message ${method} produced an error`); |
| 31 | reject(error); |
| 32 | } else { |
| 33 | process._rawDebug(`Message ${method} was sent`); |
| 34 | resolve(success); |
| 35 | } |
| 36 | }); |
| 37 | }); |
| 38 | } |
| 39 | |
| 40 | async function waitForNotification(session, notification) { |
| 41 | return new Promise((resolve) => session.once(notification, resolve)); |