Skip to content

Commit 4a89d54

Browse files
authored
add a check that smoke tested deploy script doesn't auto deploy on node startup (#557)
1 parent da5b410 commit 4a89d54

3 files changed

Lines changed: 37 additions & 5 deletions

File tree

contracts/hardhat.config.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const { debug } = require("./tasks/debug");
1212
const { env } = require("./tasks/env");
1313
const { execute, executeOnFork, proposal } = require("./tasks/governance");
1414
const { balance } = require("./tasks/ousd");
15-
const { smokeTest } = require("./tasks/smokeTest");
15+
const { smokeTest, smokeTestCheck } = require("./tasks/smokeTest");
1616
const {
1717
storeStorageLayoutForAllContracts,
1818
assertStorageLayoutChangeSafe,
@@ -145,6 +145,15 @@ task(
145145
"Optional deployment id to run smoke tests against"
146146
)
147147
.setAction(smokeTest);
148+
task(
149+
"smokeTestCheck",
150+
"Execute necessary smoke test environment / deploy script checks before the node is initialized"
151+
)
152+
.addOptionalParam(
153+
"deployid",
154+
"Optional deployment id to run smoke tests against"
155+
)
156+
.setAction(smokeTestCheck);
148157

149158
// Storage slots
150159
task(

contracts/scripts/test/smokeTest.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# any child processes created by this process are killed once the main process is terminated
2424
trap "exit" INT TERM ERR
2525
trap "kill 0" EXIT
26-
nodeWaitTimeout=180
26+
nodeWaitTimeout=60
2727

2828
main()
2929
{
@@ -32,9 +32,14 @@ main()
3232
echo "It is recommended that BLOCK_NUMBER is set to a recent block to improve performance of the fork";
3333
fi
3434

35+
SMOKE_TEST=true FORK=true npx hardhat smokeTestCheck --network localhost "$@"
36+
if [ $? -ne 0 ]
37+
then
38+
exit 1
39+
fi
40+
3541
nodeOutput=$(mktemp "${TMPDIR:-/tmp/}$(basename 0).XXX")
3642
SMOKE_TEST=true yarn run node:fork &> $nodeOutput &
37-
NODE_PID=$!
3843

3944
echo "Node output: $nodeOutput"
4045
echo "Waiting for node to initialize:"
@@ -53,7 +58,7 @@ main()
5358
printf "\n"
5459
echo "🟢 Node initialized running smoke tests"
5560

56-
FORK=true npx hardhat smokeTest --network localhost "$@"
61+
SMOKE_TEST=true FORK=true npx hardhat smokeTest --network localhost "$@"
5762
}
5863

5964
main "$@"

contracts/tasks/smokeTest.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,23 @@ function sleep(ms) {
4545
return new Promise((resolve) => setTimeout(resolve, ms));
4646
}
4747

48+
async function smokeTestCheck(taskArguments, hre) {
49+
const deployId = taskArguments.deployid
50+
51+
if (!deployId) {
52+
// interactive mode nothing to do here
53+
return
54+
}
55+
56+
const scripts = await getDeployScripts()
57+
const deployScript = scripts[parseInt(deployId)]
58+
const main = require(deployScript.fullPath)
59+
60+
if (!main.skip()) {
61+
throw new Error("Deploy script that smoke tests are ran against should return skip === true in smoke test environment. See that the 'main.skip' function in deploy script ends with '|| isSmokeTest;'")
62+
}
63+
}
64+
4865
async function smokeTest(taskArguments, hre) {
4966
const deployId = taskArguments.deployid
5067
let interactiveMode = false
@@ -104,5 +121,6 @@ async function smokeTest(taskArguments, hre) {
104121
}
105122

106123
module.exports = {
107-
smokeTest
124+
smokeTest,
125+
smokeTestCheck
108126
}

0 commit comments

Comments
 (0)