diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 9dde3245c..f937c90f0 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -30,4 +30,8 @@ jobs: echo "Running format is required" exit 1 fi - - run: yarn test + - name: Validate configuration + run: yarn validate-config + - name: Test + shell: bash + run: yarn test diff --git a/package.json b/package.json index 853257556..d9d3febf8 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "lint-fix": "yarn eslint --fix && yarn prettier --write", "format": "prettier --write '**/*'", "eslint": "eslint .", + "validate-config": "yarn ts-node ./scripts/validateConfig.ts", "test": "RELAYER_TEST=true hardhat test", "build": "tsc --build", "watch": "tsc --build --incremental --watch", diff --git a/scripts/validateConfig.ts b/scripts/validateConfig.ts new file mode 100644 index 000000000..82b1d9743 --- /dev/null +++ b/scripts/validateConfig.ts @@ -0,0 +1,34 @@ +import { RelayerConfig } from "../src/relayer/RelayerConfig"; + +// Example run: +// ts-node ./scripts/validateConfig.ts + +export async function run(): Promise { + console.log("Validating config"); + + const env: NodeJS.ProcessEnv = { + RELAYER_TOKENS: + '["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", "0x6033F7f88332B8db6ad452B7C6D5bB643990aE3f", "0xdAC17F958D2ee523a2206206994597C13D831ec7"]', + MIN_DEPOSIT_CONFIRMATIONS: + '{"5000": { "1": 5, "1135": 10 }, "2000": { "1": 4, "1135": 10 }, "100": { "1": 3, "1135": 10 } }', + RELAYER_ORIGIN_CHAINS: JSON.stringify([1, 1135]), + RELAYER_DESTINATION_CHAINS: JSON.stringify([1, 1135]), + RELAYER_EXTERNAL_INVENTORY_CONFIG: "config/mainnet/relayerExternalInventory.json", + }; + new RelayerConfig(env); + + console.log("Config is valid"); +} + +if (require.main === module) { + run() + .then(async () => { + // eslint-disable-next-line no-process-exit + process.exit(0); + }) + .catch(async (error) => { + console.error("Process exited with", error); + // eslint-disable-next-line no-process-exit + process.exit(1); + }); +}