Skip to content

Commit 0852303

Browse files
committed
test(core): incorporate JSON-RPC review feedback
1 parent b229470 commit 0852303

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

packages/core/src/rpc.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ describe('-32602 Invalid Params validation', () => {
8787
}
8888
});
8989

90-
it('accepts named object params using their value order', () => {
90+
it('accepts named object params', () => {
9191
const result = parseRpcRequest(JSON.stringify({
9292
jsonrpc: '2.0',
9393
method: 'api.echo',
@@ -114,7 +114,7 @@ describe('-32602 Invalid Params validation', () => {
114114
}
115115
});
116116

117-
for (const params of ['abc', 42, true, null]) {
117+
for (const params of ['abc', 42, true, false, null]) {
118118
it(`rejects ${JSON.stringify(params)} params`, () => {
119119
const result = parseRpcRequest(JSON.stringify({
120120
jsonrpc: '2.0',
@@ -128,6 +128,7 @@ describe('-32602 Invalid Params validation', () => {
128128
const response = JSON.parse(result.response);
129129
assert.strictEqual(response.error.code, RpcErrorCode.InvalidParams);
130130
assert.strictEqual(response.error.data.name, 'InvalidParams');
131+
assert.ok(response.error.message.includes('expected an array or object'));
131132
assert.strictEqual(response.id, 'request-1');
132133
}
133134
});

packages/core/src/rpc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export function parseRpcRequest(bodyText: string): RpcParseResult {
141141
request: {
142142
apiNamespace: parsed.method.substring(0, dotIndex),
143143
method: parsed.method.substring(dotIndex + 1),
144-
// JSON-RPC 2.0 §4.2: params may be an array (positional) or object (named).
144+
// JSON-RPC 2.0 §4.2: params may be array (positional), object (named), or omitted (empty).
145145
args,
146146
id,
147147
},

0 commit comments

Comments
 (0)