test-release.sh 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  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_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 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_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
  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 --getobj --coin=btc
  232. $objtest_py --coin=btc --testnet=1
  233. $objtest_py --coin=ltc
  234. $objtest_py --coin=ltc --testnet=1
  235. $objtest_py --coin=eth
  236. $objattrtest_py
  237. "
  238. f_obj='Data object tests completed'
  239. i_color='Color'
  240. s_color='Testing terminal colors'
  241. t_color="$colortest_py"
  242. f_color='Terminal color tests completed'
  243. i_unit='Unit'
  244. s_unit='The bitcoin and bitcoin-bchn mainnet daemons must be running for the following tests'
  245. t_unit="$unit_tests_py"
  246. f_unit='Unit tests completed'
  247. i_hash='Internal hash function implementations'
  248. s_hash='Testing internal hash function implementations'
  249. t_hash="
  250. $python test/hashfunc.py sha256 $rounds_max
  251. $python test/hashfunc.py sha512 $rounds_max # native SHA512 - not used by the MMGen wallet
  252. $python test/hashfunc.py keccak $rounds_max
  253. "
  254. f_hash='Hash function tests completed'
  255. [ "$ARM32" ] && t_hash_skip='2' # gmpy produces invalid init constants
  256. [ "$MSYS2" ] && t_hash_skip='2 3' # 2:py_long_long issues, 3:no pysha3 for keccak reference
  257. i_ref='Miscellaneous reference data'
  258. s_ref='The following tests will test some generated values against reference data'
  259. t_ref="
  260. $scrambletest_py
  261. "
  262. f_ref='Miscellaneous reference data tests completed'
  263. i_altref='Altcoin reference file'
  264. s_altref='The following tests will test some generated altcoin files against reference data'
  265. t_altref="
  266. $test_py ref_altcoin # generated addrfiles verified against checksums
  267. "
  268. f_altref='Altcoin reference file tests completed'
  269. i_alts='Gen-only altcoin'
  270. s_alts='The following tests will test generation operations for all supported altcoins'
  271. t_alts="
  272. # speed tests, no verification:
  273. $gentest_py --coin=etc 2 $rounds
  274. $gentest_py --coin=etc --use-internal-keccak-module 2 $rounds_min
  275. $gentest_py --coin=eth 2 $rounds
  276. $gentest_py --coin=eth --use-internal-keccak-module 2 $rounds_min
  277. $gentest_py --coin=xmr 2 $rounds
  278. $gentest_py --coin=xmr --use-internal-keccak-module 2 $rounds_min
  279. $gentest_py --coin=zec 2 $rounds
  280. $gentest_py --coin=zec --type=zcash_z 2 $rounds_mid
  281. # verification against external libraries and tools:
  282. # pycoin
  283. $gentest_py --all --type=legacy 2:pycoin $rounds
  284. $gentest_py --all --type=compressed 2:pycoin $rounds
  285. $gentest_py --all --type=segwit 2:pycoin $rounds
  286. $gentest_py --all --type=bech32 2:pycoin $rounds
  287. $gentest_py --all --type=legacy --testnet=1 2:pycoin $rounds
  288. $gentest_py --all --type=compressed --testnet=1 2:pycoin $rounds
  289. $gentest_py --all --type=segwit --testnet=1 2:pycoin $rounds
  290. $gentest_py --all --type=bech32 --testnet=1 2:pycoin $rounds
  291. # keyconv
  292. $gentest_py --all --type=legacy 2:keyconv $rounds
  293. $gentest_py --all --type=compressed 2:keyconv $rounds
  294. # ethkey
  295. $gentest_py --all 2:ethkey $rounds
  296. "
  297. [ "$MSYS2" ] || { # no moneropy (pysha3), zcash-mini (golang)
  298. t_alts+="
  299. # moneropy
  300. $gentest_py --all --coin=xmr 2:moneropy $rounds_min # very slow, be patient!
  301. # zcash-mini
  302. $gentest_py --all 2:zcash-mini $rounds_mid
  303. "
  304. }
  305. f_alts='Gen-only altcoin tests completed'
  306. if [ "$NO_TMPFILE_REMOVAL" ]; then
  307. TMPDIR=$(echo /tmp/mmgen-test-release*)
  308. else
  309. rm -rf /tmp/mmgen-test-release*
  310. if [ "$MSYS2" ]; then
  311. TMPDIR='/tmp/mmgen-test-release'
  312. else
  313. TMPDIR='/tmp/mmgen-test-release-'$(cat /dev/urandom | base32 - | head -n1 | cut -b 1-16)
  314. fi
  315. mkdir -p $TMPDIR
  316. fi
  317. mmgen_tool_xmr="$mmgen_tool -q --accept-defaults --outdir $TMPDIR --monero-wallet-rpc-password=passw0rd"
  318. i_xmr='Monero'
  319. s_xmr='Testing key-address file generation and wallet creation and sync operations for Monero'
  320. s_xmr='The monerod (mainnet) daemon must be running for the following tests'
  321. t_xmr="
  322. cmds/mmgen-walletgen -q -r0 -p1 -Llabel --outdir $TMPDIR -o words
  323. $mmgen_keygen -q --accept-defaults --use-internal-keccak-module --outdir $TMPDIR --coin=xmr $TMPDIR/*.mmwords $xmr_addrs
  324. cs1=\$(cmds/mmgen-tool -q --accept-defaults --coin=xmr keyaddrfile_chksum $TMPDIR/*-XMR*.akeys)
  325. $mmgen_keygen -q --use-old-ed25519 --accept-defaults --outdir $TMPDIR --coin=xmr $TMPDIR/*.mmwords $xmr_addrs
  326. cs2=\$(cmds/mmgen-tool -q --accept-defaults --coin=xmr keyaddrfile_chksum $TMPDIR/*-XMR*.akeys)
  327. [ \"\$cs1\" == \"\$cs2\" ]
  328. test/start-coin-daemons.py xmr
  329. $mmgen_tool_xmr keyaddrlist2monerowallets $TMPDIR/*-XMR*.akeys addrs=23
  330. $mmgen_tool_xmr keyaddrlist2monerowallets $TMPDIR/*-XMR*.akeys addrs=103-200
  331. rm $TMPDIR/*-MoneroWallet*
  332. $mmgen_tool_xmr keyaddrlist2monerowallets $TMPDIR/*-XMR*.akeys
  333. $mmgen_tool_xmr syncmonerowallets $TMPDIR/*-XMR*.akeys addrs=3
  334. $mmgen_tool_xmr syncmonerowallets $TMPDIR/*-XMR*.akeys addrs=23-29
  335. $mmgen_tool_xmr syncmonerowallets $TMPDIR/*-XMR*.akeys
  336. test/stop-coin-daemons.py -W xmr
  337. "
  338. f_xmr='Monero tests completed'
  339. [ "$xmr_addrs" == '3,23' ] && t_xmr_skip='4 9 14'
  340. i_eth='Ethereum'
  341. s_eth='Testing transaction and tracking wallet operations for Ethereum'
  342. t_eth="
  343. $test_py --coin=eth ethdev
  344. "
  345. f_eth='Ethereum tests completed'
  346. i_etc='Ethereum Classic'
  347. s_etc='Testing transaction and tracking wallet operations for Ethereum Classic'
  348. t_etc="
  349. $test_py --coin=etc ethdev
  350. "
  351. f_etc='Ethereum Classic tests completed'
  352. i_autosign='Autosign'
  353. s_autosign='The bitcoin, bitcoin-bchn and litecoin mainnet and testnet daemons must be running for the following test'
  354. t_autosign="$test_py autosign"
  355. f_autosign='Autosign test completed'
  356. i_autosign_btc='Autosign BTC'
  357. s_autosign_btc='The bitcoin mainnet and testnet daemons must be running for the following test'
  358. t_autosign_btc="$test_py autosign_btc"
  359. f_autosign_btc='Autosign BTC test completed'
  360. i_autosign_live='Autosign Live'
  361. s_autosign_live="The bitcoin mainnet and testnet daemons must be running for the following test\n"
  362. s_autosign_live+="${YELLOW}Mountpoint, '/etc/fstab' and removable device must be configured "
  363. s_autosign_live+="as described in 'mmgen-autosign --help'${RESET}"
  364. t_autosign_live="$test_py autosign_live"
  365. f_autosign_live='Autosign Live test completed'
  366. i_btc='Bitcoin mainnet'
  367. s_btc='The bitcoin (mainnet) daemon must both be running for the following tests'
  368. t_btc="
  369. $test_py --exclude regtest,autosign,ref_altcoin
  370. $test_py --segwit
  371. $test_py --segwit-random
  372. $test_py --bech32
  373. $python scripts/compute-file-chksum.py $REFDIR/*testnet.rawtx >/dev/null 2>&1
  374. "
  375. f_btc='Bitcoin mainnet tests completed'
  376. i_btc_tn='Bitcoin testnet'
  377. s_btc_tn='The bitcoin testnet daemon must both be running for the following tests'
  378. t_btc_tn="
  379. $test_py --testnet=1
  380. $test_py --testnet=1 --segwit
  381. $test_py --testnet=1 --segwit-random
  382. $test_py --testnet=1 --bech32
  383. "
  384. f_btc_tn='Bitcoin testnet tests completed'
  385. i_btc_rt='Bitcoin regtest'
  386. s_btc_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  387. t_btc_rt="$test_py regtest"
  388. f_btc_rt='Regtest (Bob and Alice) mode tests for BTC completed'
  389. i_bch='BitcoinCashNode (BCH) mainnet'
  390. s_bch='The bitcoin-bchn mainnet daemon must both be running for the following tests'
  391. t_bch="$test_py --coin=bch --exclude regtest"
  392. f_bch='BitcoinCashNode (BCH) mainnet tests completed'
  393. i_bch_tn='BitcoinCashNode (BCH) testnet'
  394. s_bch_tn='The bitcoin-bchn testnet daemon must both be running for the following tests'
  395. t_bch_tn="$test_py --coin=bch --testnet=1 --exclude regtest"
  396. f_bch_tn='BitcoinCashNode (BCH) testnet tests completed'
  397. i_bch_rt='BitcoinCashNode (BCH) regtest'
  398. s_bch_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  399. t_bch_rt="$test_py --coin=bch regtest"
  400. f_bch_rt='Regtest (Bob and Alice) mode tests for BCH completed'
  401. i_ltc='Litecoin'
  402. s_ltc='The litecoin mainnet daemon must both be running for the following tests'
  403. t_ltc="
  404. $test_py --coin=ltc --exclude regtest
  405. $test_py --coin=ltc --segwit
  406. $test_py --coin=ltc --segwit-random
  407. $test_py --coin=ltc --bech32
  408. "
  409. f_ltc='Litecoin mainnet tests completed'
  410. i_ltc_tn='Litecoin testnet'
  411. s_ltc_tn='The litecoin testnet daemon must both be running for the following tests'
  412. t_ltc_tn="
  413. $test_py --coin=ltc --testnet=1 --exclude regtest
  414. $test_py --coin=ltc --testnet=1 --segwit
  415. $test_py --coin=ltc --testnet=1 --segwit-random
  416. $test_py --coin=ltc --testnet=1 --bech32
  417. "
  418. f_ltc_tn='Litecoin testnet tests completed'
  419. i_ltc_rt='Litecoin regtest'
  420. s_ltc_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  421. t_ltc_rt="$test_py --coin=ltc regtest"
  422. f_ltc_rt='Regtest (Bob and Alice) mode tests for LTC completed'
  423. i_tool2='Tooltest2'
  424. s_tool2="The following tests will run '$tooltest2_py' for all supported coins"
  425. t_tool2="
  426. $tooltest2_py --tool-api # test the tool_api subsystem
  427. $tooltest2_py --tool-api --testnet=1
  428. $tooltest2_py --tool-api --coin=eth
  429. $tooltest2_py --tool-api --coin=xmr
  430. $tooltest2_py --tool-api --coin=zec
  431. $tooltest2_py
  432. $tooltest2_py --testnet=1
  433. $tooltest2_py --coin=ltc
  434. $tooltest2_py --coin=ltc --testnet=1
  435. $tooltest2_py --coin=bch
  436. $tooltest2_py --coin=bch --testnet=1
  437. $tooltest2_py --coin=zec
  438. $tooltest2_py --coin=xmr
  439. $tooltest2_py --coin=dash
  440. $tooltest2_py --coin=eth
  441. $tooltest2_py --coin=eth --testnet=1
  442. $tooltest2_py --coin=eth --token=mm1
  443. $tooltest2_py --coin=eth --token=mm1 --testnet=1
  444. $tooltest2_py --coin=etc
  445. $tooltest2_py --fork # run once with --fork so commands are actually executed
  446. "
  447. f_tool2='tooltest2 tests completed'
  448. [ "$SKIP_ALT_DEP" ] && t_tool2_skip='15 16 17 18 19' # skip ETH,ETC: txview requires py_ecc
  449. i_tool='Tooltest'
  450. s_tool="The following tests will run '$tooltest_py' for all supported coins"
  451. t_tool="
  452. $tooltest_py --coin=btc cryptocoin
  453. $tooltest_py --coin=btc mnemonic
  454. $tooltest_py --coin=ltc cryptocoin
  455. $tooltest_py --coin=eth cryptocoin
  456. $tooltest_py --coin=etc cryptocoin
  457. $tooltest_py --coin=dash cryptocoin
  458. $tooltest_py --coin=doge cryptocoin
  459. $tooltest_py --coin=emc cryptocoin
  460. $tooltest_py --coin=zec cryptocoin
  461. $tooltest_py --coin=zec --type=zcash_z cryptocoin
  462. "
  463. [ "$MSYS2" ] && t_tool_skip='10'
  464. f_tool='tooltest tests completed'
  465. i_gen='Gentest'
  466. s_gen="The following tests will run '$gentest_py' for BTC and LTC mainnet and testnet"
  467. t_gen="
  468. # speed tests, no verification:
  469. $gentest_py --coin=btc 2 $rounds
  470. $gentest_py --coin=btc --type=compressed 2 $rounds
  471. $gentest_py --coin=btc --type=segwit 2 $rounds
  472. $gentest_py --coin=btc --type=bech32 2 $rounds
  473. $gentest_py --coin=ltc 2 $rounds
  474. $gentest_py --coin=ltc --type=compressed 2 $rounds
  475. $gentest_py --coin=ltc --type=segwit 2 $rounds
  476. $gentest_py --coin=ltc --type=bech32 2 $rounds
  477. # wallet dumps:
  478. $gentest_py 2 $REFDIR/btcwallet.dump
  479. $gentest_py --type=segwit 2 $REFDIR/btcwallet-segwit.dump
  480. $gentest_py --type=bech32 2 $REFDIR/btcwallet-bech32.dump
  481. $gentest_py --testnet=1 2 $REFDIR/btcwallet-testnet.dump
  482. $gentest_py --coin=ltc 2 $REFDIR/litecoin/ltcwallet.dump
  483. $gentest_py --coin=ltc --type=segwit 2 $REFDIR/litecoin/ltcwallet-segwit.dump
  484. $gentest_py --coin=ltc --type=bech32 2 $REFDIR/litecoin/ltcwallet-bech32.dump
  485. $gentest_py --coin=ltc --testnet=1 2 $REFDIR/litecoin/ltcwallet-testnet.dump
  486. # libsecp256k1 vs python-ecdsa:
  487. $gentest_py 1:2 $rounds
  488. $gentest_py --type=segwit 1:2 $rounds
  489. $gentest_py --type=bech32 1:2 $rounds
  490. $gentest_py --testnet=1 1:2 $rounds
  491. $gentest_py --testnet=1 --type=segwit 1:2 $rounds
  492. $gentest_py --coin=ltc 1:2 $rounds
  493. $gentest_py --coin=ltc --type=segwit 1:2 $rounds
  494. $gentest_py --coin=ltc --testnet=1 1:2 $rounds
  495. $gentest_py --coin=ltc --testnet=1 --type=segwit 1:2 $rounds
  496. "
  497. f_gen='gentest tests completed'
  498. [ -d .git -a -n "$INSTALL" -a -z "$LIST_CMDS" ] && {
  499. check
  500. uninstall
  501. install
  502. cd .test-release/pydist/mmgen-*
  503. }
  504. [ "$INSTALL_ONLY" ] && exit
  505. prompt_skip() {
  506. echo -n "Enter 's' to skip, or ENTER to continue: "; read -n1; echo
  507. [ "$REPLY" == 's' ] && return 0
  508. return 1
  509. }
  510. run_tests() {
  511. for t in $1; do
  512. if [ "$SKIP_ALT_DEP" ]; then
  513. ok=$(for a in $noalt_tests; do if [ $t == $a ]; then echo 'ok'; fi; done)
  514. if [ ! "$ok" ]; then
  515. echo -e "${BLUE}Skipping altcoin test '$t'$RESET"
  516. continue
  517. fi
  518. fi
  519. if [ "$LIST_CMDS" ]; then
  520. eval echo -e '\\n#' $(echo \$i_$t) "\($t\)"
  521. else
  522. eval echo -e "'\n'"\${GREEN}'###' Running $(echo \$i_$t) tests\$RESET
  523. eval echo -e $(echo \$s_$t)
  524. fi
  525. [ "$PAUSE" ] && prompt_skip && continue
  526. CUR_TEST=$t
  527. do_test $t
  528. [ "$LIST_CMDS" ] || eval echo -e $(echo \$f_$t)
  529. done
  530. }
  531. check_args() {
  532. for i in $tests; do
  533. echo "$dfl_tests $extra_tests" | grep -q "\<$i\>" || { echo "$i: unrecognized argument"; exit; }
  534. done
  535. }
  536. check_args
  537. [ "$LIST_CMDS" ] || echo "Running tests: $tests"
  538. START=$(date +%s)
  539. run_tests "$tests"
  540. TIME=$(($(date +%s)-START))
  541. MS=$(printf %02d:%02d $((TIME/60)) $((TIME%60)))
  542. [ "$NO_TMPFILE_REMOVAL" ] || rm -rf /tmp/mmgen-test-release-*
  543. [ "$LIST_CMDS" ] || echo -e "${GREEN}All OK. Total elapsed time: $MS$RESET"