From 5ec344056382bddfa8fbb596f1280aaeb6038f84 Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Tue, 9 Apr 2024 18:56:00 +0800 Subject: [PATCH 1/5] Change default ckb.toml `[notifier]` to `[notify]` --- resource/ckb.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resource/ckb.toml b/resource/ckb.toml index 6605d1d067..1ccd93b623 100644 --- a/resource/ckb.toml +++ b/resource/ckb.toml @@ -146,7 +146,7 @@ block_proposals_cache_size = 30 block_tx_hashes_cache_size = 30 block_uncles_cache_size = 30 -# [notifier] +# [notify] # # Execute command when the new tip block changes, first arg is block hash. # new_block_notify_script = "your_new_block_notify_script.sh" # # Execute command when node received an network alert, first arg is alert message string. From 38d2a0906af6f6ff5d6d14fa206eaf0f11a9e372 Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Mon, 15 Apr 2024 09:47:01 +0800 Subject: [PATCH 2/5] Move bats-test to util/app-config/src/tests/bats-tests --- util/app-config/src/tests/{ => bats_tests}/ckb_run_replay.bats | 0 util/app-config/src/tests/{ => bats_tests}/cli.bats | 0 util/app-config/src/tests/{ => bats_tests}/cli_test.sh | 0 util/app-config/src/tests/{ => bats_tests}/export_import.bats | 0 util/app-config/src/tests/{ => bats_tests}/graceful_shutdown.bats | 0 util/app-config/src/tests/{ => bats_tests}/init_reset.bats | 0 .../src/tests/{ => bats_tests}/later_bats_job/change_epoch.bats | 0 util/app-config/src/tests/{ => bats_tests}/peer_id.bats | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename util/app-config/src/tests/{ => bats_tests}/ckb_run_replay.bats (100%) rename util/app-config/src/tests/{ => bats_tests}/cli.bats (100%) rename util/app-config/src/tests/{ => bats_tests}/cli_test.sh (100%) rename util/app-config/src/tests/{ => bats_tests}/export_import.bats (100%) rename util/app-config/src/tests/{ => bats_tests}/graceful_shutdown.bats (100%) rename util/app-config/src/tests/{ => bats_tests}/init_reset.bats (100%) rename util/app-config/src/tests/{ => bats_tests}/later_bats_job/change_epoch.bats (100%) rename util/app-config/src/tests/{ => bats_tests}/peer_id.bats (100%) diff --git a/util/app-config/src/tests/ckb_run_replay.bats b/util/app-config/src/tests/bats_tests/ckb_run_replay.bats similarity index 100% rename from util/app-config/src/tests/ckb_run_replay.bats rename to util/app-config/src/tests/bats_tests/ckb_run_replay.bats diff --git a/util/app-config/src/tests/cli.bats b/util/app-config/src/tests/bats_tests/cli.bats similarity index 100% rename from util/app-config/src/tests/cli.bats rename to util/app-config/src/tests/bats_tests/cli.bats diff --git a/util/app-config/src/tests/cli_test.sh b/util/app-config/src/tests/bats_tests/cli_test.sh similarity index 100% rename from util/app-config/src/tests/cli_test.sh rename to util/app-config/src/tests/bats_tests/cli_test.sh diff --git a/util/app-config/src/tests/export_import.bats b/util/app-config/src/tests/bats_tests/export_import.bats similarity index 100% rename from util/app-config/src/tests/export_import.bats rename to util/app-config/src/tests/bats_tests/export_import.bats diff --git a/util/app-config/src/tests/graceful_shutdown.bats b/util/app-config/src/tests/bats_tests/graceful_shutdown.bats similarity index 100% rename from util/app-config/src/tests/graceful_shutdown.bats rename to util/app-config/src/tests/bats_tests/graceful_shutdown.bats diff --git a/util/app-config/src/tests/init_reset.bats b/util/app-config/src/tests/bats_tests/init_reset.bats similarity index 100% rename from util/app-config/src/tests/init_reset.bats rename to util/app-config/src/tests/bats_tests/init_reset.bats diff --git a/util/app-config/src/tests/later_bats_job/change_epoch.bats b/util/app-config/src/tests/bats_tests/later_bats_job/change_epoch.bats similarity index 100% rename from util/app-config/src/tests/later_bats_job/change_epoch.bats rename to util/app-config/src/tests/bats_tests/later_bats_job/change_epoch.bats diff --git a/util/app-config/src/tests/peer_id.bats b/util/app-config/src/tests/bats_tests/peer_id.bats similarity index 100% rename from util/app-config/src/tests/peer_id.bats rename to util/app-config/src/tests/bats_tests/peer_id.bats From e48b600477f78df1c427ea0413872c8470782f71 Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Mon, 15 Apr 2024 09:50:24 +0800 Subject: [PATCH 3/5] Fix `make cli-test` script path --- Makefile | 2 +- util/app-config/src/tests/bats_tests/cli_test.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 4915a49164..4ad5287c28 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ doc-test: ## Run doc tests .PHONY: cli-test cli-test: prod # Run ckb command line usage bats test - ./util/app-config/src/tests/cli_test.sh + ./util/app-config/src/tests/bats_tests/cli_test.sh .PHONY: test test: ## Run all tests, including some tests can be time-consuming to execute (tagged with [ignore]) diff --git a/util/app-config/src/tests/bats_tests/cli_test.sh b/util/app-config/src/tests/bats_tests/cli_test.sh index fb592bc5b6..25ee673c26 100755 --- a/util/app-config/src/tests/bats_tests/cli_test.sh +++ b/util/app-config/src/tests/bats_tests/cli_test.sh @@ -12,9 +12,9 @@ function cleanup { trap cleanup EXIT cp target/prod/ckb ${CKB_BATS_TESTBED} -cp util/app-config/src/tests/*.bats ${CKB_BATS_TESTBED} -cp -r util/app-config/src/tests/later_bats_job ${CKB_BATS_TESTBED} -cp util/app-config/src/tests/*.sh ${CKB_BATS_TESTBED} +cp util/app-config/src/tests/bats_tests/*.bats ${CKB_BATS_TESTBED} +cp -r util/app-config/src/tests/bats_tests/later_bats_job ${CKB_BATS_TESTBED} +cp util/app-config/src/tests/bats_tests/*.sh ${CKB_BATS_TESTBED} if [ ! -d "/tmp/ckb_bats_assets/" ]; then git clone --depth=1 https://github.com/nervosnetwork/ckb-assets /tmp/ckb_bats_assets From 47295a7198499345aa50b476a5eeb8975d0fe5e2 Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Mon, 15 Apr 2024 09:55:11 +0800 Subject: [PATCH 4/5] Add load uncomment [notify] config bats-test Signed-off-by: Eval EXEC --- .../tests/bats_tests/load_notify_config.bats | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 util/app-config/src/tests/bats_tests/load_notify_config.bats diff --git a/util/app-config/src/tests/bats_tests/load_notify_config.bats b/util/app-config/src/tests/bats_tests/load_notify_config.bats new file mode 100644 index 0000000000..df0f341535 --- /dev/null +++ b/util/app-config/src/tests/bats_tests/load_notify_config.bats @@ -0,0 +1,49 @@ +#!/usr/bin/env bats +bats_load_library 'bats-assert' +bats_load_library 'bats-support' + + +_init() { + bash -c "ckb init -C ${CKB_DIRNAME} -f " +} + +_uncomment_notify_config() { + sed -i 's/# \[notify\]/\[notify\]/g' ${CKB_DIRNAME}/ckb.toml +} + + +_run() { + ckb run -C ${CKB_DIRNAME} &> ${TMP_DIR}/ckb_notify.log & + PID=$! + sleep 3 + kill ${PID} + + while kill -0 ${PID}; do + sleep 1 + done + + grep -q "CKB shutdown" ${TMP_DIR}/ckb_notify.log +} + +_log_no_error() { + if grep -q -i error ${TMP_DIR}/ckb_notify.log; then + echo "error found in log" + return 1 + fi +} + +function run_with_uncomment_notify_config { #@test + run _init + [ "$status" -eq 0 ] + + run _uncomment_notify_config + [ "$status" -eq 0 ] + + run _run + [ "$status" -eq 0 ] + + run _log_no_error + [ "$status" -eq 0 ] + + cat ${TMP_DIR}/ckb_notify.log +} From 1978b545442e0724c4737be978e011f9e71f8cb7 Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Mon, 15 Apr 2024 10:34:15 +0800 Subject: [PATCH 5/5] Remove trailing whitespace --- util/app-config/src/tests/bats_tests/load_notify_config.bats | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/app-config/src/tests/bats_tests/load_notify_config.bats b/util/app-config/src/tests/bats_tests/load_notify_config.bats index df0f341535..d96786f0a7 100644 --- a/util/app-config/src/tests/bats_tests/load_notify_config.bats +++ b/util/app-config/src/tests/bats_tests/load_notify_config.bats @@ -41,9 +41,9 @@ function run_with_uncomment_notify_config { #@test run _run [ "$status" -eq 0 ] - + run _log_no_error [ "$status" -eq 0 ] - + cat ${TMP_DIR}/ckb_notify.log }