Skip to content

feat(integration): Parallelize integration tests #1086

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 137 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
cf545c1
parallel tests running
emizzle Dec 20, 2024
1ea9f58
test summary formatting
emizzle Dec 20, 2024
149d429
prevent errors during node shutdown
emizzle Jan 9, 2025
fe9596c
stdout formatting for test results
emizzle Jan 10, 2025
93d3a71
clean up
emizzle Jan 13, 2025
53bd04d
print start/finish stderr/stdout markers
emizzle Jan 13, 2025
f83b2e1
default test name to the filename of the integration test
emizzle Jan 13, 2025
c8e9e72
stop hardhat and show logs
emizzle Jan 14, 2025
16b2aa2
expect process exit code
emizzle Jan 14, 2025
75f806a
Add additional logging info print outs
emizzle Jan 14, 2025
421bd53
reinstate removed types
emizzle Jan 14, 2025
8ae25b3
pass hardhat port to ethersuite
emizzle Jan 14, 2025
739a29b
hang manager off IntegrationTest, cleanup
emizzle Jan 14, 2025
6d1610e
print hardhat testmanager errors and hardhat stdout when there is an …
emizzle Jan 14, 2025
9241047
clean up
emizzle Jan 14, 2025
31c2cd9
lock hardhat start to avoid intermittent start failures
emizzle Jan 14, 2025
784cd8b
cleanup
emizzle Jan 16, 2025
7c5b0d1
continually show test status updates
emizzle Jan 16, 2025
8281582
ensure timeouts work
emizzle Jan 16, 2025
0598153
fix nodeprocess not exiting
emizzle Jan 20, 2025
1621bc2
add constructor param for continuous status update in terminal
emizzle Jan 20, 2025
7f21d54
increase port distance per test run
emizzle Jan 20, 2025
7bebe21
make onoutputline callback gcsafe
emizzle Jan 20, 2025
eb7b105
remove unneeded sleep
emizzle Jan 21, 2025
a2bc5cb
fail early with message when hardhat binary not found
emizzle Jan 21, 2025
4a9c4a1
Use absolute path for binary when checking for existence
emizzle Jan 21, 2025
87e3d52
fix rebase
emizzle Jan 22, 2025
3e704de
fix rebase, formatting
emizzle Jan 22, 2025
4ad77c1
DIsable continuous updates by default (for CI)
emizzle Jan 22, 2025
1912cf0
allow test parameters to be set from make testIntegration command
emizzle Jan 22, 2025
614582c
format info blurbs
emizzle Jan 22, 2025
0b09c69
automatically enable chronicles logs for the test harness when DEBUG_…
emizzle Jan 22, 2025
5bdf65f
CI: do not start hardhat for integration tests
emizzle Jan 22, 2025
b808b53
formatting
emizzle Jan 22, 2025
6e72a22
use tracked futures for showContinuousStatusUpdates
emizzle Jan 22, 2025
fa58ad3
clean up
emizzle Jan 22, 2025
f10ed9e
formatting
emizzle Jan 22, 2025
2e8753e
formatting
emizzle Jan 22, 2025
066e4ff
npm install to install the hardhat binary in CI
emizzle Jan 22, 2025
3f44149
disable windows integration tests for now
emizzle Jan 23, 2025
68a4526
enable CI debugging
emizzle Jan 23, 2025
48befd7
Back off port inc in the hopes that this is causing issues with CI
emizzle Jan 28, 2025
7a8f335
temporarily remove linux test to see if macos works in ci
emizzle Jan 28, 2025
d81405d
undo changes done for CI debugging
emizzle Jan 28, 2025
0b70d55
use large linux runner and disable other tests
emizzle Jan 28, 2025
4d1c424
try large runners for linux/windows
emizzle Jan 28, 2025
49fbb07
temp remove coverage from ci workflow
emizzle Jan 28, 2025
ac3687b
bump to larger runner, linux only
emizzle Jan 28, 2025
b7c3bff
trying a self-hosted runner to see if it has more resources
emizzle Jan 28, 2025
9bae8a6
fix: pass show continuous updates into test manager instance
emizzle Jan 28, 2025
b98b818
indicate with exit code 1 if the tests failed
emizzle Jan 28, 2025
dd04413
add windows large runner 32vcpu
emizzle Jan 28, 2025
65de3a8
use macos-14-large
emizzle Jan 28, 2025
01a749d
fix exit status
emizzle Jan 28, 2025
b6b6991
nil check hardhat process before stopping
emizzle Jan 29, 2025
62baca0
re-add windows to CI
emizzle Jan 29, 2025
60caec2
Bubble errors from hardhat start
emizzle Jan 29, 2025
56348f4
fix hardhat running on windows
emizzle Jan 30, 2025
cb0a763
handle cancellations for race and allFutures
emizzle Jan 31, 2025
fff3726
fix waiting for hardhat node process exit on windows
emizzle Jan 31, 2025
b763e0c
swap linux large runner
emizzle Jan 31, 2025
d938090
enable debug logs for testpurchasing since the failure in ci
emizzle Jan 31, 2025
71f788e
Increase hardhat, codex api, and codex discovery ports for each subse…
emizzle Feb 3, 2025
8db6ed4
fix: use the last used port instead of the globally defined port
emizzle Feb 3, 2025
61acb5d
Allow parallel integration tests to be disabled
emizzle Feb 3, 2025
4424bd7
fix: hardhot not being stopped when test times out
emizzle Feb 4, 2025
f5b4e7e
cancel processes soon
emizzle Feb 4, 2025
2c87f3a
update Make flag to simply debug
emizzle Feb 5, 2025
28547b8
add test name to datadir path
emizzle Feb 6, 2025
23114b6
lock codex port selection in multinodesuites
emizzle Feb 6, 2025
d553a88
increase port gap by 1000 to avoid clashes in windows
emizzle Feb 6, 2025
9f85045
clean up
emizzle Feb 6, 2025
12f7b92
Allow debug runs from the github UI
emizzle Feb 6, 2025
174d1a2
run npm install for parallel tests in ci
emizzle Feb 6, 2025
fa0905e
CI: enable artefact upload for parallel tests
emizzle Feb 7, 2025
0512fb9
formatting
emizzle Feb 20, 2025
d36a00b
bump chronos to 4.0.4
emizzle Feb 21, 2025
86f1d0d
Add proper async exception tracking to multinodesuite
emizzle Feb 24, 2025
ecbcfc2
run tests async from start so that stop can cancel all tracked futures
emizzle Feb 28, 2025
376b69a
Refactor process launch
emizzle Feb 28, 2025
c85da85
Colorise stdout from test runs
emizzle Feb 25, 2025
96be622
ci: check runner for parallel integration tests and use value from vars
veaceslavdoina Feb 21, 2025
5459844
filter out log topics that are making too much noise
emizzle Mar 4, 2025
df42946
Ensure started tests are torn down properly on timeout
emizzle Mar 4, 2025
676ccbb
enable more logging to file
emizzle Mar 5, 2025
8bb573c
refactor: debug and logging
emizzle Mar 6, 2025
b5a0361
Fix process hanging after restart
emizzle Mar 6, 2025
47f826b
formatting
emizzle Mar 6, 2025
9ae5bd8
formatting
emizzle Mar 6, 2025
6cd7e2c
Update NBS action.yml in CI
emizzle Mar 6, 2025
1a906ee
CI yml fix for gcc-14
emizzle Mar 6, 2025
4559622
Add debugging and assertions after test run
emizzle Mar 7, 2025
01f5e5f
readd prevention of hanging when closing process streams on windows
emizzle Mar 7, 2025
9df4b98
re-raise CancelledError
emizzle Mar 10, 2025
e5ce6b8
do not re-raise CancelledError as convertError not used in async procs
emizzle Mar 11, 2025
a3d6848
Remove DebugCodexNodes
emizzle Mar 14, 2025
94009f5
ensure runTests doesn't raise CancelledError
emizzle Mar 14, 2025
18a3d4e
fix windows issue where reading stdout/stderr hangs forever
emizzle Mar 17, 2025
6bf3c8a
Add wait to stdout/stderr stream future
emizzle Mar 17, 2025
53df5fc
Remove debug from twonodesconfig
emizzle Mar 17, 2025
1975975
fix rebase on top of async http client change
emizzle Mar 18, 2025
72e9798
Move test assertions at end of start so that test.status can be set a…
emizzle Mar 18, 2025
de4fa33
disable all logging to see if windows passes
emizzle Mar 18, 2025
14c119b
reinstate logging after it also failed on windows and ci
emizzle Mar 19, 2025
0bd8c7c
Continuously read from stdout/stderr to prevent buffers from filling
emizzle Mar 19, 2025
5b2e546
Remove noCancel from captureProcessOutput call
emizzle Mar 19, 2025
a9bc6e4
remove noCancel from node startup in multinodes
emizzle Mar 19, 2025
7a87b92
unittest2 > unittest1
emizzle Mar 19, 2025
2b8f55e
Add "starting test" log to multinodes logging output for context
emizzle Mar 19, 2025
9cd4279
remove unneeded exception from start raises
emizzle Mar 20, 2025
19076d2
write to stdout/stderr as the stream is read, rearrange node stop log…
emizzle Mar 21, 2025
5c1076f
fix compilation error
emizzle Mar 21, 2025
4177948
add new line to stdout/stderr logs when logging lines
emizzle Mar 21, 2025
2aa1b0c
attempt to kill windows hardhat process
emizzle Mar 21, 2025
aa6a9f5
formatting
emizzle Mar 21, 2025
85030e3
Reduce the number of requests for asserts in tests
2-towns Mar 21, 2025
738ee09
fix: forcefully kill windows hardhat processes after termination
emizzle Mar 24, 2025
aa148ed
safeEventually > eventuallySafe
emizzle Mar 24, 2025
e305a5c
Remove new implementation of eventuallySafe by overidding the default…
emizzle Mar 24, 2025
f7eac83
fix makefile: DEBUG enables DebugHardhat
emizzle Mar 24, 2025
beca88a
re-enable debug logging in codex nodes
emizzle Mar 24, 2025
b877f34
Don't store hardhat logs in memory and do not print to term even if D…
emizzle Mar 24, 2025
8ce53f2
Reinstate unittest > unittest2, move eventually to ./asynctest
emizzle Mar 24, 2025
7797990
force kill windows test processes
emizzle Mar 24, 2025
da7e6ef
fix eventually symbol resolution
emizzle Mar 24, 2025
6e52a05
fix compilation errors in windows
emizzle Mar 24, 2025
422cc89
formatting
emizzle Mar 24, 2025
ad7b15f
re-enable all CI tests
emizzle Mar 24, 2025
8cfa7e9
update after rebase
emizzle Mar 25, 2025
b3bc587
verbose unittest2 output to stdout
emizzle Mar 25, 2025
1a9e080
try increasing polling interval to see if this has an effect on windo…
emizzle Mar 26, 2025
a98a34c
logging: show test setup/teardown in logs
emizzle Mar 26, 2025
a398047
try removing verbose output to see if windows ci passes
emizzle Mar 26, 2025
2b8cc25
fix previous commit compilation
emizzle Mar 26, 2025
87a1beb
revert posix-only verbose unittest output
emizzle Mar 26, 2025
e330353
increase period duration for windows ci
emizzle Mar 26, 2025
82b2763
use rebased version of contracts (not on master, but on what was work…
emizzle Mar 27, 2025
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
26 changes: 17 additions & 9 deletions .github/actions/nimbus-build-system/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ runs:
shell: ${{ inputs.shell }} {0}
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs/ | sh -s -- --default-toolchain=${{ inputs.rust_version }} -y
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"

- name: APT (Linux amd64/arm64)
if: inputs.os == 'linux' && (inputs.cpu == 'amd64' || inputs.cpu == 'arm64')
Expand Down Expand Up @@ -89,7 +90,7 @@ runs:

- name: Install gcc 14 on Linux
# We don't want to install gcc 14 for coverage (Ubuntu 20.04)
if : ${{ inputs.os == 'linux' && inputs.coverage != 'true' }}
if: ${{ inputs.os == 'linux' && inputs.coverage != 'true' }}
shell: ${{ inputs.shell }} {0}
run: |
# Add GCC-14 to alternatives
Expand All @@ -101,10 +102,17 @@ runs:
if: inputs.os == 'linux' || inputs.os == 'macos'
uses: hendrikmuhs/[email protected]
with:
create-symlink: true
create-symlink: false
key: ${{ matrix.os }}-${{ matrix.builder }}-${{ matrix.cpu }}-${{ matrix.tests }}-${{ matrix.nim_version }}
evict-old-files: 7d

- name: Add ccache to path on Linux/Mac
if: inputs.os == 'linux' || inputs.os == 'macos'
shell: ${{ inputs.shell }} {0}
run: |
echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> "$GITHUB_PATH"
echo "/usr/local/opt/ccache/libexec" >> "$GITHUB_PATH"

- name: Install ccache on Windows
if: inputs.os == 'windows'
uses: hendrikmuhs/[email protected]
Expand All @@ -117,11 +125,11 @@ runs:
shell: ${{ inputs.shell }} {0}
run: |
CCACHE_DIR=$(dirname $(which ccache))/ccached
mkdir ${CCACHE_DIR}
ln -s $(which ccache) ${CCACHE_DIR}/gcc.exe
ln -s $(which ccache) ${CCACHE_DIR}/g++.exe
ln -s $(which ccache) ${CCACHE_DIR}/cc.exe
ln -s $(which ccache) ${CCACHE_DIR}/c++.exe
mkdir -p ${CCACHE_DIR}
ln -sf $(which ccache) ${CCACHE_DIR}/gcc.exe
ln -sf $(which ccache) ${CCACHE_DIR}/g++.exe
ln -sf $(which ccache) ${CCACHE_DIR}/cc.exe
ln -sf $(which ccache) ${CCACHE_DIR}/c++.exe
echo "export PATH=${CCACHE_DIR}:\$PATH" >> $HOME/.bash_profile # prefix path in MSYS2

- name: Derive environment variables
Expand Down Expand Up @@ -202,7 +210,7 @@ runs:
- name: Restore Nim toolchain binaries from cache
id: nim-cache
uses: actions/cache@v4
if : ${{ inputs.coverage != 'true' }}
if: ${{ inputs.coverage != 'true' }}
with:
path: NimBinaries
key: ${{ inputs.os }}-${{ inputs.cpu }}-nim-${{ inputs.nim_version }}-cache-${{ env.cache_nonce }}-${{ github.run_id }}
Expand All @@ -225,4 +233,4 @@ runs:
gcc --version
make -j${ncpu} CI_CACHE=NimBinaries ${ARCH_OVERRIDE} QUICK_AND_DIRTY_COMPILER=1 update
echo
./env.sh nim --version
./env.sh nim --version
53 changes: 50 additions & 3 deletions .github/workflows/ci-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,46 @@ jobs:
nim_version: ${{ matrix.nim_version }}
coverage: false

- name: Check runner resources for parallel integration tests
run: |
echo "Determining runner"
case "${{ matrix.os }}" in
linux) CPU=$(nproc --all)
RAM=$(awk '/MemTotal/ {print int($2 / 1024 / 1024 + 0.5)}' /proc/meminfo)
;;
macos) CPU=$(sysctl -n hw.ncpu)
RAM=$(sysctl -n hw.memsize | awk '{print $0/1073741824}')
sysctl -n hw.ncpu
;;
windows) CPU=$NUMBER_OF_PROCESSORS
RAM=$(systeminfo | awk '/Total Physical Memory:/ { gsub(/,/,"."); print int($4 + 0.5) }')
;;
*) CPU=2
RAM=8
echo "Unknown runner"
;;
esac
echo "CPU=${CPU}" >> $GITHUB_ENV
echo "RAM=${RAM}" >> $GITHUB_ENV
echo "TYPE=${RUNNER_ENVIRONMENT}" >> $GITHUB_ENV

