Skip to content
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

[Breaking Change] Fix default ckb.toml's [notifier] to [notify] #4405

Merged
merged 5 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
49 changes: 49 additions & 0 deletions util/app-config/src/tests/bats_tests/load_notify_config.bats
Original file line number Diff line number Diff line change
@@ -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
}
Loading