Re-format jsonrpc errors (#2014)

This commit is contained in:
Jaco Greeff
2020-03-09 08:27:00 +01:00
committed by GitHub
parent eb17de0888
commit ca9f671553
2 changed files with 21 additions and 7 deletions
@@ -42,6 +42,12 @@ describe('decodeResponse', (): void => {
).toThrow(/123: test error/);
});
it('throws any error found, with data', (): void => {
expect(
(): any => coder.decodeResponse({ id: 1, jsonrpc: '2.0', error: { code: 123, data: 'Error("Some random error description")', message: 'test error' } } as JsonRpcResponse)
).toThrow(/123: test error: Some random error description/);
});
it('returns the result', (): void => {
expect(
coder.decodeResponse({ id: 1, jsonrpc: '2.0', result: 'some result' } as JsonRpcResponse)