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
whonion
committed
Dec 23, 2023
1 parent
0848d91
commit 116925c
Showing
3 changed files
with
39 additions
and
2 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 |
---|---|---|
|
@@ -59,4 +59,4 @@ jobs: | |
run: npm i | ||
|
||
- name: Test Running | ||
run: npm run start | ||
run: npm run test |
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
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,36 @@ | ||
import { spawn } from 'child_process'; | ||
|
||
const MAX_TEST_DURATION_MS = 120000; // Test duration in milliseconds (e.g., 120 seconds) | ||
const SCRIPT_FILE = 'main.ts'; // Change this to match your main.ts filename | ||
|
||
// Function to run the main.ts script for a specific duration | ||
function runMainScriptForDuration() { | ||
return new Promise<void>((resolve, reject) => { | ||
const process = spawn('ts-node', [SCRIPT_FILE], { | ||
stdio: 'inherit', // Inherit stdio from the parent process | ||
}); | ||
|
||
setTimeout(() => { | ||
process.kill(); // Terminate the script after the specified duration | ||
resolve(); | ||
}, MAX_TEST_DURATION_MS); | ||
|
||
process.on('close', (code) => { | ||
if (code === 0) { | ||
resolve(); | ||
} else { | ||
reject(`main.ts exited with code ${code}`); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
// Run the test | ||
runMainScriptForDuration() | ||
.then(() => { | ||
console.log('Test completed successfully.'); | ||
}) | ||
.catch((error) => { | ||
console.error('Test failed:', error); | ||
process.exit(1); | ||
}); |