fix: spawn correct network size in cdx_launch_network

This commit is contained in:
gmega 2025-06-30 17:22:25 -03:00
parent 70061c4008
commit 4ee345889f
No known key found for this signature in database
GPG Key ID: 6290D34EAD824B18
4 changed files with 19 additions and 5 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
outputs
*.log

View File

@ -40,17 +40,18 @@ echoerr "* Timing log: ${output_log}"
trap pm_stop EXIT INT TERM
pm_start
#cdx_set_log_level "INFO;trace:blockexcnetwork,blockexcengine,discoveryengine"
cdx_launch_network "${node_count}"
for i in $(seq 1 "${repetitions}"); do
for file_size in "${file_sizes[@]}"; do
for file_size in "${file_sizes[@]}"; do
for i in $(seq 1 "${repetitions}"); do
file_name=$(cdx_generate_file "${file_size}")
cid=$(cdx_upload_file "0" "${file_name}")
cdx_log_timings_start "${output_log}" "${file_size},${i},${cid}"
handles=()
for j in $(seq 1 "${node_count}"); do
for j in $(seq 1 "$((node_count - 1))"); do
cdx_download_file_async "$j" "$cid"
# shellcheck disable=SC2128
handles+=("$result")

View File

@ -40,6 +40,8 @@ _cdx_log_level="INFO"
echoerr "[codex] Node log level is ${_cdx_log_level}"
# PID array for known Codex node processes
# FIXME: right now only processes destroyed with cdx_destroy_node are removed from
# this array.
declare -A _cdx_pids
cdx_set_outputs() {
@ -128,7 +130,7 @@ cdx_cmdline() {
# shellcheck disable=SC2140
echo "${cdx_cmd}"\
"--data-dir=${_cdx_data}/codex-${node_index} --api-port=$(_cdx_api_port "$node_index")"\
"--disc-port=$(_cdx_disc_port "$node_index") --log-level=${_cdx_log_level}"
"--disc-port=$(_cdx_disc_port "$node_index") '--log-level=${_cdx_log_level}'"
}
cdx_get_spr() {
@ -163,9 +165,14 @@ cdx_launch_node() {
cdx_launch_network() {
local node_count="$1" bootstrap_spr
if [[ "$node_count" -lt 2 ]]; then
echoerr "Error: a Codex network needs at least 2 nodes"
return 1
fi
cdx_launch_node 0 || return 1
bootstrap_spr=$(cdx_get_spr 0) || return 1
for i in $(seq 1 "$node_count"); do
for i in $(seq 1 "$((node_count - 1))"); do
cdx_launch_node "$i" "--bootstrap-node" "$bootstrap_spr" || return 1
done
return 0

View File

@ -149,6 +149,10 @@ setup() {
pm_stop
}
@test "should refuse to launch a Codex network with less than 2 nodes" {
refute cdx_launch_network 1
}
@test "should launch a Codex network and allow uploading and downloading" {
pm_start