Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ FROM ubuntu:jammy

## Base tools installations
RUN apt-get update && \
apt-get install -y software-properties-common apt-utils wget tree sudo && \
# ca-certificates is required for wget downloads, apt utils for ppa additions. Optimisations here don't end well
## Google direct
wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
apt-get install -y --no-install-recommends ./google-chrome-stable_current_amd64.deb libxss1 netcat && \
rm google-chrome-stable_current_amd64.deb && \
apt-get install -y software-properties-common apt-utils wget tree sudo netcat && \
# Install Chromium from apt instead of Chrome .deb
apt-get install -y chromium-browser && \
## Node ppa
wget -qO- https://deb.nodesource.com/setup_18.x | bash - && \
apt-get update && \
Expand Down
2 changes: 1 addition & 1 deletion tests/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ module.exports = {
artifacts: "./artifacts"
},
mocha: {
timeout: 10000,
timeout: 60000,
parallel: true
}
}
18 changes: 9 additions & 9 deletions tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ totalRuntime=0

synthesis() {
if [ $? -eq 0 ]; then
currentRuntime=$(($(date +%s%N) - $date))
currentRuntime=$(($(date +%s) - $startdate))
totalRuntime=$(($totalRuntime + $currentRuntime))
if [ $currentRuntime -gt 10000000000 ]; then
Results="$Results$1 ⏰ $(($currentRuntime / 1000000000)), "
if [ $currentRuntime -gt 10 ]; then
Results="$Results$1 ⏰ $(($currentRuntime ))s, "
else
Results="$Results$1 ✅ $(($currentRuntime / 1000000000)), "
Results="$Results$1 ✅ $(($currentRuntime ))s, "
fi
else
Results=$Results$1" ❌, "
Expand All @@ -31,7 +31,7 @@ synthesis() {
}

#@ Should replicate the production environement
BaseOptions="--read-only --network none --memory 500M --cpus 2.0 --user 1000:1000 --env USERNAME=🧑‍🎓 --env HOME=/jail --env TMPDIR=/jail --workdir /jail --tmpfs /jail:size=100M,noatime,exec,nodev,nosuid,uid=1000,gid=1000,nr_inodes=5k,mode=1700 --volume $TEMP_STUDENT:/jail/student:ro"
BaseOptions="--platform linux/amd64 --read-only --network none --memory 500M --cpus 2.0 --user 1000:1000 --env USERNAME=🧑‍🎓 --env HOME=/jail --env TMPDIR=/jail --workdir /jail --tmpfs /jail:size=100M,noatime,exec,nodev,nosuid,uid=1000,gid=1000,nr_inodes=5k,mode=1700 --volume $TEMP_STUDENT:/jail/student:ro"

if [ ! -z "$1" ]; then
if [ "$1" = "clean" ]; then
Expand Down Expand Up @@ -62,14 +62,14 @@ if [ ! -z "$1" ]; then
exit 0
fi
# A specific test has been named, we run it with the debug flag
docker build . -t blockchain --progress=plain
docker build . -t blockchain --progress=plain --platform linux/amd64
mkdir -p $TEMP_STUDENT
cp $STORAGE_STUDENT/$1.{sol,js,html,mjs} $TEMP_STUDENT 2>/dev/null
time docker run $BaseOptions -e DEBUG=true -e EXERCISE="$1" blockchain:latest
else
# No specific test has been named. Run all tests with a summary at the end
echo "▶️ Docker build"
docker build . -t blockchain
docker build . -t blockchain --platform linux/amd64
echo "▶️ Running test"
# -e DEBUG=true available
mkdir -p $TEMP_STUDENT
Expand All @@ -78,13 +78,13 @@ else
rm $TEMP_STUDENT/* # for debugging, the folder is left and removed at the next run
cp $STORAGE_STUDENT/$testname.{sol,js,html,mjs} $TEMP_STUDENT 2>/dev/null
sleep 0.1
date=$(date +%s%N)
startdate=$(date +%s)
docker run $BaseOptions -e EXERCISE=$testname blockchain:latest
synthesis $testname
done
sleep 1
echo "▶️ Results"
echo $Results
echo "tests ran:$testNumber in avg $(($totalRuntime / 1000000 / $testNumber)) ms"
echo "tests ran:$testNumber in avg $(($totalRuntime / $testNumber)) seconds"
fi
exit 0