test-release.sh 20 KB

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