test-release.sh 20 KB

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