Skip to content

Commit

Permalink
fix: temporarily remove id validation (#555)
Browse files Browse the repository at this point in the history
  • Loading branch information
Melisa Anabella Rossi authored Dec 29, 2023
1 parent 7d6cff2 commit b2fa644
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/utils/jsonrpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function isValidResponse(response: RPCResponse | RPCResponse[]) {
!!message &&
(message.error === undefined || message.error === null) &&
message.jsonrpc === '2.0' &&
typeof message.id === 'number' &&
message.id !== null &&
'result' in message &&
message.result !== undefined
) // only undefined is not valid json object
Expand Down
7 changes: 4 additions & 3 deletions test/jsonrpc.isValidResponse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ describe('jsonrpc', function () {
expect(valid).toEqual(false)
})

it('should validate jsonrpc response without id number', function () {
it('should validate jsonrpc response without id', function () {
// given
let response: any = {
jsonrpc: '2.0',
id: null,
result: []
}

Expand All @@ -72,7 +73,7 @@ describe('jsonrpc', function () {
expect(valid).toEqual(false)
})

it('should validate jsonrpc response with wrong id field', function () {
it('should validate jsonrpc response with id', function () {
// given
let response: any = {
jsonrpc: '2.0',
Expand All @@ -84,7 +85,7 @@ describe('jsonrpc', function () {
let valid = Jsonrpc.isValidResponse(response)

// then
expect(valid).toEqual(false)
expect(valid).toEqual(true)
})

it('should validate jsonrpc response without result field', function () {
Expand Down

0 comments on commit b2fa644

Please sign in to comment.