# Set PARALLEL=1 if the runner has enough resources
if [[ ("${{ matrix.os }}" == "linux" || "${{ matrix.os }}" == "windows") && "${CPU}" -ge 16 ]]; then
echo "PARALLEL=1" >> $GITHUB_ENV
elif [[ "${{ matrix.os }}" == "macos" && "${CPU}" -ge 6 ]]; then
echo "PARALLEL=1" >> $GITHUB_ENV
else
echo "PARALLEL=0" >> $GITHUB_ENV
fi

- name: Show runner information
run: |
echo "OS: ${{ matrix.os }}"
echo "CPU: ${{ env.CPU }}"
echo "RAM: ${{ env.RAM }} GB"
echo "TYPE: ${{ env.TYPE }}"
echo "PARALLEL: ${{ env.PARALLEL }}"

## Part 1 Tests ##
- name: Unit tests
if: matrix.tests == 'unittest' || matrix.tests == 'all'
Expand All @@ -53,13 +93,20 @@ jobs:
with:
node-version: 18.15

- name: Start Ethereum node with Codex contracts
- name: Install Ethereum node dependencies
if: matrix.tests == 'contract' || matrix.tests == 'integration' || matrix.tests == 'tools' || matrix.tests == 'all'
working-directory: vendor/codex-contracts-eth
env:
MSYS2_PATH_TYPE: inherit
run: |
npm install

