fix for anvil 1.4.x
This commit is contained in:
29
bin/mock
29
bin/mock
@@ -4,25 +4,29 @@
|
|||||||
# Dev account #4
|
# Dev account #4
|
||||||
PRIVATE_KEY=0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a
|
PRIVATE_KEY=0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
# Function to cleanup processes
|
# Function to cleanup processes
|
||||||
cleanup() {
|
cleanup() {
|
||||||
kill $ANVIL_PID 2>/dev/null
|
if [[ -n "${ANVIL_PID:-}" ]] && kill -0 "$ANVIL_PID" 2>/dev/null; then
|
||||||
|
kill "$ANVIL_PID" 2>/dev/null || true
|
||||||
|
sleep 0.2
|
||||||
|
kill -9 "$ANVIL_PID" 2>/dev/null || true
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
err() {
|
# Ensure cleanup on any exit
|
||||||
cleanup
|
|
||||||
exit $1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Set up trap to handle script exit
|
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
# On Ctrl-C or TERM: exit immediately (will trigger EXIT trap -> cleanup)
|
||||||
|
trap 'exit 130' INT
|
||||||
|
trap 'exit 143' TERM
|
||||||
|
|
||||||
# Create log directory if it doesn't exist
|
# Create log directory if it doesn't exist
|
||||||
mkdir -p log
|
mkdir -p log
|
||||||
|
|
||||||
# Run anvil in background and redirect output to log file
|
# Run anvil in background and redirect output to log file
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
anvil | tee log/anvil.txt &
|
anvil --disable-block-gas-limit | tee log/anvil.txt &
|
||||||
ANVIL_PID=$!
|
ANVIL_PID=$!
|
||||||
|
|
||||||
# Function to check if string exists in file
|
# Function to check if string exists in file
|
||||||
@@ -43,14 +47,13 @@ while ! check_string "Listening on" "log/anvil.txt"; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
forge script --private-key ${PRIVATE_KEY} DeployMock --fork-url http://localhost:8545 --broadcast "$@" || err 1
|
forge script --private-key ${PRIVATE_KEY} DeployMock --fork-url http://localhost:8545 --broadcast "$@" || exit 1
|
||||||
|
|
||||||
if [ "$1" = "slow" ]; then
|
if [ "${1:-}" = "slow" ]; then
|
||||||
echo "SLOW MODE: Setting mining mode to 12-second intervals."
|
echo "SLOW MODE: Setting mining mode to 12-second intervals."
|
||||||
cast rpc evm_setIntervalMining 12
|
cast rpc evm_setIntervalMining 12
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Press Ctrl+C to exit..."
|
echo "Press Ctrl+C to exit..."
|
||||||
while true; do
|
# Wait for the anvil process; Ctrl-C will interrupt 'wait' and trigger cleanup via traps
|
||||||
sleep 1
|
wait "$ANVIL_PID"
|
||||||
done
|
|
||||||
|
|||||||
Reference in New Issue
Block a user