test-release.sh 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. #!/bin/bash
  2. # Tested on Linux, Armbian, Raspbian, MSYS2
  3. REFDIR='test/ref'
  4. SUDO='sudo'
  5. if [ "$(uname -m)" == 'armv7l' ]; then
  6. ARM32=1
  7. elif uname -a | grep -q 'MSYS'; then
  8. SUDO='' MSYS2=1;
  9. fi
  10. RED="\e[31;1m" GREEN="\e[32;1m" YELLOW="\e[33;1m" BLUE="\e[34;1m" MAGENTA="\e[35;1m" CYAN="\e[36;1m"
  11. RESET="\e[0m"
  12. trap 'echo -e "${GREEN}Exiting at user request$RESET"; exit' INT
  13. umask 0022
  14. export MMGEN_TEST_SUITE=1
  15. export MMGEN_NO_LICENSE=1
  16. export PYTHONPATH=.
  17. test_py='test/test.py -n'
  18. objtest_py='test/objtest.py'
  19. objattrtest_py='test/objattrtest.py'
  20. colortest_py='test/colortest.py'
  21. unit_tests_py='test/unit_tests.py --names --quiet'
  22. tooltest_py='test/tooltest.py'
  23. tooltest2_py='test/tooltest2.py --names --quiet'
  24. gentest_py='test/gentest.py --quiet'
  25. scrambletest_py='test/scrambletest.py'
  26. mmgen_tool='cmds/mmgen-tool'
  27. mmgen_keygen='cmds/mmgen-keygen'
  28. python='python3'
  29. rounds=100 rounds_min=20 rounds_mid=250 rounds_max=500
  30. monero_addrs='3,99,2,22-24,101-104'
  31. dfl_tests='obj color unit hash ref alts monero eth autosign btc btc_tn btc_rt bch bch_rt ltc ltc_tn ltc_rt tool tool2 gen'
  32. add_tests='autosign_minimal autosign_live'
  33. PROGNAME=$(basename $0)
  34. while getopts hbCfFiIlOpRtvV OPT
  35. do
  36. case "$OPT" in
  37. h) printf " %-16s Test MMGen release\n" "${PROGNAME}:"
  38. echo " USAGE: $PROGNAME [options] [tests]"
  39. echo " OPTIONS: '-h' Print this help message"
  40. echo " '-b' Buffer keypresses for all invocations of 'test/test.py'"
  41. echo " '-C' Run tests in coverage mode"
  42. echo " '-f' Speed up the tests by using fewer rounds"
  43. echo " '-F' Reduce rounds even further"
  44. echo " '-i' Create and install Python package, then run tests. A branch"
  45. echo " must be supplied as the first argument"
  46. echo " '-I' Install the package only; don't run tests"
  47. echo " '-l' List the test name symbols"
  48. echo " '-O' Use pexpect.spawn rather than popen_spawn for applicable tests"
  49. echo " '-p' Pause between tests"
  50. echo " '-R' Don't remove temporary files after program has exited"
  51. echo " '-t' Print the tests without running them"
  52. echo " '-v' Run test/test.py with '--exact-output' and other commands with"
  53. echo " '--verbose' switch"
  54. echo " '-V' Run test/test.py and other commands with '--verbose' switch"
  55. echo " AVAILABLE TESTS:"
  56. echo " obj - data objects"
  57. echo " color - color handling"
  58. echo " unit - unit tests"
  59. echo " hash - internal hash function implementations"
  60. echo " alts - operations for all supported gen-only altcoins"
  61. echo " monero - operations for Monero"
  62. echo " eth - operations for Ethereum"
  63. echo " autosign - autosign"
  64. echo " btc - bitcoin"
  65. echo " btc_tn - bitcoin testnet"
  66. echo " btc_rt - bitcoin regtest"
  67. echo " bch - bitcoin cash (BCH)"
  68. echo " bch_rt - bitcoin cash (BCH) regtest"
  69. echo " ltc - litecoin"
  70. echo " ltc_tn - litecoin testnet"
  71. echo " ltc_rt - litecoin regtest"
  72. echo " tool - tooltest (all supported coins)"
  73. echo " tool2 - tooltest2 (all supported coins)"
  74. echo " gen - gentest (all supported coins)"
  75. echo " By default, all tests are run"
  76. exit ;;
  77. b) test_py+=" --buf-keypress" ;;
  78. C) mkdir -p 'test/trace'
  79. touch 'test/trace.acc'
  80. test_py+=" --coverage"
  81. tooltest_py+=" --coverage"
  82. tooltest2_py+=" --fork --coverage"
  83. scrambletest_py+=" --coverage"
  84. python="python3 -m trace --count --file=test/trace.acc --coverdir=test/trace"
  85. unit_tests_py="$python $unit_tests_py"
  86. objtest_py="$python $objtest_py"
  87. objattrtest_py="$python $objattrtest_py"
  88. gentest_py="$python $gentest_py"
  89. mmgen_tool="$python $mmgen_tool"
  90. mmgen_keygen="$python $mmgen_keygen" ;&
  91. f) FAST=1 rounds=10 rounds_min=3 rounds_mid=25 rounds_max=50 monero_addrs='3,23' unit_tests_py+=" --fast" ;;
  92. F) FAST=1 rounds=3 rounds_min=1 rounds_mid=3 rounds_max=5 monero_addrs='3,23' unit_tests_py+=" --fast" ;;
  93. i) INSTALL=1 ;;
  94. I) INSTALL_ONLY=1 ;;
  95. l) echo -e "Default tests:\n $dfl_tests"
  96. echo -e "Additional tests:\n $add_tests"
  97. exit ;;
  98. O) test_py+=" --pexpect-spawn" ;;
  99. p) PAUSE=1 ;;
  100. R) NO_TMPFILE_REMOVAL=1 ;;
  101. t) TESTING=1 ;;
  102. v) EXACT_OUTPUT=1 test_py+=" --exact-output" ;&
  103. V) VERBOSE=1 [ "$EXACT_OUTPUT" ] || test_py+=" --verbose"
  104. unit_tests_py="${unit_tests_py/--quiet/--verbose}"
  105. tooltest2_py="${tooltest2_py/--quiet/--verbose}"
  106. gentest_py="${gentest_py/--quiet/--verbose}"
  107. tooltest_py+=" --verbose"
  108. mmgen_tool+=" --verbose"
  109. objattrtest_py+=" --verbose"
  110. scrambletest_py+=" --verbose" ;;
  111. *) exit ;;
  112. esac
  113. done
  114. [ "$MSYS2" -a ! "$FAST" ] && tooltest2_py+=' --fork'
  115. [ "$EXACT_OUTPUT" -o "$VERBOSE" ] || objtest_py+=" -S"
  116. shift $((OPTIND-1))
  117. [ "$INSTALL" ] && {
  118. BRANCH=$1; shift
  119. BRANCHES=$(git branch)
  120. FOUND_BRANCH=$(for b in ${BRANCHES/\*}; do [ "$b" == "$BRANCH" ] && echo ok; done)
  121. [ "$FOUND_BRANCH" ] || { echo "Branch '$BRANCH' not found!"; exit; }
  122. }
  123. set -e
  124. check() {
  125. [ "$BRANCH" ] || { echo 'No branch specified. Exiting'; exit; }
  126. [ "$(git diff $BRANCH)" == "" ] || {
  127. echo "Unmerged changes from branch '$BRANCH'. Exiting"
  128. exit
  129. }
  130. git diff $BRANCH >/dev/null 2>&1 || exit
  131. }
  132. uninstall() {
  133. set +e
  134. eval "$SUDO ./scripts/uninstall-mmgen.py"
  135. [ "$?" -ne 0 ] && { echo 'Uninstall failed, but proceeding anyway'; sleep 1; }
  136. set -e
  137. }
  138. install() {
  139. set -x
  140. eval "$SUDO rm -rf .test-release"
  141. git clone --branch $BRANCH --single-branch . .test-release
  142. (
  143. cd .test-release
  144. ./setup.py sdist
  145. mkdir pydist && cd pydist
  146. if [ "$MSYS2" ]; then unzip ../dist/mmgen-*.zip; else tar zxvf ../dist/mmgen-*gz; fi
  147. cd mmgen-*
  148. eval "$SUDO ./setup.py clean --all"
  149. [ "$MSYS2" ] && ./setup.py build --compiler=mingw32
  150. eval "$SUDO ./setup.py install --force"
  151. )
  152. set +x
  153. }
  154. do_test() {
  155. set +x
  156. tests=$(eval echo \"'$'"t_$1"\")
  157. skips=$(eval echo \"'$'"t_$1_skip"\")
  158. declare -a tests_arr
  159. n=0
  160. while read test; do
  161. tests_arr[n]="$test"
  162. let n+=1
  163. done <<-EOF
  164. $tests
  165. EOF
  166. n=0
  167. for test in "${tests_arr[@]}"; do
  168. [ -z "$test" ] && continue
  169. test_disp=$YELLOW${test/\#/$RESET$MAGENTA\#}$RESET
  170. [ "${test:0:1}" == '#' ] && { echo -e "$test_disp"; continue; }
  171. let n+=1
  172. echo $skips | grep -q "\<$n\>" && continue
  173. echo -e "${GREEN}Running:$RESET $test_disp"
  174. # continue
  175. [ "$TESTING" ] || eval "$test" || {
  176. echo -e $RED"test-release.sh: test '$CUR_TEST' failed at command '$test'"$RESET
  177. exit 1
  178. }
  179. done
  180. }
  181. i_obj='Data object'
  182. s_obj='Testing data objects'
  183. t_obj="
  184. $objtest_py --coin=btc
  185. $objtest_py --coin=btc --testnet=1
  186. $objtest_py --coin=ltc
  187. $objtest_py --coin=ltc --testnet=1
  188. $objtest_py --coin=eth
  189. $objattrtest_py
  190. "
  191. f_obj='Data object test complete'
  192. i_color='Color'
  193. s_color='Running color'
  194. t_color="$colortest_py"
  195. f_color='Color tests complete'
  196. i_unit='Unit'
  197. s_unit='Running unit'
  198. t_unit="$unit_tests_py"
  199. f_unit='Unit tests run complete'
  200. i_hash='Internal hash function implementations'
  201. s_hash='Testing internal hash function implementations'
  202. t_hash="
  203. $python test/hashfunc.py sha256 $rounds_max
  204. $python test/hashfunc.py sha512 $rounds_max # native sha512 - not used by MMGen
  205. $python test/hashfunc.py keccak $rounds_max
  206. "
  207. f_hash='Hash function tests complete'
  208. [ "$ARM32" ] && t_hash_skip='2' # gmpy produces invalid init constants
  209. [ "$MSYS2" ] && t_hash_skip='2 3' # 2:py_long_long issues, 3:no pysha3 for keccak reference
  210. i_ref='Miscellaneous reference data tests'
  211. s_ref='The following tests will test some generated values against reference data'
  212. t_ref="
  213. $scrambletest_py
  214. $test_py ref_altcoin # generated addrfiles verified against checksums
  215. "
  216. f_ref='Miscellaneous reference data tests completed'
  217. i_alts='Gen-only altcoin'
  218. s_alts='The following tests will test generation operations for all supported altcoins'
  219. t_alts="
  220. # speed tests, no verification:
  221. $gentest_py --coin=btc 2 $rounds
  222. $gentest_py --coin=btc --type=compressed 2 $rounds
  223. $gentest_py --coin=btc --type=segwit 2 $rounds
  224. $gentest_py --coin=btc --type=bech32 2 $rounds
  225. $gentest_py --coin=ltc 2 $rounds
  226. $gentest_py --coin=ltc --type=compressed 2 $rounds
  227. $gentest_py --coin=ltc --type=segwit 2 $rounds
  228. $gentest_py --coin=ltc --type=bech32 2 $rounds
  229. $gentest_py --coin=etc 2 $rounds
  230. $gentest_py --coin=etc --use-internal-keccak-module 2 $rounds_min
  231. $gentest_py --coin=eth 2 $rounds
  232. $gentest_py --coin=eth --use-internal-keccak-module 2 $rounds_min
  233. $gentest_py --coin=xmr 2 $rounds
  234. $gentest_py --coin=xmr --use-internal-keccak-module 2 $rounds_min
  235. $gentest_py --coin=zec 2 $rounds
  236. $gentest_py --coin=zec --type=zcash_z 2 $rounds_mid
  237. # verification against external libraries and tools:
  238. $gentest_py --all --type=legacy 2:keyconv $rounds
  239. $gentest_py --all --type=compressed 2:keyconv $rounds
  240. $gentest_py --all --coin=xmr 2:moneropy $rounds_min # very slow, be patient!
  241. "
  242. [ "$MSYS2" ] || { # no pycoin (libsecp256k1), zcash-mini (golang), ethkey (?)
  243. t_alts="$t_alts
  244. $gentest_py --all --type=legacy 2:pycoin $rounds
  245. $gentest_py --all --type=compressed 2:pycoin $rounds
  246. $gentest_py --all --type=segwit 2:pycoin $rounds
  247. $gentest_py --all --type=bech32 2:pycoin $rounds
  248. $gentest_py --all --type=legacy --testnet=1 2:pycoin $rounds
  249. $gentest_py --all --type=compressed --testnet=1 2:pycoin $rounds
  250. $gentest_py --all --type=segwit --testnet=1 2:pycoin $rounds
  251. $gentest_py --all --type=bech32 --testnet=1 2:pycoin $rounds
  252. $gentest_py --all 2:zcash-mini $rounds_mid
  253. $gentest_py --all 2:ethkey $rounds
  254. "
  255. }
  256. f_alts='Gen-only altcoin tests completed'
  257. [ "$NO_TMPFILE_REMOVAL" ] || rm -rf /tmp/mmgen-test-release*
  258. if [ "$MSYS2" ]; then
  259. TMPDIR='/tmp/mmgen-test-release'
  260. else
  261. TMPDIR='/tmp/mmgen-test-release-'$(cat /dev/urandom | base32 - | head -n1 | cut -b 1-16)
  262. fi
  263. mkdir -p $TMPDIR
  264. i_monero='Monero'
  265. s_monero='Testing key-address file generation and wallet creation and sync operations for Monero'
  266. s_monero='The monerod (mainnet) daemon must be running for the following tests'
  267. t_monero="
  268. mmgen-walletgen -q -r0 -p1 -Llabel --outdir $TMPDIR -o words
  269. $mmgen_keygen -q --accept-defaults --use-internal-keccak-module --outdir $TMPDIR --coin=xmr $TMPDIR/*.mmwords $monero_addrs
  270. cs1=\$(mmgen-tool -q --accept-defaults --coin=xmr keyaddrfile_chksum $TMPDIR/*-XMR*.akeys)
  271. $mmgen_keygen -q --use-old-ed25519 --accept-defaults --outdir $TMPDIR --coin=xmr $TMPDIR/*.mmwords $monero_addrs
  272. cs2=\$(mmgen-tool -q --accept-defaults --coin=xmr keyaddrfile_chksum $TMPDIR/*-XMR*.akeys)
  273. [ \"\$cs1\" == \"\$cs2\" ]
  274. "
  275. f_monero='Monero tests completed'
  276. [ "$MSYS2" ] || { # password file descriptor issues, cannot use popen_spawn()
  277. t_monero="$t_monero
  278. $mmgen_tool -q --accept-defaults --outdir $TMPDIR keyaddrlist2monerowallets $TMPDIR/*-XMR*.akeys addrs=23
  279. $mmgen_tool -q --accept-defaults --outdir $TMPDIR keyaddrlist2monerowallets $TMPDIR/*-XMR*.akeys addrs=103-200
  280. rm $TMPDIR/*-MoneroWallet*
  281. $mmgen_tool -q --accept-defaults --outdir $TMPDIR keyaddrlist2monerowallets $TMPDIR/*-XMR*.akeys
  282. $mmgen_tool -q --accept-defaults --outdir $TMPDIR syncmonerowallets $TMPDIR/*-XMR*.akeys addrs=3
  283. $mmgen_tool -q --accept-defaults --outdir $TMPDIR syncmonerowallets $TMPDIR/*-XMR*.akeys addrs=23-29
  284. $mmgen_tool -q --accept-defaults --outdir $TMPDIR syncmonerowallets $TMPDIR/*-XMR*.akeys
  285. "
  286. }
  287. [ "$monero_addrs" == '3,23' ] && t_monero_skip='4 8 13'
  288. i_eth='Ethereum'
  289. s_eth='Testing transaction and tracking wallet operations for Ethereum and Ethereum Classic'
  290. t_eth="
  291. $test_py --coin=eth ethdev
  292. $test_py --coin=etc ethdev
  293. "
  294. f_eth='Ethereum tests completed'
  295. i_autosign='Autosign'
  296. s_autosign='The bitcoin, bitcoin-abc and litecoin mainnet and testnet daemons must be running for the following test'
  297. t_autosign="$test_py autosign"
  298. f_autosign='Autosign test complete'
  299. i_autosign_minimal='Autosign Minimal'
  300. s_autosign_minimal='The bitcoin mainnet and testnet daemons must be running for the following test'
  301. t_autosign_minimal="$test_py autosign_minimal"
  302. f_autosign_minimal='Autosign Minimal test complete'
  303. i_autosign_live='Autosign Live'
  304. s_autosign_live="The bitcoin mainnet and testnet daemons must be running for the following test\n"
  305. s_autosign_live+="${YELLOW}Mountpoint, '/etc/fstab' and removable device must be configured "
  306. s_autosign_live+="as described in 'mmgen-autosign --help'${RESET}"
  307. t_autosign_live="$test_py autosign_live"
  308. f_autosign_live='Autosign Live test complete'
  309. i_btc='Bitcoin mainnet'
  310. s_btc='The bitcoin (mainnet) daemon must both be running for the following tests'
  311. t_btc="
  312. $test_py --exclude regtest,autosign_minimal
  313. $test_py --segwit
  314. $test_py --segwit-random
  315. $test_py --bech32
  316. $python scripts/compute-file-chksum.py $REFDIR/*testnet.rawtx >/dev/null 2>&1
  317. "
  318. f_btc='You may stop the bitcoin (mainnet) daemon if you wish'
  319. i_btc_tn='Bitcoin testnet'
  320. s_btc_tn='The bitcoin testnet daemon must both be running for the following tests'
  321. t_btc_tn="
  322. $test_py --testnet=1
  323. $test_py --testnet=1 --segwit
  324. $test_py --testnet=1 --segwit-random
  325. $test_py --testnet=1 --bech32
  326. "
  327. f_btc_tn='You may stop the bitcoin testnet daemon if you wish'
  328. i_btc_rt='Bitcoin regtest'
  329. s_btc_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  330. t_btc_rt="$test_py regtest"
  331. f_btc_rt='Regtest (Bob and Alice) mode tests for BTC completed'
  332. i_bch='Bitcoin cash (BCH)'
  333. s_bch='The bitcoin cash daemon (Bitcoin ABC) must both be running for the following tests'
  334. t_bch="$test_py --coin=bch --exclude regtest"
  335. f_bch='You may stop the Bitcoin ABC daemon if you wish'
  336. i_bch_rt='Bitcoin cash (BCH) regtest'
  337. s_bch_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  338. t_bch_rt="$test_py --coin=bch regtest"
  339. f_bch_rt='Regtest (Bob and Alice) mode tests for BCH completed'
  340. i_ltc='Litecoin'
  341. s_ltc='The litecoin daemon must both be running for the following tests'
  342. t_ltc="
  343. $test_py --coin=ltc --exclude regtest
  344. $test_py --coin=ltc --segwit
  345. $test_py --coin=ltc --segwit-random
  346. $test_py --coin=ltc --bech32
  347. "
  348. f_ltc='You may stop the litecoin daemon if you wish'
  349. i_ltc_tn='Litecoin testnet'
  350. s_ltc_tn='The litecoin testnet daemon must both be running for the following tests'
  351. t_ltc_tn="
  352. $test_py --coin=ltc --testnet=1 --exclude regtest
  353. $test_py --coin=ltc --testnet=1 --segwit
  354. $test_py --coin=ltc --testnet=1 --segwit-random
  355. $test_py --coin=ltc --testnet=1 --bech32
  356. "
  357. f_ltc_tn='You may stop the litecoin testnet daemon if you wish'
  358. i_ltc_rt='Litecoin regtest'
  359. s_ltc_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  360. t_ltc_rt="$test_py --coin=ltc regtest"
  361. f_ltc_rt='Regtest (Bob and Alice) mode tests for LTC completed'
  362. i_tool2='Tooltest2'
  363. s_tool2="The following tests will run '$tooltest2_py' for all supported coins"
  364. t_tool2="
  365. $tooltest2_py --fork # run once with --fork so commands are actually executed
  366. $tooltest2_py
  367. $tooltest2_py --testnet=1
  368. $tooltest2_py --coin=ltc
  369. $tooltest2_py --coin=ltc --testnet=1
  370. $tooltest2_py --coin=bch
  371. $tooltest2_py --coin=bch --testnet=1
  372. $tooltest2_py --coin=zec
  373. $tooltest2_py --coin=zec --type=zcash_z
  374. $tooltest2_py --coin=xmr
  375. $tooltest2_py --coin=dash
  376. $tooltest2_py --coin=eth
  377. $tooltest2_py --coin=eth --testnet=1
  378. $tooltest2_py --coin=eth --token=mm1
  379. $tooltest2_py --coin=eth --token=mm1 --testnet=1
  380. $tooltest2_py --coin=etc
  381. "
  382. f_tool2='tooltest2 tests completed'
  383. i_tool='Tooltest'
  384. s_tool="The following tests will run '$tooltest_py' for all supported coins"
  385. t_tool="
  386. $tooltest_py --coin=btc cryptocoin
  387. $tooltest_py --coin=btc mnemonic
  388. $tooltest_py --coin=ltc cryptocoin
  389. $tooltest_py --coin=eth cryptocoin
  390. $tooltest_py --coin=etc cryptocoin
  391. $tooltest_py --coin=dash cryptocoin
  392. $tooltest_py --coin=doge cryptocoin
  393. $tooltest_py --coin=emc cryptocoin
  394. $tooltest_py --coin=zec cryptocoin
  395. $tooltest_py --coin=zec --type=zcash_z cryptocoin
  396. "
  397. [ "$MSYS2" ] && t_tool_skip='10'
  398. f_tool='tooltest tests completed'
  399. i_gen='Gentest'
  400. s_gen="The following tests will run '$gentest_py' on mainnet and testnet for all supported coins"
  401. t_gen="
  402. # wallet dumps:
  403. $gentest_py 2 $REFDIR/btcwallet.dump
  404. $gentest_py --type=segwit 2 $REFDIR/btcwallet-segwit.dump
  405. $gentest_py --type=bech32 2 $REFDIR/btcwallet-bech32.dump
  406. $gentest_py --testnet=1 2 $REFDIR/btcwallet-testnet.dump
  407. $gentest_py --coin=ltc 2 $REFDIR/litecoin/ltcwallet.dump
  408. $gentest_py --coin=ltc --type=segwit 2 $REFDIR/litecoin/ltcwallet-segwit.dump
  409. $gentest_py --coin=ltc --type=bech32 2 $REFDIR/litecoin/ltcwallet-bech32.dump
  410. $gentest_py --coin=ltc --testnet=1 2 $REFDIR/litecoin/ltcwallet-testnet.dump
  411. # libsecp256k1 vs python-ecdsa:
  412. $gentest_py 1:2 $rounds
  413. $gentest_py --type=segwit 1:2 $rounds
  414. $gentest_py --type=bech32 1:2 $rounds
  415. $gentest_py --testnet=1 1:2 $rounds
  416. $gentest_py --testnet=1 --type=segwit 1:2 $rounds
  417. $gentest_py --coin=ltc 1:2 $rounds
  418. $gentest_py --coin=ltc --type=segwit 1:2 $rounds
  419. $gentest_py --coin=ltc --testnet=1 1:2 $rounds
  420. $gentest_py --coin=ltc --testnet=1 --type=segwit 1:2 $rounds
  421. "
  422. f_gen='gentest tests completed'
  423. [ -d .git -a -n "$INSTALL" -a -z "$TESTING" ] && {
  424. check
  425. uninstall
  426. install
  427. cd .test-release/pydist/mmgen-*
  428. }
  429. [ "$INSTALL_ONLY" ] && exit
  430. prompt_skip() {
  431. echo -n "Enter 's' to skip, or ENTER to continue: "; read -n1; echo
  432. [ "$REPLY" == 's' ] && return 0
  433. return 1
  434. }
  435. run_tests() {
  436. for t in $1; do
  437. eval echo -e "'\n'"\${GREEN}'###' Running $(echo \$i_$t) tests\$RESET
  438. eval echo -e $(echo \$s_$t)
  439. [ "$PAUSE" ] && prompt_skip && continue
  440. CUR_TEST=$t
  441. do_test $t
  442. eval echo -e \$GREEN$(echo \$f_$t)\$RESET
  443. done
  444. }
  445. check_args() {
  446. for i in $tests; do
  447. echo "$dfl_tests $add_tests" | grep -q "\<$i\>" || { echo "$i: unrecognized argument"; exit; }
  448. done
  449. }
  450. tests=$dfl_tests
  451. [ "$*" ] && tests="$*"
  452. check_args
  453. echo "Running tests: $tests"
  454. START=$(date +%s)
  455. run_tests "$tests"
  456. TIME=$(($(date +%s)-START))
  457. MS=$(printf %02d:%02d $((TIME/60)) $((TIME%60)))
  458. [ "$NO_TMPFILE_REMOVAL" ] || rm -rf /tmp/mmgen-test-release-*
  459. echo -e "${GREEN}All OK. Total elapsed time: $MS$RESET"