- name: Run Ethereum node with Codex contracts
if: matrix.tests == 'contract' || (matrix.tests == 'integration' && env.PARALLEL != 1) || matrix.tests == 'tools' || matrix.tests == 'all'
working-directory: vendor/codex-contracts-eth
env:
MSYS2_PATH_TYPE: inherit
run: |
npm start &

## Part 2 Tests ##
Expand All @@ -70,13 +117,13 @@ jobs:
## Part 3 Tests ##
- name: Integration tests
if: matrix.tests == 'integration' || matrix.tests == 'all'
run: make -j${ncpu} testIntegration
run: make -j${ncpu} PARALLEL=${{ env.PARALLEL }} DEBUG=${{ runner.debug }} testIntegration

- name: Upload integration tests log files
uses: actions/upload-artifact@v4
if: (matrix.tests == 'integration' || matrix.tests == 'all') && always()
with:
name: ${{ matrix.os }}-${{ matrix.cpu }}-${{ matrix.nim_version }}-integration-tests-logs
name: ${{ matrix.os }}-${{ matrix.cpu }}-${{ matrix.nim_version }}-${{ matrix.tests }}-tests-logs
path: tests/integration/logs/
retention-days: 1

Expand Down
18 changes: 15 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,46 @@ on:
env:
cache_nonce: 0 # Allows for easily busting actions/cache caches
nim_version: v2.0.14
builder_integration_from_vars: true
builder_integration_linux: runner-node-01-linux-03-eu-hel1
builder_integration_macos: macos-14-large
builder_integration_windows: windows-latest-amd64-32vcpu

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
matrix:
name: Compute matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
cache_nonce: ${{ env.cache_nonce }}
steps:
- name: Compute builders
if: ${{ env.builder_integration_from_vars == 'true' }}
run: |
if [[ -n "${{ vars.builder_integration_linux }}" ]]; then echo "builder_integration_linux=${{ vars.builder_integration_linux }}"; fi >> $GITHUB_ENV
if [[ -n "${{ vars.builder_integration_macos }}" ]]; then echo "builder_integration_macos=${{ vars.builder_integration_macos }}"; fi >> $GITHUB_ENV
if [[ -n "${{ vars.builder_integration_windows }}" ]]; then echo "builder_integration_windows=${{ vars.builder_integration_windows }}"; fi >> $GITHUB_ENV

