Skip to content

Commit

Permalink
Merge pull request #158 from open-rpc/feat/rpc-discover
Browse files Browse the repository at this point in the history
feat(MethodCallValidator): allow rpc discover
  • Loading branch information
BelfordZ authored Jun 25, 2019
2 parents e5c1b29 + 555b397 commit 287b60f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/method-call-validator/method-call-validator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,17 @@ describe("MethodCallValidator", () => {
expect(result).toEqual([]);
});

it("rpc.discover is allowed", () => {
const example = getExampleSchema() as any;
const methodCallValidator = new MethodCallValidator(example);
const result = methodCallValidator.validate("rpc.discover", []);
expect(result).toEqual([]);
});

it("returns method not found error when the method name is invalid", () => {
const example = getExampleSchema() as any;
const methodCallValidator = new MethodCallValidator(example);
const result = methodCallValidator.validate("boo", ["123"]);
expect(result).toBeInstanceOf(MethodCallMethodNotFoundError);
});

});
1 change: 1 addition & 0 deletions src/method-call-validator/method-call-validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export default class MethodCallValidator {
methodName: string,
params: any[],
): MethodCallParameterValidationError[] | MethodCallMethodNotFoundError {
if (methodName === "rpc.discover") { return []; }
const method = _.find(this.document.methods, { name: methodName }) as MethodObject;

if (!method) {
Expand Down

0 comments on commit 287b60f

Please sign in to comment.