mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
fixes
This commit is contained in:
parent
c7f9181296
commit
0cf7d01e81
|
@ -13,7 +13,7 @@ import { HardhatUserConfig } from "hardhat/config";
|
|||
import { NetworkUserConfig } from "hardhat/types";
|
||||
import { utils } from "ethers";
|
||||
import Web3 from "web3";
|
||||
import "./scripts/tests/run-tests"
|
||||
import "./scripts/tests/tests-run"
|
||||
|
||||
|
||||
dotenvConfig({ path: resolve(__dirname, "./.env") });
|
||||
|
|
|
@ -9,10 +9,11 @@
|
|||
"check": "ts-node status-checks/huskyCheck.ts",
|
||||
"check-husky": "ts-node status-checks/huskyCheck.ts",
|
||||
"deploy": "ts-node scripts/deployConnectorsFromCmd.ts",
|
||||
"test:runner": "hardhat run_tests_on",
|
||||
"test:runner": "hardhat run scripts/tests/run-tests.ts",
|
||||
"typechain": "hardhat typechain",
|
||||
"compile": "hardhat compile",
|
||||
"deploy:runner": "hardhat run scripts/deployment/deployConnectorsFromCmd.ts"
|
||||
"deploy:runner": "hardhat run scripts/deployment/deployConnectorsFromCmd.ts",
|
||||
"runner:tests": "hardhat run_tests_on"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
@ -4,29 +4,17 @@ import { promises as fs } from "fs";
|
|||
import { join } from "path";
|
||||
import { execScript } from "./command";
|
||||
|
||||
import { task } from "hardhat/config";
|
||||
|
||||
|
||||
let start: number, end: number;
|
||||
|
||||
task("run_tests_on", "runs specified test on a specified chain")
|
||||
.addPositionalParam("chain")
|
||||
.addPositionalParam("test")
|
||||
.setAction(async (taskArgs) => {
|
||||
const chain = taskArgs.chain;
|
||||
const test = taskArgs.test;
|
||||
await testRunner(chain,test)
|
||||
.then(() =>
|
||||
console.log(
|
||||
`🙌 finished the test runner, time taken ${(end - start) / 1000} sec`
|
||||
)
|
||||
)
|
||||
.catch((err) => console.error("❌ failed due to error: ", err));
|
||||
|
||||
});
|
||||
|
||||
async function testRunner(chain: string, testName: string) {
|
||||
|
||||
async function testRunner() {
|
||||
const { chain } = await inquirer.prompt([
|
||||
{
|
||||
name: "chain",
|
||||
message: "What chain do you want to run tests on?",
|
||||
type: "list",
|
||||
choices: ["mainnet", "polygon", "avalanche", "arbitrum"],
|
||||
},
|
||||
]);
|
||||
const testsPath = join(__dirname, "../../test", chain);
|
||||
await fs.access(testsPath);
|
||||
const availableTests = await fs.readdir(testsPath);
|
||||
|
@ -34,6 +22,14 @@ async function testRunner(chain: string, testName: string) {
|
|||
throw new Error(`No tests available for ${chain}`);
|
||||
}
|
||||
|
||||
const { testName } = await inquirer.prompt([
|
||||
{
|
||||
name: "testName",
|
||||
message: "For which connector you want to run the tests?",
|
||||
type: "list",
|
||||
choices: ["all", ...availableTests],
|
||||
},
|
||||
]);
|
||||
start = Date.now();
|
||||
let path: string;
|
||||
if (testName === "all") {
|
||||
|
@ -63,3 +59,10 @@ async function testRunner(chain: string, testName: string) {
|
|||
end = Date.now();
|
||||
}
|
||||
|
||||
testRunner()
|
||||
.then(() =>
|
||||
console.log(
|
||||
`🙌 finished the test runner, time taken ${(end - start) / 1000} sec`
|
||||
)
|
||||
)
|
||||
.catch((err) => console.error("❌ failed due to error: ", err));
|
65
scripts/tests/tests-run.ts
Normal file
65
scripts/tests/tests-run.ts
Normal file
|
@ -0,0 +1,65 @@
|
|||
import inquirer from "inquirer";
|
||||
import { promises as fs } from "fs";
|
||||
|
||||
import { join } from "path";
|
||||
import { execScript } from "./command";
|
||||
|
||||
import { task } from "hardhat/config";
|
||||
|
||||
|
||||
let start: number, end: number;
|
||||
|
||||
task("run_tests_on", "runs specified test on a specified chain")
|
||||
.addPositionalParam("chain")
|
||||
.addPositionalParam("test")
|
||||
.setAction(async (taskArgs) => {
|
||||
const chain = taskArgs.chain;
|
||||
const test = taskArgs.test;
|
||||
await testRunner(chain,test)
|
||||
.then(() =>
|
||||
console.log(
|
||||
`🙌 finished the test runner, time taken ${(end - start) / 1000} sec`
|
||||
)
|
||||
)
|
||||
.catch((err) => console.error("❌ failed due to error: ", err));
|
||||
|
||||
});
|
||||
|
||||
async function testRunner(chain: string, testName: string) {
|
||||
|
||||
const testsPath = join(__dirname, "../../test", chain);
|
||||
await fs.access(testsPath);
|
||||
const availableTests = await fs.readdir(testsPath);
|
||||
if (availableTests.length === 0) {
|
||||
throw new Error(`No tests available for ${chain}`);
|
||||
}
|
||||
|
||||
start = Date.now();
|
||||
let path: string;
|
||||
if (testName === "all") {
|
||||
for (let test of availableTests) {
|
||||
path = join(testsPath, test);
|
||||
path += "/*";
|
||||
await execScript({
|
||||
cmd: "npx",
|
||||
args: ["hardhat", "test", path],
|
||||
env: {
|
||||
networkType: chain,
|
||||
},
|
||||
}).catch((err)=>console.log(`failed ${test}`))
|
||||
}
|
||||
} else {
|
||||
path = join(testsPath, testName);
|
||||
path += "/*";
|
||||
|
||||
await execScript({
|
||||
cmd: "npx",
|
||||
args: ["hardhat", "test", path],
|
||||
env: {
|
||||
networkType: chain,
|
||||
},
|
||||
});
|
||||
}
|
||||
end = Date.now();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user