- name: Compute matrix
id: matrix
uses: fabiocaccamo/create-matrix-action@v5
with:
matrix: |
os {linux}, cpu {amd64}, builder {ubuntu-latest}, tests {unittest}, nim_version {${{ env.nim_version }}}, shell {bash --noprofile --norc -e -o pipefail}
os {linux}, cpu {amd64}, builder {ubuntu-latest}, tests {contract}, nim_version {${{ env.nim_version }}}, shell {bash --noprofile --norc -e -o pipefail}
os {linux}, cpu {amd64}, builder {ubuntu-latest}, tests {integration}, nim_version {${{ env.nim_version }}}, shell {bash --noprofile --norc -e -o pipefail}
os {linux}, cpu {amd64}, builder {${{ env.builder_integration_linux }}}, tests {integration}, nim_version {${{ env.nim_version }}}, shell {bash --noprofile --norc -e -o pipefail}
os {linux}, cpu {amd64}, builder {ubuntu-latest}, tests {tools}, nim_version {${{ env.nim_version }}}, shell {bash --noprofile --norc -e -o pipefail}
os {macos}, cpu {amd64}, builder {macos-13}, tests {unittest}, nim_version {${{ env.nim_version }}}, shell {bash --noprofile --norc -e -o pipefail}
os {macos}, cpu {amd64}, builder {macos-13}, tests {contract}, nim_version {${{ env.nim_version }}}, shell {bash --noprofile --norc -e -o pipefail}
os {macos}, cpu {amd64}, builder {macos-13}, tests {integration}, nim_version {${{ env.nim_version }}}, shell {bash --noprofile --norc -e -o pipefail}
os {macos}, cpu {amd64}, builder {${{ env.builder_integration_macos }}}, tests {integration}, nim_version {${{ env.nim_version }}}, shell {bash --noprofile --norc -e -o pipefail}
os {macos}, cpu {amd64}, builder {macos-13}, tests {tools}, nim_version {${{ env.nim_version }}}, shell {bash --noprofile --norc -e -o pipefail}
os {windows}, cpu {amd64}, builder {windows-latest}, tests {unittest}, nim_version {${{ env.nim_version }}}, shell {msys2}
os {windows}, cpu {amd64}, builder {windows-latest}, tests {contract}, nim_version {${{ env.nim_version }}}, shell {msys2}
os {windows}, cpu {amd64}, builder {windows-latest}, tests {integration}, nim_version {${{ env.nim_version }}}, shell {msys2}
os {windows}, cpu {amd64}, builder {${{ env.builder_integration_windows }}}, tests {integration}, nim_version {${{ env.nim_version }}}, shell {msys2}
os {windows}, cpu {amd64}, builder {windows-latest}, tests {tools}, nim_version {${{ env.nim_version }}}, shell {msys2}

