From 1cec24eb655c08b1639e50d785a45759fbf1e703 Mon Sep 17 00:00:00 2001 From: labdulla Date: Thu, 4 Dec 2025 02:41:22 +0300 Subject: [PATCH] =?UTF-8?q?The=20key=20changes=20are:=201.=20Added=C2=A0--?= =?UTF-8?q?platform=20linux/amd64=C2=A0to=20the=20docker=20build=20command?= =?UTF-8?q?=20in=20the=20else=20block=20(line=20where=20it=20says=C2=A0doc?= =?UTF-8?q?ker=20build=20.=20-t=20blockchain)=202.=20The=C2=A0BaseOptions?= =?UTF-8?q?=C2=A0variable=20already=20has=C2=A0--platform=20linux/amd64?= =?UTF-8?q?=C2=A0at=20the=20beginning,=20so=20all=20docker=20run=20command?= =?UTF-8?q?s=20will=20use=20it=203.=20Fix=20The=20issue=20is=20with=20the?= =?UTF-8?q?=20date=20calculation=20in=20your=20script.=20On=20macOS,=C2=A0?= =?UTF-8?q?date=20+%s%N=C2=A0doesn't=20work=20the=20same=20way=20as=20on?= =?UTF-8?q?=20Linux=20-=20the=C2=A0%N=C2=A0(nanoseconds)=20is=20not=20supp?= =?UTF-8?q?orted=20and=20gets=20printed=20literally=20as=20N.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/Dockerfile | 9 +++------ tests/hardhat.config.js | 2 +- tests/run.sh | 18 +++++++++--------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/tests/Dockerfile b/tests/Dockerfile index b5f55c3..945a23b 100644 --- a/tests/Dockerfile +++ b/tests/Dockerfile @@ -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 && \ diff --git a/tests/hardhat.config.js b/tests/hardhat.config.js index 639007f..4755dc9 100755 --- a/tests/hardhat.config.js +++ b/tests/hardhat.config.js @@ -48,7 +48,7 @@ module.exports = { artifacts: "./artifacts" }, mocha: { - timeout: 10000, + timeout: 60000, parallel: true } } \ No newline at end of file diff --git a/tests/run.sh b/tests/run.sh index e23eecb..616b5af 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -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" ❌, " @@ -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 @@ -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 @@ -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