Skip to content

Commit

Permalink
Merge pull request #4405 from eval-exec/exec/fix-config-notify
Browse files Browse the repository at this point in the history
[Breaking Change] Fix default `ckb.toml`'s `[notifier]` to `[notify]`
  • Loading branch information
quake committed Apr 16, 2024
2 parents 1ff3ac8 + 1978b54 commit c19bcf5
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion resource/ckb.toml
Expand Up @@ -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.
Expand Down
File renamed without changes.
Expand Up @@ -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
Expand Down
File renamed without changes.
49 changes: 49 additions & 0 deletions 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
}
File renamed without changes.

0 comments on commit c19bcf5

Please sign in to comment.