test-release.sh 18 KB

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