diff options
Diffstat (limited to 'test/btc/hell.sh')
-rw-r--r-- | test/btc/hell.sh | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/test/btc/hell.sh b/test/btc/hell.sh new file mode 100644 index 0000000..7b83337 --- /dev/null +++ b/test/btc/hell.sh @@ -0,0 +1,144 @@ +#!/bin/bash + +## Test btc_wire correctness when a blockchain reorganisation occurs leading to past incoming transaction conflict + +set -eu + +source "${BASH_SOURCE%/*}/../common.sh" +SCHEMA=btc.sql + +echo "----- Setup -----" +echo "Load config file" +load_config +echo "Start database" +setup_db +echo "Start bitcoin node" +init_btc +echo "Start second bitcoin node" +init_btc2 +echo "Start btc-wire" +btc_wire +echo "Start gateway" +gateway +echo "" + +# Check btc-wire is running +function up() { + check_up $WIRE_PID btc_wire +} +# Check btc-wire is not running +function down() { + check_down $WIRE_PID btc_wire +} + +echo "----- Handle reorg conflicting incoming receive -----" + +echo "Loose second bitcoin node" +btc2_deco + +echo -n "Gen incoming transactions:" +btc-wire-cli -d $BTC_DIR transfer 0.0042 > /dev/null +next_btc # Trigger btc_wire +check_balance 9.99579209 0.00420000 +echo " OK" + +echo -n "Perform fork and check btc-wire hard error:" +up +btc2_fork +check_balance 9.99579209 0.00000000 +down +echo " OK" + +echo -n "Check btc-wire hard error on restart:" +btc_wire +sleep 1 +down +echo " OK" + +echo -n "Generate conflict:" +restart_btc -minrelaytxfee=0.0001 +btc-wire-cli -d $BTC_DIR abandon client +btc-wire-cli -d $BTC_DIR transfer 0.0054 > /dev/null +next_btc +check_balance 9.99457382 0.00540000 +echo " OK" + +echo -n "Check btc-wire never heal on restart:" +btc_wire +sleep 1 +down +check_balance 9.99457382 0.00540000 +echo " OK" + +echo -n "Check btc-wire have not read the conflicting transaction:" +check_delta "incoming" "" +echo " OK" + +# Recover by paying for the customer ? + +echo "----- Reset -----" +echo "Cleanup" +cleanup +source "${BASH_SOURCE%/*}/../common.sh" +echo "Load config file" +load_config +echo "Start database" +setup_db +echo "Start bitcoin node" +init_btc +echo "Start second bitcoin node" +init_btc2 +echo "Start btc-wire" +btc_wire +echo "Start gateway" +gateway +echo "" + +echo "----- Handle reorg conflicting incoming bounce -----" + +echo "Loose second bitcoin node" +btc2_deco + +echo -n "Generate bounce:" +$BTC_CLI -rpcwallet=client sendtoaddress $WIRE 0.042 > /dev/null +next_btc +sleep 1 +check_balance 9.99998674 0.00001000 +echo " OK" + +echo -n "Perform fork and check btc-wire hard error:" +up +btc2_fork +check_balance 9.95799859 0.00000000 +down +echo " OK" + +echo -n "Check btc-wire hard error on restart:" +btc_wire +sleep 1 +down +echo " OK" + +echo -n "Generate conflict:" +restart_btc -minrelaytxfee=0.0001 +btc-wire-cli -d $BTC_DIR abandon client +btc-wire-cli -d $BTC_DIR transfer 0.054 > /dev/null +next_btc +check_balance 9.94597382 0.05400000 +echo " OK" + +sleep 5 + +echo -n "Check btc-wire never heal on restart:" +btc_wire +sleep 1 +down +check_balance 9.94597382 0.05400000 +echo " OK" + +echo -n "Check btc-wire have not read the conflicting transaction:" +check_delta "incoming" "" +echo " OK" + + +echo "All tests passed"
\ No newline at end of file |