test-release.sh 19 KB

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