build:
Expand Down
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,24 @@ testContracts: | build deps
echo -e $(BUILD_MSG) "build/$@" && \
$(ENV_SCRIPT) nim testContracts $(NIM_PARAMS) build.nims

TEST_PARAMS :=
ifdef DEBUG
TEST_PARAMS := $(TEST_PARAMS) -d:DebugTestHarness=$(DEBUG)
TEST_PARAMS := $(TEST_PARAMS) -d:NoCodexLogFilters=$(DEBUG)
TEST_PARAMS := $(TEST_PARAMS) -d:ShowContinuousStatusUpdates=$(DEBUG)
TEST_PARAMS := $(TEST_PARAMS) -d:DebugHardhat=$(DEBUG)
endif
ifdef TEST_TIMEOUT
TEST_PARAMS := $(TEST_PARAMS) -d:TestTimeout=$(TEST_TIMEOUT)
endif
ifdef PARALLEL
TEST_PARAMS := $(TEST_PARAMS) -d:EnableParallelTests=$(PARALLEL)
endif

# Builds and runs the integration tests
testIntegration: | build deps
echo -e $(BUILD_MSG) "build/$@" && \
$(ENV_SCRIPT) nim testIntegration $(NIM_PARAMS) build.nims
$(ENV_SCRIPT) nim testIntegration $(TEST_PARAMS) $(NIM_PARAMS) build.nims

