forked from emerteroglu/evm-contract-sniffer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
55 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,31 @@ | ||
name: Test | ||
|
||
on: [push] # You can customize the trigger event based on your needs | ||
on: [push] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
matrix: | ||
node-version: ['18.x', '19.x', '20.x'] | ||
|
||
env: # Set environment variables from repository secrets | ||
ETHERSCANKEY: ${{ secrets.ETHERSCANKEY }} | ||
RPCURL: ${{ secrets.RPCURL }} | ||
EXP_URL: 'https://etherscan.io' | ||
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20 # You can specify your desired Node.js version | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Install Dependencies | ||
run: npm install | ||
- name: Run JavaScript Script | ||
run: node main.js | ||
run: npm i | ||
|
||
- name: Test Run | ||
run: node test.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const childProcess = require("child_process"); | ||
|
||
const MAX_TEST_DURATION_MS = 120000; // Test duration in milliseconds (e.g., 60 seconds) | ||
const SCRIPT_FILE = "main.js"; // Change this to match your main.js filename | ||
|
||
// Function to run the main.js script for a specific duration | ||
function runMainScriptForDuration() { | ||
return new Promise((resolve, reject) => { | ||
const process = childProcess.spawn("node", [SCRIPT_FILE]); | ||
|
||
setTimeout(() => { | ||
process.kill(); // Terminate the script after the specified duration | ||
resolve(); | ||
}, MAX_TEST_DURATION_MS); | ||
|
||
process.stdout.on("data", data => { | ||
console.log(data.toString()); | ||
}); | ||
|
||
process.stderr.on("data", data => { | ||
console.error(data.toString()); | ||
reject("Error occurred while running main.js"); | ||
}); | ||
|
||
process.on("close", code => { | ||
if (code === 0) { | ||
resolve(); | ||
} else { | ||
reject(`main.js exited with code ${code}`); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
// Run the test | ||
runMainScriptForDuration() | ||
.then(() => { | ||
console.log("Test completed successfully."); | ||
}) | ||
.catch(error => { | ||
console.error("Test failed:", error); | ||
process.exit(1); | ||
}); |