test-release.sh 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  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_btc autosign_live etc ltc_tn bch_tn'
  34. noalt_tests='misc obj color unit hash ref autosign_btc btc btc_tn btc_rt tool tool2 gen'
  35. quick_tests='misc obj color unit hash ref altref alts xmr eth autosign btc btc_rt tool tool2 gen'
  36. qskip_tests='btc_tn bch bch_rt ltc ltc_rt'
  37. PROGNAME=$(basename $0)
  38. while getopts hAbCfFi:I:lOpRtvV OPT
  39. do
  40. case "$OPT" in
  41. h) printf " %-16s Test MMGen release\n" "${PROGNAME}:"
  42. echo " USAGE: $PROGNAME [options] [tests or test group]"
  43. echo " OPTIONS: '-h' Print this help message"
  44. echo " '-A' Skip tests requiring altcoin modules or daemons"
  45. echo " '-b' Buffer keypresses for all invocations of 'test/test.py'"
  46. echo " '-C' Run tests in coverage mode"
  47. echo " '-f' Speed up the tests by using fewer rounds"
  48. echo " '-F' Reduce rounds even further"
  49. echo " '-i' Create and install Python package, then run tests. A branch"
  50. echo " must be supplied as a parameter"
  51. echo " '-I' Like '-i', but install the package without running the tests"
  52. echo " '-l' List the test name symbols"
  53. echo " '-O' Use pexpect.spawn rather than popen_spawn for applicable tests"
  54. echo " '-p' Pause between tests"
  55. echo " '-R' Don't remove temporary files after program has exited"
  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 - operations for Monero"
  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=1 ;;
  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 xmr_addrs='3,23' unit_tests_py+=" --fast" ;;
  112. F) FAST=1 rounds=3 rounds_min=1 rounds_mid=3 rounds_max=5 xmr_addrs='3,23' 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. R) NO_TMPFILE_REMOVAL=1 ;;
  124. t) LIST_CMDS=1 ;;
  125. v) EXACT_OUTPUT=1 test_py+=" --exact-output" ;&
  126. V) VERBOSE=1 [ "$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=1 ;;
  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
  162. }
  163. git diff $BRANCH >/dev/null 2>&1 || exit
  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=$(eval echo \"'$'"t_$1"\")
  190. skips=$(eval echo \"'$'"t_$1_skip"\")
  191. declare -a tests_arr
  192. n=0
  193. while read test; do
  194. tests_arr[n]="$test"
  195. let n+=1
  196. done <<-EOF
  197. $tests
  198. EOF
  199. n=0
  200. for test in "${tests_arr[@]}"; do
  201. [ -z "$test" ] && continue
  202. test_disp=$YELLOW${test/\#/$RESET$MAGENTA\#}$RESET
  203. [ "${test:0:1}" == '#' ] && {
  204. [ "$LIST_CMDS" ] || echo -e "$test_disp"
  205. continue
  206. }
  207. let n+=1
  208. echo $skips | grep -q "\<$n\>" && continue
  209. if [ "$LIST_CMDS" ]; then
  210. echo $test
  211. else
  212. echo -e "${GREEN}Running:$RESET $test_disp"
  213. fi
  214. # continue
  215. [ "$LIST_CMDS" ] || eval "$test" || {
  216. echo -e $RED"test-release.sh: test '$CUR_TEST' failed at command '$test'"$RESET
  217. exit 1
  218. }
  219. done
  220. }
  221. i_misc='Miscellaneous'
  222. s_misc='Testing various subsystems'
  223. t_misc="
  224. $altcoin_py
  225. "
  226. f_misc='Miscellaneous tests completed'
  227. i_obj='Data object'
  228. s_obj='Testing data objects'
  229. t_obj="
  230. $objtest_py --coin=btc
  231. $objtest_py --coin=btc --testnet=1
  232. $objtest_py --coin=ltc
  233. $objtest_py --coin=ltc --testnet=1
  234. $objtest_py --coin=eth
  235. $objattrtest_py
  236. "
  237. f_obj='Data object tests completed'
  238. i_color='Color'
  239. s_color='Testing terminal colors'
  240. t_color="$colortest_py"
  241. f_color='Terminal color tests completed'
  242. i_unit='Unit'
  243. s_unit='The bitcoin and bitcoin-abc mainnet daemons must be running for the following tests'
  244. t_unit="$unit_tests_py"
  245. f_unit='Unit tests completed'
  246. i_hash='Internal hash function implementations'
  247. s_hash='Testing internal hash function implementations'
  248. t_hash="
  249. $python test/hashfunc.py sha256 $rounds_max
  250. $python test/hashfunc.py sha512 $rounds_max # native SHA512 - not used by the MMGen wallet
  251. $python test/hashfunc.py keccak $rounds_max
  252. "
  253. f_hash='Hash function tests completed'
  254. [ "$ARM32" ] && t_hash_skip='2' # gmpy produces invalid init constants
  255. [ "$MSYS2" ] && t_hash_skip='2 3' # 2:py_long_long issues, 3:no pysha3 for keccak reference
  256. i_ref='Miscellaneous reference data'
  257. s_ref='The following tests will test some generated values against reference data'
  258. t_ref="
  259. $scrambletest_py
  260. "
  261. f_ref='Miscellaneous reference data tests completed'
  262. i_altref='Altcoin reference file'
  263. s_altref='The following tests will test some generated altcoin files against reference data'
  264. t_altref="
  265. $test_py ref_altcoin # generated addrfiles verified against checksums
  266. "
  267. f_altref='Altcoin reference file tests completed'
  268. i_alts='Gen-only altcoin'
  269. s_alts='The following tests will test generation operations for all supported altcoins'
  270. t_alts="
  271. # speed tests, no verification:
  272. $gentest_py --coin=etc 2 $rounds
  273. $gentest_py --coin=etc --use-internal-keccak-module 2 $rounds_min
  274. $gentest_py --coin=eth 2 $rounds
  275. $gentest_py --coin=eth --use-internal-keccak-module 2 $rounds_min
  276. $gentest_py --coin=xmr 2 $rounds
  277. $gentest_py --coin=xmr --use-internal-keccak-module 2 $rounds_min
  278. $gentest_py --coin=zec 2 $rounds
  279. $gentest_py --coin=zec --type=zcash_z 2 $rounds_mid
  280. # verification against external libraries and tools:
  281. # pycoin
  282. $gentest_py --all --type=legacy 2:pycoin $rounds
  283. $gentest_py --all --type=compressed 2:pycoin $rounds
  284. $gentest_py --all --type=segwit 2:pycoin $rounds
  285. $gentest_py --all --type=bech32 2:pycoin $rounds
  286. $gentest_py --all --type=legacy --testnet=1 2:pycoin $rounds
  287. $gentest_py --all --type=compressed --testnet=1 2:pycoin $rounds
  288. $gentest_py --all --type=segwit --testnet=1 2:pycoin $rounds
  289. $gentest_py --all --type=bech32 --testnet=1 2:pycoin $rounds
  290. # keyconv
  291. $gentest_py --all --type=legacy 2:keyconv $rounds
  292. $gentest_py --all --type=compressed 2:keyconv $rounds
  293. # ethkey
  294. $gentest_py --all 2:ethkey $rounds
  295. "
  296. [ "$MSYS2" ] || { # no moneropy (pysha3), zcash-mini (golang)
  297. t_alts+="
  298. # moneropy
  299. $gentest_py --all --coin=xmr 2:moneropy $rounds_min # very slow, be patient!
  300. # zcash-mini
  301. $gentest_py --all 2:zcash-mini $rounds_mid
  302. "
  303. }
  304. f_alts='Gen-only altcoin tests completed'
  305. if [ "$NO_TMPFILE_REMOVAL" ]; then
  306. TMPDIR=$(echo /tmp/mmgen-test-release*)
  307. else
  308. rm -rf /tmp/mmgen-test-release*
  309. if [ "$MSYS2" ]; then
  310. TMPDIR='/tmp/mmgen-test-release'
  311. else
  312. TMPDIR='/tmp/mmgen-test-release-'$(cat /dev/urandom | base32 - | head -n1 | cut -b 1-16)
  313. fi
  314. mkdir -p $TMPDIR
  315. fi
  316. mmgen_tool_xmr="$mmgen_tool -q --accept-defaults --outdir $TMPDIR --monero-wallet-rpc-password=passw0rd"
  317. i_xmr='Monero'
  318. s_xmr='Testing key-address file generation and wallet creation and sync operations for Monero'
  319. s_xmr='The monerod (mainnet) daemon must be running for the following tests'
  320. t_xmr="
  321. mmgen-walletgen -q -r0 -p1 -Llabel --outdir $TMPDIR -o words
  322. $mmgen_keygen -q --accept-defaults --use-internal-keccak-module --outdir $TMPDIR --coin=xmr $TMPDIR/*.mmwords $xmr_addrs
  323. cs1=\$(mmgen-tool -q --accept-defaults --coin=xmr keyaddrfile_chksum $TMPDIR/*-XMR*.akeys)
  324. $mmgen_keygen -q --use-old-ed25519 --accept-defaults --outdir $TMPDIR --coin=xmr $TMPDIR/*.mmwords $xmr_addrs
  325. cs2=\$(mmgen-tool -q --accept-defaults --coin=xmr keyaddrfile_chksum $TMPDIR/*-XMR*.akeys)
  326. [ \"\$cs1\" == \"\$cs2\" ]
  327. test/start-coin-daemons.py xmr
  328. $mmgen_tool_xmr keyaddrlist2monerowallets $TMPDIR/*-XMR*.akeys addrs=23
  329. $mmgen_tool_xmr keyaddrlist2monerowallets $TMPDIR/*-XMR*.akeys addrs=103-200
  330. rm $TMPDIR/*-MoneroWallet*
  331. $mmgen_tool_xmr keyaddrlist2monerowallets $TMPDIR/*-XMR*.akeys
  332. $mmgen_tool_xmr syncmonerowallets $TMPDIR/*-XMR*.akeys addrs=3
  333. $mmgen_tool_xmr syncmonerowallets $TMPDIR/*-XMR*.akeys addrs=23-29
  334. $mmgen_tool_xmr syncmonerowallets $TMPDIR/*-XMR*.akeys
  335. test/stop-coin-daemons.py -W xmr
  336. "
  337. f_xmr='Monero tests completed'
  338. [ "$xmr_addrs" == '3,23' ] && t_xmr_skip='4 9 14'
  339. i_eth='Ethereum'
  340. s_eth='Testing transaction and tracking wallet operations for Ethereum'
  341. t_eth="
  342. $test_py --coin=eth ethdev
  343. "
  344. f_eth='Ethereum tests completed'
  345. i_etc='Ethereum Classic'
  346. s_etc='Testing transaction and tracking wallet operations for Ethereum Classic'
  347. t_etc="
  348. $test_py --coin=etc ethdev
  349. "
  350. f_etc='Ethereum Classic tests completed'
  351. i_autosign='Autosign'
  352. s_autosign='The bitcoin, bitcoin-abc and litecoin mainnet and testnet daemons must be running for the following test'
  353. t_autosign="$test_py autosign"
  354. f_autosign='Autosign test completed'
  355. i_autosign_btc='Autosign BTC'
  356. s_autosign_btc='The bitcoin mainnet and testnet daemons must be running for the following test'
  357. t_autosign_btc="$test_py autosign_btc"
  358. f_autosign_btc='Autosign BTC test completed'
  359. i_autosign_live='Autosign Live'
  360. s_autosign_live="The bitcoin mainnet and testnet daemons must be running for the following test\n"
  361. s_autosign_live+="${YELLOW}Mountpoint, '/etc/fstab' and removable device must be configured "
  362. s_autosign_live+="as described in 'mmgen-autosign --help'${RESET}"
  363. t_autosign_live="$test_py autosign_live"
  364. f_autosign_live='Autosign Live test completed'
  365. i_btc='Bitcoin mainnet'
  366. s_btc='The bitcoin (mainnet) daemon must both be running for the following tests'
  367. t_btc="
  368. $test_py --exclude regtest,autosign,ref_altcoin
  369. $test_py --segwit
  370. $test_py --segwit-random
  371. $test_py --bech32
  372. $python scripts/compute-file-chksum.py $REFDIR/*testnet.rawtx >/dev/null 2>&1
  373. "
  374. f_btc='Bitcoin mainnet tests completed'
  375. i_btc_tn='Bitcoin testnet'
  376. s_btc_tn='The bitcoin testnet daemon must both be running for the following tests'
  377. t_btc_tn="
  378. $test_py --testnet=1
  379. $test_py --testnet=1 --segwit
  380. $test_py --testnet=1 --segwit-random
  381. $test_py --testnet=1 --bech32
  382. "
  383. f_btc_tn='Bitcoin testnet tests completed'
  384. i_btc_rt='Bitcoin regtest'
  385. s_btc_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  386. t_btc_rt="$test_py regtest"
  387. f_btc_rt='Regtest (Bob and Alice) mode tests for BTC completed'
  388. i_bch='Bcash (BCH) mainnet'
  389. s_bch='The bitcoin-abc mainnet daemon must both be running for the following tests'
  390. t_bch="$test_py --coin=bch --exclude regtest"
  391. f_bch='Bcash (BCH) mainnet tests completed'
  392. i_bch_tn='Bcash (BCH) testnet'
  393. s_bch_tn='The bitcoin-abc testnet daemon must both be running for the following tests'
  394. t_bch_tn="$test_py --coin=bch --testnet=1 --exclude regtest"
  395. f_bch_tn='Bcash (BCH) testnet tests completed'
  396. i_bch_rt='Bcash (BCH) regtest'
  397. s_bch_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  398. t_bch_rt="$test_py --coin=bch regtest"
  399. f_bch_rt='Regtest (Bob and Alice) mode tests for BCH completed'
  400. i_ltc='Litecoin'
  401. s_ltc='The litecoin mainnet daemon must both be running for the following tests'
  402. t_ltc="
  403. $test_py --coin=ltc --exclude regtest
  404. $test_py --coin=ltc --segwit
  405. $test_py --coin=ltc --segwit-random
  406. $test_py --coin=ltc --bech32
  407. "
  408. f_ltc='Litecoin mainnet tests completed'
  409. i_ltc_tn='Litecoin testnet'
  410. s_ltc_tn='The litecoin testnet daemon must both be running for the following tests'
  411. t_ltc_tn="
  412. $test_py --coin=ltc --testnet=1 --exclude regtest
  413. $test_py --coin=ltc --testnet=1 --segwit
  414. $test_py --coin=ltc --testnet=1 --segwit-random
  415. $test_py --coin=ltc --testnet=1 --bech32
  416. "
  417. f_ltc_tn='Litecoin testnet tests completed'
  418. i_ltc_rt='Litecoin regtest'
  419. s_ltc_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  420. t_ltc_rt="$test_py --coin=ltc regtest"
  421. f_ltc_rt='Regtest (Bob and Alice) mode tests for LTC completed'
  422. i_tool2='Tooltest2'
  423. s_tool2="The following tests will run '$tooltest2_py' for all supported coins"
  424. t_tool2="
  425. $tooltest2_py --tool-api # test the tool_api subsystem
  426. $tooltest2_py --tool-api --testnet=1
  427. $tooltest2_py --tool-api --coin=eth
  428. $tooltest2_py --tool-api --coin=xmr
  429. $tooltest2_py --tool-api --coin=zec
  430. $tooltest2_py
  431. $tooltest2_py --testnet=1
  432. $tooltest2_py --coin=ltc
  433. $tooltest2_py --coin=ltc --testnet=1
  434. $tooltest2_py --coin=bch
  435. $tooltest2_py --coin=bch --testnet=1
  436. $tooltest2_py --coin=zec
  437. $tooltest2_py --coin=xmr
  438. $tooltest2_py --coin=dash
  439. $tooltest2_py --coin=eth
  440. $tooltest2_py --coin=eth --testnet=1
  441. $tooltest2_py --coin=eth --token=mm1
  442. $tooltest2_py --coin=eth --token=mm1 --testnet=1
  443. $tooltest2_py --coin=etc
  444. $tooltest2_py --fork # run once with --fork so commands are actually executed
  445. "
  446. f_tool2='tooltest2 tests completed'
  447. [ "$SKIP_ALT" ] && t_tool2_skip='17 18'
  448. i_tool='Tooltest'
  449. s_tool="The following tests will run '$tooltest_py' for all supported coins"
  450. t_tool="
  451. $tooltest_py --coin=btc cryptocoin
  452. $tooltest_py --coin=btc mnemonic
  453. $tooltest_py --coin=ltc cryptocoin
  454. $tooltest_py --coin=eth cryptocoin
  455. $tooltest_py --coin=etc cryptocoin
  456. $tooltest_py --coin=dash cryptocoin
  457. $tooltest_py --coin=doge cryptocoin
  458. $tooltest_py --coin=emc cryptocoin
  459. $tooltest_py --coin=zec cryptocoin
  460. $tooltest_py --coin=zec --type=zcash_z cryptocoin
  461. "
  462. [ "$MSYS2" ] && t_tool_skip='10'
  463. f_tool='tooltest tests completed'
  464. i_gen='Gentest'
  465. s_gen="The following tests will run '$gentest_py' for BTC and LTC mainnet and testnet"
  466. t_gen="
  467. # speed tests, no verification:
  468. $gentest_py --coin=btc 2 $rounds
  469. $gentest_py --coin=btc --type=compressed 2 $rounds
  470. $gentest_py --coin=btc --type=segwit 2 $rounds
  471. $gentest_py --coin=btc --type=bech32 2 $rounds
  472. $gentest_py --coin=ltc 2 $rounds
  473. $gentest_py --coin=ltc --type=compressed 2 $rounds
  474. $gentest_py --coin=ltc --type=segwit 2 $rounds
  475. $gentest_py --coin=ltc --type=bech32 2 $rounds
  476. # wallet dumps:
  477. $gentest_py 2 $REFDIR/btcwallet.dump
  478. $gentest_py --type=segwit 2 $REFDIR/btcwallet-segwit.dump
  479. $gentest_py --type=bech32 2 $REFDIR/btcwallet-bech32.dump
  480. $gentest_py --testnet=1 2 $REFDIR/btcwallet-testnet.dump
  481. $gentest_py --coin=ltc 2 $REFDIR/litecoin/ltcwallet.dump
  482. $gentest_py --coin=ltc --type=segwit 2 $REFDIR/litecoin/ltcwallet-segwit.dump
  483. $gentest_py --coin=ltc --type=bech32 2 $REFDIR/litecoin/ltcwallet-bech32.dump
  484. $gentest_py --coin=ltc --testnet=1 2 $REFDIR/litecoin/ltcwallet-testnet.dump
  485. # libsecp256k1 vs python-ecdsa:
  486. $gentest_py 1:2 $rounds
  487. $gentest_py --type=segwit 1:2 $rounds
  488. $gentest_py --type=bech32 1:2 $rounds
  489. $gentest_py --testnet=1 1:2 $rounds
  490. $gentest_py --testnet=1 --type=segwit 1:2 $rounds
  491. $gentest_py --coin=ltc 1:2 $rounds
  492. $gentest_py --coin=ltc --type=segwit 1:2 $rounds
  493. $gentest_py --coin=ltc --testnet=1 1:2 $rounds
  494. $gentest_py --coin=ltc --testnet=1 --type=segwit 1:2 $rounds
  495. "
  496. f_gen='gentest tests completed'
  497. [ -d .git -a -n "$INSTALL" -a -z "$LIST_CMDS" ] && {
  498. check
  499. uninstall
  500. install
  501. cd .test-release/pydist/mmgen-*
  502. }
  503. [ "$INSTALL_ONLY" ] && exit
  504. prompt_skip() {
  505. echo -n "Enter 's' to skip, or ENTER to continue: "; read -n1; echo
  506. [ "$REPLY" == 's' ] && return 0
  507. return 1
  508. }
  509. run_tests() {
  510. for t in $1; do
  511. if [ "$LIST_CMDS" ]; then
  512. eval echo -e '\\n#' $(echo \$i_$t) "\($t\)"
  513. else
  514. eval echo -e "'\n'"\${GREEN}'###' Running $(echo \$i_$t) tests\$RESET
  515. eval echo -e $(echo \$s_$t)
  516. fi
  517. [ "$PAUSE" ] && prompt_skip && continue
  518. CUR_TEST=$t
  519. do_test $t
  520. [ "$LIST_CMDS" ] || eval echo -e $(echo \$f_$t)
  521. done
  522. }
  523. check_args() {
  524. for i in $tests; do
  525. echo "$dfl_tests $extra_tests" | grep -q "\<$i\>" || { echo "$i: unrecognized argument"; exit; }
  526. done
  527. }
  528. check_args
  529. [ "$LIST_CMDS" ] || echo "Running tests: $tests"
  530. START=$(date +%s)
  531. run_tests "$tests"
  532. TIME=$(($(date +%s)-START))
  533. MS=$(printf %02d:%02d $((TIME/60)) $((TIME%60)))
  534. [ "$NO_TMPFILE_REMOVAL" ] || rm -rf /tmp/mmgen-test-release-*
  535. [ "$LIST_CMDS" ] || echo -e "${GREEN}All OK. Total elapsed time: $MS$RESET"