# Builds and runs all tests (except for Taiko L2 tests)
testAll: | build deps
Expand Down
18 changes: 15 additions & 3 deletions build.nims
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
mode = ScriptMode.Verbose

import std/os except commandLineParams
import std/strutils

### Helper functions
proc truthy(val: string): bool =
const truthySwitches = @["yes", "1", "on", "true"]
return val in truthySwitches

proc buildBinary(name: string, srcDir = "./", params = "", lang = "c") =
if not dirExists "build":
mkDir "build"
Expand Down Expand Up @@ -45,11 +50,18 @@ task testContracts, "Build & run Codex Contract tests":
task testIntegration, "Run integration tests":
buildBinary "codex",
params =
"-d:chronicles_runtime_filtering -d:chronicles_log_level=TRACE -d:codex_enable_proof_failures=true"
test "testIntegration"
"-d:chronicles_runtime_filtering -d:chronicles_log_level=TRACE -d:chronicles_disabled_topics=JSONRPC-HTTP-CLIENT,websock,libp2p,discv5 -d:codex_enable_proof_failures=true"
var sinks = @["textlines[nocolors,file]"]
for i in 2 ..< paramCount():
if "DebugTestHarness" in paramStr(i) and truthy paramStr(i).split('=')[1]:
sinks.add "textlines[stdout]"
break
var testParams =
"-d:chronicles_log_level=TRACE -d:chronicles_sinks=\"" & sinks.join(",") & "\""
test "testIntegration", params = testParams
# use params to enable logging from the integration test executable
# test "testIntegration", params = "-d:chronicles_sinks=textlines[notimestamps,stdout],textlines[dynamic] " &
# "-d:chronicles_enabled_topics:integration:TRACE"
# "-d:chronicles_enabled_topics:integration:TRACE"

