Skip to content

Commit

Permalink
Add Across config validation on CI pipeline (#61)
Browse files Browse the repository at this point in the history
### What was the problem?

This PR resolves LISK-899.

### How was it solved?

PR pipeline was updated to validate 

### How was it tested?

Tested locally with `yarn validate-config` with valid and invalid
configs.
  • Loading branch information
sameersubudhi authored Sep 12, 2024
2 parents 26a4f61 + c23272c commit 20212f9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
34 changes: 34 additions & 0 deletions scripts/validateConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { RelayerConfig } from "../src/relayer/RelayerConfig";

// Example run:
// ts-node ./scripts/validateConfig.ts

export async function run(): Promise<void> {
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);
});
}

0 comments on commit 20212f9

Please sign in to comment.