diff --git a/test/softfork_test.sh b/test/softfork_test.sh index e41995f636..35270a2b75 100755 --- a/test/softfork_test.sh +++ b/test/softfork_test.sh @@ -1,19 +1,22 @@ #!/bin/bash -# this testing script requires jq - cleanup () { - rm -rf /path/to/datadir/regtest + agt_cli stop + rm -rf "$datadir" } mine_block () { - agt_cli generatetoaddress 1 "$1" 1>/dev/null + agt_cli generatetoaddress 1 "$1" 1>/dev/null (( "timestamp+=10" )) agt_cli setmocktime "$timestamp" } +dummy_mine () { + mine_block "$other_address" > /dev/null 2>&1 +} + agt_cli () { - src/argentumnt-cli -regtest -datadir=/path/to/datadir "$@" + src/argentumnt-cli -regtest -datadir="$datadir" "$@" } get_status () { @@ -25,7 +28,7 @@ get_height () { } start_server () { - src/argentumntd -daemon -regtest -datadir=/path/to/datadir -txindex -blockversion="$1" + src/argentumntd -daemon -regtest -datadir="$datadir" -txindex -blockversion="$1" sleep 3 } @@ -41,6 +44,15 @@ assert_string_eql () { fi } +if ! command -v jq > /dev/null; then + echo please install jq + exit 1 +fi + +trap cleanup EXIT + +datadir=$(mktemp -d) + # 0X20000000 bip9_flag_unset=536870912 # 0X20000004 (third bit) @@ -81,10 +93,10 @@ start_server $bip9_flag_unset # for any but the first server startups, the first generatetoaddress # mine fails ("time-too-old"). # It is likely connected to the hacky use of setmocktime, which is itself -# necessitated by the validation rule that block times must strictly +# necessitated by the validation rule that block times must strictly # monotonically increase. # We therefore call mine_block once whenever we restart the server. -mine_block $other_address +dummy_mine end=$((miner_confirmation_window - change_activation_threshold + 1)) for _ in $(seq 1 $end); do @@ -95,7 +107,7 @@ assert_string_eql '"started"' "$(get_status)" stop_server start_server $bip9_flag_set -mine_block $other_address +dummy_mine ##### Mine enough blocks to lock in end=$((change_activation_threshold)) @@ -105,7 +117,7 @@ done stop_server start_server $bip9_flag_unset -mine_block $other_address +dummy_mine ##### Mine all but one of the rest of the blocks of activation window end=$((miner_confirmation_window - change_activation_threshold - 1)) @@ -130,11 +142,8 @@ mine_block $other_address assert_string_eql '"active"' "$(get_status)" assert_string_eql '575' "$(get_height)" -mine_block $other_address +mine_block $other_address > /dev/null 2>&1 assert_string_eql '575' "$(get_height)" mine_block $whitelisted_address assert_string_eql '576' "$(get_height)" - -stop_server -cleanup