From fe91a34a50ec4ac8037c6d153f7789b497562c18 Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Thu, 21 Aug 2025 21:02:19 +0800 Subject: [PATCH 1/2] test: ci test for `forest-cli state compute` --- scripts/tests/calibnet_other_check.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/tests/calibnet_other_check.sh b/scripts/tests/calibnet_other_check.sh index fbbc9ba5967f..86682ad87dd6 100755 --- a/scripts/tests/calibnet_other_check.sh +++ b/scripts/tests/calibnet_other_check.sh @@ -16,7 +16,7 @@ go test -v ./f3-sidecar echo "Verifying the non calibnet snapshot (./test-snapshots/chain4.car) is being served properly." $FOREST_CLI_PATH chain read-obj -c bafy2bzacedjrqan2fwfvhfopi64yickki7miiksecglpeiavf7xueytnzevlu -echo "Test subcommand: state compute" +echo "Test subcommand: state compute at epoch 0" cid=$($FOREST_CLI_PATH state compute --epoch 0) # Expected state root CID, same reported as in Lotus. This should break only if the network is reset. if [ "$cid" != "bafy2bzacecgqgzh3gxpariy3mzqb37y2vvxoaw5nwbrlzkhso6owus3zqckwe" ]; then @@ -63,3 +63,6 @@ echo "Regression testing mempool select" gem install http --user-install $FOREST_CLI_PATH chain head --format json -n 1000 | scripts/mpool_select_killer.rb +echo "Test subcommand: state compute (batch)" +head=$($FOREST_CLI_PATH chain head | head -n 1 | jq ".[0]") +$FOREST_CLI_PATH state compute --epoch $((head - 900)) -n 10 -v From a615a51ab9d84b777bb5da49f8117f3655ee3b7b Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Thu, 21 Aug 2025 22:42:05 +0800 Subject: [PATCH 2/2] resolve AI review comments --- scripts/tests/calibnet_other_check.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/tests/calibnet_other_check.sh b/scripts/tests/calibnet_other_check.sh index 86682ad87dd6..62372fcf667f 100755 --- a/scripts/tests/calibnet_other_check.sh +++ b/scripts/tests/calibnet_other_check.sh @@ -64,5 +64,10 @@ gem install http --user-install $FOREST_CLI_PATH chain head --format json -n 1000 | scripts/mpool_select_killer.rb echo "Test subcommand: state compute (batch)" -head=$($FOREST_CLI_PATH chain head | head -n 1 | jq ".[0]") -$FOREST_CLI_PATH state compute --epoch $((head - 900)) -n 10 -v +head_epoch=$($FOREST_CLI_PATH chain head --format json | jq ".[0].epoch") +if ! [[ "$head_epoch" =~ ^[0-9]+$ ]]; then + echo "Failed to parse numeric head epoch from 'chain head --format json': $head_epoch" + exit 1 +fi +start_epoch=$(( head_epoch > 900 ? head_epoch - 900 : 0 )) +$FOREST_CLI_PATH state compute --epoch "$start_epoch" -n 10 -v