Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle unsupported error in router executer #5229

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ajv, createLoggingContext, ExecuteArgs, ExecuteArgsSchema } from "@connext/nxtp-utils";

import { DomainNotSupported } from "../../../errors";
import { getContext } from "../executor";

import { sendExecuteSlowToSequencer } from "./sequencer";
Expand All @@ -22,16 +21,21 @@ export const execute = async (args: ExecuteArgs, transferId: string): Promise<vo

// Ensure we support the target domain (i.e. it's been configured).
if (!config.chains[args.params.destinationDomain]) {
throw new DomainNotSupported(args.params.destinationDomain, transferId, {
logger.debug("Unsupported destination domain", requestContext, methodContext, {
domain: args.params.destinationDomain,
transferId,
supportedDomains: Object.keys(config.chains),
});

return;
}

// Validate input schema
const validate = ajv.compile(ExecuteArgsSchema);
const valid = validate(args);
if (!valid) {
throw new Error(validate.errors?.map((err: unknown) => JSON.stringify(err, null, 2)).join(","));
logger.debug(validate.errors!.map((err: unknown) => JSON.stringify(err, null, 2)).join(","));
return;
}

const encodedData = contracts.connext.encodeFunctionData("execute", [args]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ describe("Operations:Execute", () => {
it("should not send to the relayer if not valid ", async () => {
const executeArgs = { ...mock.entity.executeArgs(), routers: ["0x"] };
const transferId = mkBytes32();
await expect(execute(executeArgs, transferId)).to.be.rejectedWith(Error);
await execute(executeArgs, transferId);
expect(sendExecuteFastToRelayerStub.callCount).to.be.eq(0);
});
it("should throw DomainNotSupported if not configured", async () => {
const executeArgs = { ...mock.entity.executeArgs(), params: { originDomain: "111", destinationDomain: "222" } };
const transferId = mkBytes32();
await expect(execute(executeArgs, transferId)).to.be.rejectedWith(DomainNotSupported);
await execute(executeArgs, transferId);
expect(sendExecuteFastToRelayerStub.callCount).to.be.eq(0);
});
it("should send the payload to the relayer successfully!", async () => {
Expand Down