test-release.sh 19 KB

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