From a59f10c8413fa900fd0d73e2299268328b591126 Mon Sep 17 00:00:00 2001 From: MMGen Date: Mon, 20 May 2019 15:15:13 +0000 Subject: [PATCH] test-release.sh: use strings instead of arrays for cmd lists --- test/test-release.sh | 352 +++++++++++++++++++++++-------------------- 1 file changed, 191 insertions(+), 161 deletions(-) diff --git a/test/test-release.sh b/test/test-release.sh index f899b184..04a00d40 100755 --- a/test/test-release.sh +++ b/test/test-release.sh @@ -146,82 +146,112 @@ install() { ) set +x } + do_test() { set +x - for i in "$@"; do - echo -e "${GREEN}Running:$RESET $YELLOW$i$RESET" - [ "$TESTING" ] || eval "$i" || { - echo -e $RED"Test '$CUR_TEST' failed at command '$i'"$RESET + tests=$(eval echo \"'$'"t_$1"\") + skips=$(eval echo \"'$'"t_$1_skip"\") + + declare -a tests_arr + + n=0 + while read test; do + tests_arr[n]="$test" + let n+=1 + done <<-EOF + $tests + EOF + + n=0 + for test in "${tests_arr[@]}"; do + [ -z "$test" -o "${test:0:1}" == '#' ] && continue + let n+=1 + echo $skips | grep -q "\<$n\>" && continue + echo -e "${GREEN}Running:$RESET $YELLOW$test$RESET" +# continue + [ "$TESTING" ] || eval "$test" || { + echo -e $RED"Test '$CUR_TEST' failed at command '$test'"$RESET exit } done } + i_obj='Data object' s_obj='Testing data objects' -t_obj=( - "$objtest_py --coin=btc" - "$objtest_py --coin=btc --testnet=1" - "$objtest_py --coin=ltc" - "$objtest_py --coin=ltc --testnet=1") +t_obj=" + $objtest_py --coin=btc + $objtest_py --coin=btc --testnet=1 + $objtest_py --coin=ltc + $objtest_py --coin=ltc --testnet=1 +" f_obj='Data object test complete' i_unit='Unit' s_unit='Running unit' -t_unit=("$unit_tests_py") +t_unit="$unit_tests_py" f_unit='Unit tests run complete' i_hash='Internal hash function implementations' s_hash='Testing internal hash function implementations' -t_hash=( - "$python test/hashfunc.py sha256 $rounds_max" - "$python test/hashfunc.py sha512 $rounds_max" - "$python test/hashfunc.py keccak $rounds_max") +t_hash=" + $python test/hashfunc.py sha256 $rounds_max + $python test/hashfunc.py sha512 $rounds_max + $python test/hashfunc.py keccak $rounds_max +" f_hash='Hash function tests complete' i_alts='Gen-only altcoin' s_alts='The following tests will test generation operations for all supported altcoins' -t_alts=( - "$scrambletest_py" - "$test_py ref_altcoin" - "$gentest_py --coin=btc 2 $rounds" - "$gentest_py --coin=btc --type=compressed 2 $rounds" - "$gentest_py --coin=btc --type=segwit 2 $rounds" - "$gentest_py --coin=btc --type=bech32 2 $rounds" - "$gentest_py --coin=ltc 2 $rounds" - "$gentest_py --coin=ltc --type=compressed 2 $rounds" - "$gentest_py --coin=ltc --type=segwit 2 $rounds" - "$gentest_py --coin=ltc --type=bech32 2 $rounds" - "$gentest_py --coin=etc 2 $rounds" - "$gentest_py --coin=etc --use-internal-keccak-module 2 $rounds_min" - "$gentest_py --coin=eth 2 $rounds" - "$gentest_py --coin=eth --use-internal-keccak-module 2 $rounds_min" - "$gentest_py --coin=xmr 2 $rounds" - "$gentest_py --coin=xmr --use-internal-keccak-module 2 $rounds_min" - "$gentest_py --coin=zec 2 $rounds" - "$gentest_py --coin=zec --type=zcash_z 2 $rounds_mid" +t_alts=" + $scrambletest_py + $test_py ref_altcoin # generated addrfiles verified against checksums + $gentest_py --all 2:keyconv $rounds_mid - "$gentest_py --coin=btc 2:ext $rounds" - "$gentest_py --coin=btc --type=compressed 2:ext $rounds" - "$gentest_py --coin=btc --type=segwit 2:ext $rounds" - "$gentest_py --coin=ltc 2:ext $rounds" - "$gentest_py --coin=ltc --type=compressed 2:ext $rounds" -# "$gentest_py --coin=ltc --type=segwit 2:ext $rounds" # pycoin generates old-style LTC Segwit addrs -# "$gentest_py --coin=etc 2:ext $rounds" # no pythereum -# "$gentest_py --coin=eth 2:ext $rounds" - "$gentest_py --coin=zec 2:ext $rounds" - "$gentest_py --coin=zec --type=zcash_z 2:ext $rounds_mid" + # speed tests, no verification + $gentest_py --coin=btc 2 $rounds + $gentest_py --coin=btc --type=compressed 2 $rounds + $gentest_py --coin=btc --type=segwit 2 $rounds + $gentest_py --coin=btc --type=bech32 2 $rounds + $gentest_py --coin=ltc 2 $rounds + $gentest_py --coin=ltc --type=compressed 2 $rounds + $gentest_py --coin=ltc --type=segwit 2 $rounds + $gentest_py --coin=ltc --type=bech32 2 $rounds + $gentest_py --coin=etc 2 $rounds + $gentest_py --coin=etc --use-internal-keccak-module 2 $rounds_min + $gentest_py --coin=eth 2 $rounds + $gentest_py --coin=eth --use-internal-keccak-module 2 $rounds_min + $gentest_py --coin=xmr 2 $rounds + $gentest_py --coin=xmr --use-internal-keccak-module 2 $rounds_min + $gentest_py --coin=zec 2 $rounds +" + +# disabled, pycoin generates old-style LTC Segwit addrs: +# $gentest_py --coin=ltc --type=segwit 2:ext $rounds + +# disabled, no pyethereum: +# $gentest_py --coin=etc 2:ext $rounds +# $gentest_py --coin=eth 2:ext $rounds +# $gentest_py --all 2:pyethereum $rounds + +[ "$MINGW" ] || { + t_alts="$t_alts + $gentest_py --coin=zec --type=zcash_z 2 $rounds_mid + $gentest_py --coin=zec --type=zcash_z 2:ext $rounds_mid + $gentest_py --all 2:zcash_mini $rounds_mid + $gentest_py --all 2:pycoin $rounds + $gentest_py --coin=btc 2:ext $rounds + $gentest_py --coin=btc --type=compressed 2:ext $rounds + $gentest_py --coin=btc --type=segwit 2:ext $rounds + $gentest_py --coin=ltc 2:ext $rounds + $gentest_py --coin=ltc --type=compressed 2:ext $rounds + $gentest_py --coin=zec 2:ext $rounds + " +} - "$gentest_py --all 2:pycoin $rounds" -# "$gentest_py --all 2:pyethereum $rounds" - "$gentest_py --all 2:keyconv $rounds_mid" - "$gentest_py --all 2:zcash_mini $rounds_mid") -if [ "$MINGW" ]; then - t_alts[13]="# MSWin platform: skipping zcash z-addr generation and altcoin verification with third-party tools" - i=14 end=${#t_alts[*]} - while [ $i -lt $end ]; do unset t_alts[$i]; let i++; done -fi f_alts='Gen-only altcoin tests completed' +[ "$NO_TMPFILE_REMOVAL" ] || rm -rf /tmp/mmgen-test-release* + if [ "$MINGW" ]; then TMPDIR='/tmp/mmgen-test-release' else @@ -232,177 +262,177 @@ mkdir -p $TMPDIR i_monero='Monero' s_monero='Testing key-address file generation and wallet creation and sync operations for Monero' s_monero='The monerod (mainnet) daemon must be running for the following tests' -t_monero=( -"mmgen-walletgen -q -r0 -p1 -Llabel --outdir $TMPDIR -o words" -"$mmgen_keygen -q --accept-defaults --use-internal-keccak-module --outdir $TMPDIR --coin=xmr $TMPDIR/*.mmwords $monero_addrs" -'cs1=$(mmgen-tool -q --accept-defaults --coin=xmr keyaddrfile_chksum $TMPDIR/*-XMR*.akeys)' -"$mmgen_keygen -q --use-old-ed25519 --accept-defaults --outdir $TMPDIR --coin=xmr $TMPDIR/*.mmwords $monero_addrs" -'cs2=$(mmgen-tool -q --accept-defaults --coin=xmr keyaddrfile_chksum $TMPDIR/*-XMR*.akeys)' -'[ "$cs1" == "$cs2" ] || false' -"$mmgen_tool -q --accept-defaults --outdir $TMPDIR keyaddrlist2monerowallets $TMPDIR/*-XMR*.akeys addrs=23" -"$mmgen_tool -q --accept-defaults --outdir $TMPDIR keyaddrlist2monerowallets $TMPDIR/*-XMR*.akeys addrs=103-200" -'rm $TMPDIR/*-MoneroWallet*' -"$mmgen_tool -q --accept-defaults --outdir $TMPDIR keyaddrlist2monerowallets $TMPDIR/*-XMR*.akeys" -"$mmgen_tool -q --accept-defaults --outdir $TMPDIR syncmonerowallets $TMPDIR/*-XMR*.akeys addrs=3" -"$mmgen_tool -q --accept-defaults --outdir $TMPDIR syncmonerowallets $TMPDIR/*-XMR*.akeys addrs=23-29" -"$mmgen_tool -q --accept-defaults --outdir $TMPDIR syncmonerowallets $TMPDIR/*-XMR*.akeys" -) -[ "$MINGW" ] && { - t_monero[2]="# MSWin platform: skipping Monero wallet creation and sync tests; NOT verifying key-addr list" - i=3 end=${#t_monero[*]} - while [ $i -lt $end ]; do unset t_monero[$i]; let i++; done -} -[ "$monero_addrs" == '3,23' ] && { - unset t_monero[12] - unset t_monero[7] - unset t_monero[3] -} +t_monero=" + mmgen-walletgen -q -r0 -p1 -Llabel --outdir $TMPDIR -o words + $mmgen_keygen -q --accept-defaults --use-internal-keccak-module --outdir $TMPDIR --coin=xmr $TMPDIR/*.mmwords $monero_addrs + cs1=\$(mmgen-tool -q --accept-defaults --coin=xmr keyaddrfile_chksum $TMPDIR/*-XMR*.akeys) + $mmgen_keygen -q --use-old-ed25519 --accept-defaults --outdir $TMPDIR --coin=xmr $TMPDIR/*.mmwords $monero_addrs + cs2=\$(mmgen-tool -q --accept-defaults --coin=xmr keyaddrfile_chksum $TMPDIR/*-XMR*.akeys) + [ \"\$cs1\" == \"\$cs2\" ] +" f_monero='Monero tests completed' +[ "$MINGW" ] || { + t_monero="$t_monero +$mmgen_tool -q --accept-defaults --outdir $TMPDIR keyaddrlist2monerowallets $TMPDIR/*-XMR*.akeys addrs=23 +$mmgen_tool -q --accept-defaults --outdir $TMPDIR keyaddrlist2monerowallets $TMPDIR/*-XMR*.akeys addrs=103-200 +rm $TMPDIR/*-MoneroWallet* +$mmgen_tool -q --accept-defaults --outdir $TMPDIR keyaddrlist2monerowallets $TMPDIR/*-XMR*.akeys +$mmgen_tool -q --accept-defaults --outdir $TMPDIR syncmonerowallets $TMPDIR/*-XMR*.akeys addrs=3 +$mmgen_tool -q --accept-defaults --outdir $TMPDIR syncmonerowallets $TMPDIR/*-XMR*.akeys addrs=23-29 +$mmgen_tool -q --accept-defaults --outdir $TMPDIR syncmonerowallets $TMPDIR/*-XMR*.akeys + " +} + +[ "$monero_addrs" == '3,23' ] && t_monero_skip='4 8 13' + i_eth='Ethereum' s_eth='Testing transaction and tracking wallet operations for Ethereum and Ethereum Classic' -t_eth=( - "$test_py --coin=eth ethdev" - "$test_py --coin=etc ethdev" -) +t_eth=" + $test_py --coin=eth ethdev + $test_py --coin=etc ethdev +" f_eth='Ethereum tests completed' i_autosign='Autosign' s_autosign='The bitcoin, bitcoin-abc and litecoin mainnet and testnet daemons must be running for the following test' -t_autosign=("$test_py autosign") +t_autosign="$test_py autosign" f_autosign='Autosign test complete' i_autosign_minimal='Autosign Minimal' s_autosign_minimal='The bitcoin mainnet and testnet daemons must be running for the following test' -t_autosign_minimal=("$test_py autosign_minimal") +t_autosign_minimal="$test_py autosign_minimal" f_autosign_minimal='Autosign Minimal test complete' i_autosign_live='Autosign Live' s_autosign_live="The bitcoin mainnet and testnet daemons must be running for the following test\n" s_autosign_live+="${YELLOW}Mountpoint, '/etc/fstab' and removable device must be configured " s_autosign_live+="as described in 'mmgen-autosign --help'${RESET}" -t_autosign_live=("$test_py autosign_live") +t_autosign_live="$test_py autosign_live" f_autosign_live='Autosign Live test complete' i_btc='Bitcoin mainnet' s_btc='The bitcoin (mainnet) daemon must both be running for the following tests' -t_btc=( - "$test_py --exclude regtest" - "$test_py --segwit" - "$test_py --segwit-random" - "$test_py --bech32" - "$python scripts/compute-file-chksum.py $REFDIR/*testnet.rawtx >/dev/null 2>&1") +t_btc=" + $test_py --exclude regtest + $test_py --segwit + $test_py --segwit-random + $test_py --bech32 + $python scripts/compute-file-chksum.py $REFDIR/*testnet.rawtx >/dev/null 2>&1 +" f_btc='You may stop the bitcoin (mainnet) daemon if you wish' i_btc_tn='Bitcoin testnet' s_btc_tn='The bitcoin testnet daemon must both be running for the following tests' -t_btc_tn=( - "$test_py --testnet=1" - "$test_py --testnet=1 --segwit" - "$test_py --testnet=1 --segwit-random" - "$test_py --testnet=1 --bech32") +t_btc_tn=" + $test_py --testnet=1 + $test_py --testnet=1 --segwit + $test_py --testnet=1 --segwit-random + $test_py --testnet=1 --bech32 +" f_btc_tn='You may stop the bitcoin testnet daemon if you wish' i_btc_rt='Bitcoin regtest' s_btc_rt="The following tests will test MMGen's regtest (Bob and Alice) mode" -t_btc_rt=( - "$test_py regtest" - ) +t_btc_rt="$test_py regtest" f_btc_rt='Regtest (Bob and Alice) mode tests for BTC completed' i_bch='Bitcoin cash (BCH)' s_bch='The bitcoin cash daemon (Bitcoin ABC) must both be running for the following tests' -t_bch=("$test_py --coin=bch --exclude regtest") +t_bch="$test_py --coin=bch --exclude regtest" f_bch='You may stop the Bitcoin ABC daemon if you wish' i_bch_rt='Bitcoin cash (BCH) regtest' s_bch_rt="The following tests will test MMGen's regtest (Bob and Alice) mode" -t_bch_rt=("$test_py --coin=bch regtest") +t_bch_rt="$test_py --coin=bch regtest" f_bch_rt='Regtest (Bob and Alice) mode tests for BCH completed' i_ltc='Litecoin' s_ltc='The litecoin daemon must both be running for the following tests' -t_ltc=( - "$test_py --coin=ltc --exclude regtest" - "$test_py --coin=ltc --segwit" - "$test_py --coin=ltc --segwit-random" - "$test_py --coin=ltc --bech32") +t_ltc=" + $test_py --coin=ltc --exclude regtest + $test_py --coin=ltc --segwit + $test_py --coin=ltc --segwit-random + $test_py --coin=ltc --bech32 +" f_ltc='You may stop the litecoin daemon if you wish' i_ltc_tn='Litecoin testnet' s_ltc_tn='The litecoin testnet daemon must both be running for the following tests' -t_ltc_tn=( - "$test_py --coin=ltc --testnet=1 --exclude regtest" - "$test_py --coin=ltc --testnet=1 --segwit" - "$test_py --coin=ltc --testnet=1 --segwit-random" - "$test_py --coin=ltc --testnet=1 --bech32") +t_ltc_tn=" + $test_py --coin=ltc --testnet=1 --exclude regtest + $test_py --coin=ltc --testnet=1 --segwit + $test_py --coin=ltc --testnet=1 --segwit-random + $test_py --coin=ltc --testnet=1 --bech32 +" f_ltc_tn='You may stop the litecoin testnet daemon if you wish' i_ltc_rt='Litecoin regtest' s_ltc_rt="The following tests will test MMGen's regtest (Bob and Alice) mode" -t_ltc_rt=("$test_py --coin=ltc regtest") +t_ltc_rt="$test_py --coin=ltc regtest" f_ltc_rt='Regtest (Bob and Alice) mode tests for LTC completed' i_tool2='Tooltest2' s_tool2="The following tests will run '$tooltest2_py' for all supported coins" -t_tool2=( - "$tooltest2_py --quiet" - "$tooltest2_py --quiet --coin=btc" - "$tooltest2_py --quiet --coin=btc --testnet=1" - "$tooltest2_py --quiet --coin=ltc" - "$tooltest2_py --quiet --coin=ltc --testnet=1" - "$tooltest2_py --quiet --coin=bch" - "$tooltest2_py --quiet --coin=bch --testnet=1" - "$tooltest2_py --quiet --coin=zec" - "$tooltest2_py --quiet --coin=zec --type=zcash_z" - "$tooltest2_py --quiet --coin=xmr" - "$tooltest2_py --quiet --coin=dash" - "$tooltest2_py --quiet --coin=eth" - "$tooltest2_py --quiet --coin=eth --testnet=1" - "$tooltest2_py --quiet --coin=eth --token=mm1" - "$tooltest2_py --quiet --coin=eth --token=mm1 --testnet=1" - "$tooltest2_py --quiet --coin=etc") +t_tool2=" + $tooltest2_py --quiet + $tooltest2_py --quiet --coin=btc + $tooltest2_py --quiet --coin=btc --testnet=1 + $tooltest2_py --quiet --coin=ltc + $tooltest2_py --quiet --coin=ltc --testnet=1 + $tooltest2_py --quiet --coin=bch + $tooltest2_py --quiet --coin=bch --testnet=1 + $tooltest2_py --quiet --coin=zec + $tooltest2_py --quiet --coin=zec --type=zcash_z + $tooltest2_py --quiet --coin=xmr + $tooltest2_py --quiet --coin=dash + $tooltest2_py --quiet --coin=eth + $tooltest2_py --quiet --coin=eth --testnet=1 + $tooltest2_py --quiet --coin=eth --token=mm1 + $tooltest2_py --quiet --coin=eth --token=mm1 --testnet=1 + $tooltest2_py --quiet --coin=etc +" f_tool2='tooltest2 tests completed' i_tool='Tooltest' s_tool="The following tests will run '$tooltest_py' for all supported coins" -t_tool=( - "$tooltest_py --coin=btc cryptocoin" - "$tooltest_py --coin=btc mnemonic" - "$tooltest_py --coin=ltc cryptocoin" - "$tooltest_py --coin=eth cryptocoin" - "$tooltest_py --coin=etc cryptocoin" - "$tooltest_py --coin=dash cryptocoin" - "$tooltest_py --coin=doge cryptocoin" - "$tooltest_py --coin=emc cryptocoin" - "$tooltest_py --coin=zec cryptocoin") +t_tool=" + $tooltest_py --coin=btc cryptocoin + $tooltest_py --coin=btc mnemonic + $tooltest_py --coin=ltc cryptocoin + $tooltest_py --coin=eth cryptocoin + $tooltest_py --coin=etc cryptocoin + $tooltest_py --coin=dash cryptocoin + $tooltest_py --coin=doge cryptocoin + $tooltest_py --coin=emc cryptocoin + $tooltest_py --coin=zec cryptocoin + $tooltest_py --coin=zec --type=zcash_z cryptocoin +" +[ "$MINGW" ] && t_tool_skip='10' -[ "$MINGW" ] || { - t_tool_len=${#t_tool[*]} - t_tool[$t_tool_len]="$tooltest_py --coin=zec --type=zcash_z cryptocoin" -} f_tool='tooltest tests completed' i_gen='Gentest' s_gen="The following tests will run '$gentest_py' on mainnet and testnet for all supported coins" -t_gen=( - "$gentest_py -q 2 $REFDIR/btcwallet.dump" - "$gentest_py -q --type=segwit 2 $REFDIR/btcwallet-segwit.dump" - "$gentest_py -q --type=bech32 2 $REFDIR/btcwallet-bech32.dump" - "$gentest_py -q 1:2 $rounds" - "$gentest_py -q --type=segwit 1:2 $rounds" - "$gentest_py -q --type=bech32 1:2 $rounds" - "$gentest_py -q --testnet=1 2 $REFDIR/btcwallet-testnet.dump" - "$gentest_py -q --testnet=1 1:2 $rounds" - "$gentest_py -q --testnet=1 --type=segwit 1:2 $rounds" - "$gentest_py -q --coin=ltc 2 $REFDIR/litecoin/ltcwallet.dump" - "$gentest_py -q --coin=ltc --type=segwit 2 $REFDIR/litecoin/ltcwallet-segwit.dump" - "$gentest_py -q --coin=ltc --type=bech32 2 $REFDIR/litecoin/ltcwallet-bech32.dump" - "$gentest_py -q --coin=ltc 1:2 $rounds" - "$gentest_py -q --coin=ltc --type=segwit 1:2 $rounds" - "$gentest_py -q --coin=ltc --testnet=1 2 $REFDIR/litecoin/ltcwallet-testnet.dump" - "$gentest_py -q --coin=ltc --testnet=1 1:2 $rounds" - "$gentest_py -q --coin=ltc --testnet=1 --type=segwit 1:2 $rounds") +t_gen=" + $gentest_py -q 2 $REFDIR/btcwallet.dump + $gentest_py -q --type=segwit 2 $REFDIR/btcwallet-segwit.dump + $gentest_py -q --type=bech32 2 $REFDIR/btcwallet-bech32.dump + $gentest_py -q 1:2 $rounds + $gentest_py -q --type=segwit 1:2 $rounds + $gentest_py -q --type=bech32 1:2 $rounds + $gentest_py -q --testnet=1 2 $REFDIR/btcwallet-testnet.dump + $gentest_py -q --testnet=1 1:2 $rounds + $gentest_py -q --testnet=1 --type=segwit 1:2 $rounds + $gentest_py -q --coin=ltc 2 $REFDIR/litecoin/ltcwallet.dump + $gentest_py -q --coin=ltc --type=segwit 2 $REFDIR/litecoin/ltcwallet-segwit.dump + $gentest_py -q --coin=ltc --type=bech32 2 $REFDIR/litecoin/ltcwallet-bech32.dump + $gentest_py -q --coin=ltc 1:2 $rounds + $gentest_py -q --coin=ltc --type=segwit 1:2 $rounds + $gentest_py -q --coin=ltc --testnet=1 2 $REFDIR/litecoin/ltcwallet-testnet.dump + $gentest_py -q --coin=ltc --testnet=1 1:2 $rounds + $gentest_py -q --coin=ltc --testnet=1 --type=segwit 1:2 $rounds +" f_gen='gentest tests completed' [ -d .git -a -n "$INSTALL" -a -z "$TESTING" ] && { @@ -425,7 +455,7 @@ run_tests() { eval echo -e $(echo \$s_$t) [ "$PAUSE" ] && prompt_skip && continue CUR_TEST=$t - eval "do_test \"\${t_$t[@]}\"" + do_test $t eval echo -e \$GREEN$(echo \$f_$t)\$RESET done }