task build, "build codex binary":
codexTask()
Expand Down
6 changes: 6 additions & 0 deletions codex/blockexchange/engine/engine.nim
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ const
DefaultMaxPeersPerRequest* = 10
DefaultTaskQueueSize = 100
DefaultConcurrentTasks = 10
# DefaultMaxRetries = 3
# DefaultConcurrentDiscRequests = 10
# DefaultConcurrentAdvertRequests = 10
# DefaultDiscoveryTimeout = 1.minutes
# DefaultMaxQueriedBlocksCache = 1000
# DefaultMinPeersPerBlock = 3

type
TaskHandler* = proc(task: BlockExcPeerCtx): Future[void] {.gcsafe.}
Expand Down
3 changes: 3 additions & 0 deletions codex/logutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ import std/sugar
import std/typetraits

import pkg/chronicles except toJson, `%`
from pkg/chronos import TransportAddress
from pkg/libp2p import Cid, MultiAddress, `$`
import pkg/questionable
import pkg/questionable/results
Expand Down Expand Up @@ -255,3 +256,5 @@ formatIt(LogFormat.textLines, array[32, byte]):
it.short0xHexLog
formatIt(LogFormat.json, array[32, byte]):
it.to0xHex
formatIt(TransportAddress):
$it
12 changes: 11 additions & 1 deletion tests/asynctest.nim
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
import pkg/asynctest/chronos/unittest2

export unittest2
export unittest2 except eventually

template eventuallySafe*(
expression: untyped, timeout = 5000, pollInterval = 1000
): bool =
## More sane defaults, for use with HTTP connections
eventually(expression, timeout, pollInterval)

template eventually*(expression: untyped, timeout = 5000, pollInterval = 10): bool =
## Fast defaults, do not use with HTTP connections!
eventually(expression, timeout, pollInterval)
6 changes: 2 additions & 4 deletions tests/codex/slots/sampler/testutils.nim
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,13 @@ asyncchecksuite "Test proof sampler utils":
)

proc getExpectedIndices(n: int): seq[Natural] =
return collect(
newSeq,
return collect(newSeq):
(;
for i in 1 .. n:
cellIndex(
proofInput.entropy, proofInput.slotRoot, proofInput.nCellsPerSlot, i
)
),
)
)

check:
slotCellIndices(3) == getExpectedIndices(3)
Expand Down
4 changes: 3 additions & 1 deletion tests/ethertest.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import pkg/chronos
import ./asynctest
import ./checktest

const HardhatPort {.intdefine.}: int = 8545

## Unit testing suite that sets up an Ethereum testing environment.
## Injects a `ethProvider` instance, and a list of `accounts`.
## Calls the `evm_snapshot` and `evm_revert` methods to ensure that any
Expand All @@ -17,7 +19,7 @@ template ethersuite*(name, body) =

setup:
ethProvider = JsonRpcProvider.new(
"http://127.0.0.1:8545", pollingInterval = chronos.milliseconds(100)
"http://127.0.0.1:" & $HardhatPort, pollingInterval = chronos.milliseconds(100)
)
snapshot = await send(ethProvider, "evm_snapshot")
accounts = await ethProvider.listAccounts()
Expand Down
2 changes: 2 additions & 0 deletions tests/helpers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import helpers/templeveldb
import std/times
import std/sequtils, chronos

import ./asynctest

export multisetup, trackers, templeveldb

### taken from libp2p errorhelpers.nim
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/codexconfig.nim
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ proc withLogFile*(self: CodexConfigs): CodexConfigs {.raises: [CodexConfigError]

proc withLogFile*(
self: var CodexConfig, logFile: string
) {.raises: [CodexConfigError].} = #: CodexConfigs =
) {.raises: [CodexConfigError].} =
#: CodexConfigs =
## typically called internally from the test suite, sets a log file path to
## be created during the test run, for a specified node in the group
# var config = self
Expand Down
Loading
Loading