usdc options public ws test

This commit is contained in:
tiagosiebler
2022-09-16 13:13:49 +01:00
parent 28485c0068
commit d2ba5d3e01
9 changed files with 319 additions and 115 deletions

View File

@@ -73,6 +73,36 @@ export function waitForSocketEvent(
});
}
export function listenToSocketEvents(wsClient: WebsocketClient) {
const retVal: Record<
'update' | 'open' | 'response' | 'close' | 'error',
typeof jest.fn
> = {
open: jest.fn(),
response: jest.fn(),
update: jest.fn(),
close: jest.fn(),
error: jest.fn(),
};
wsClient.on('open', retVal.open);
wsClient.on('response', retVal.response);
wsClient.on('update', retVal.update);
wsClient.on('close', retVal.close);
wsClient.on('error', retVal.error);
return {
...retVal,
cleanup: () => {
wsClient.removeListener('open', retVal.open);
wsClient.removeListener('response', retVal.response);
wsClient.removeListener('update', retVal.update);
wsClient.removeListener('close', retVal.close);
wsClient.removeListener('error', retVal.error);
},
};
}
export function logAllEvents(wsClient: WebsocketClient) {
wsClient.on('update', (data) => {
console.log('wsUpdate: ', JSON.stringify(data, null, 2));