test-release.sh 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  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 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 hAbCDfFi: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 " -D Run tests in deterministic mode"
  45. echo " -f Speed up the tests by using fewer rounds"
  46. echo " -F Reduce rounds even further"
  47. echo " -i BRANCH Create and install Python package from cloned BRANCH, then"
  48. echo " run tests in installed package"
  49. echo " -I BRANCH Like '-i', but install the package without running the tests"
  50. echo " -l List the test name symbols"
  51. echo " -N Pass the --no-timings switch to test/test.py"
  52. echo " -O Use pexpect.spawn rather than popen_spawn where applicable"
  53. echo " -p Pause between tests"
  54. echo " -s LIST Skip tests in LIST (space-separated)"
  55. echo " -t Print the tests without running them"
  56. echo " -v Run test/test.py with '--exact-output' and other commands"
  57. echo " with '--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 - Monero xmrwallet operations"
  69. echo " eth - operations for Ethereum and 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. D) export MMGEN_TEST_SUITE_DETERMINISTIC=1
  110. export MMGEN_DISABLE_COLOR=1 ;;
  111. f) FAST=1 rounds=10 rounds_min=3 rounds_mid=25 rounds_max=50 unit_tests_py+=" --fast" ;;
  112. F) FAST=1 rounds=3 rounds_min=1 rounds_mid=3 rounds_max=5 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. N) test_py+=" --no-timings" ;;
  122. O) test_py+=" --pexpect-spawn" ;;
  123. p) PAUSE=1 ;;
  124. s) SKIP_LIST="$OPTARG" ;;
  125. t) LIST_CMDS=1 ;;
  126. v) EXACT_OUTPUT=1 test_py+=" --exact-output" ;&
  127. V) VERBOSE=1
  128. [ "$EXACT_OUTPUT" ] || test_py+=" --verbose"
  129. unit_tests_py="${unit_tests_py/--quiet/--verbose}"
  130. altcoin_py="${altcoin_py/--quiet/--verbose}"
  131. tooltest2_py="${tooltest2_py/--quiet/--verbose}"
  132. gentest_py="${gentest_py/--quiet/--verbose}"
  133. tooltest_py+=" --verbose"
  134. mmgen_tool+=" --verbose"
  135. objattrtest_py+=" --verbose"
  136. scrambletest_py+=" --verbose" ;;
  137. *) exit ;;
  138. esac
  139. done
  140. [ "$MMGEN_DISABLE_COLOR" ] || {
  141. RED="\e[31;1m" GREEN="\e[32;1m" YELLOW="\e[33;1m" BLUE="\e[34;1m" MAGENTA="\e[35;1m" CYAN="\e[36;1m"
  142. RESET="\e[0m"
  143. }
  144. [ "$MSYS2" -a ! "$FAST" ] && tooltest2_py+=' --fork'
  145. [ "$EXACT_OUTPUT" -o "$VERBOSE" ] || objtest_py+=" -S"
  146. shift $((OPTIND-1))
  147. case $1 in
  148. '') tests=$dfl_tests ;;
  149. 'default') tests=$dfl_tests ;;
  150. 'extra') tests=$extra_tests ;;
  151. 'noalt') tests=$noalt_tests SKIP_ALT_DEP=1 unit_tests_py+=" --no-altcoin-deps" ;;
  152. 'quick') tests=$quick_tests ;;
  153. 'qskip') tests=$qskip_tests ;;
  154. *) tests="$*" ;;
  155. esac
  156. [ "$INSTALL" ] && {
  157. BRANCH=$INSTALL
  158. BRANCHES=$(git branch)
  159. FOUND_BRANCH=$(for b in ${BRANCHES/\*}; do [ "$b" == "$BRANCH" ] && echo ok; done)
  160. [ "$FOUND_BRANCH" ] || { echo "Branch '$BRANCH' not found!"; exit; }
  161. }
  162. set -e
  163. check() {
  164. [ "$BRANCH" ] || { echo 'No branch specified. Exiting'; exit; }
  165. [ "$(git diff $BRANCH)" == "" ] || {
  166. echo "Unmerged changes from branch '$BRANCH'. Exiting"
  167. exit 1
  168. }
  169. git diff $BRANCH >/dev/null 2>&1 || exit 1
  170. }
  171. uninstall() {
  172. set +e
  173. eval "$SUDO ./scripts/uninstall-mmgen.py"
  174. [ "$?" -ne 0 ] && { echo 'Uninstall failed, but proceeding anyway'; sleep 1; }
  175. set -e
  176. }
  177. install() {
  178. set -x
  179. eval "$SUDO rm -rf .test-release"
  180. git clone --branch $BRANCH --single-branch . .test-release
  181. (
  182. cd .test-release
  183. ./setup.py sdist
  184. mkdir pydist && cd pydist
  185. if [ "$MSYS2" ]; then unzip ../dist/mmgen-*.zip; else tar zxvf ../dist/mmgen-*gz; fi
  186. cd mmgen-*
  187. eval "$SUDO ./setup.py clean --all"
  188. [ "$MSYS2" ] && ./setup.py build --compiler=mingw32
  189. eval "$SUDO ./setup.py install --force"
  190. )
  191. set +x
  192. }
  193. do_test() {
  194. set +x
  195. tests="t_$1"
  196. skips="t_$1_skip"
  197. while read skip test; do
  198. [ "$test" ] || continue
  199. echo "${!skips}" | grep -q $skip && continue
  200. if [ "$LIST_CMDS" ]; then
  201. echo $test
  202. else
  203. test_disp=$YELLOW${test/\#/$RESET$MAGENTA\#}$RESET
  204. if [ "${test:0:1}" == '#' ]; then
  205. echo -e "$test_disp"
  206. else
  207. echo -e "${GREEN}Running:$RESET $test_disp"
  208. eval "$test" || {
  209. echo -e $RED"test-release.sh: test '$CUR_TEST' failed at command '$test'"$RESET
  210. exit 1
  211. }
  212. fi
  213. fi
  214. done <<<${!tests}
  215. }
  216. i_misc='Miscellaneous'
  217. s_misc='Testing various subsystems'
  218. t_misc="
  219. - $altcoin_py
  220. "
  221. f_misc='Miscellaneous tests completed'
  222. i_obj='Data object'
  223. s_obj='Testing data objects'
  224. t_obj="
  225. - $objtest_py --coin=btc
  226. - $objtest_py --getobj --coin=btc
  227. - $objtest_py --coin=btc --testnet=1
  228. - $objtest_py --coin=ltc
  229. - $objtest_py --coin=ltc --testnet=1
  230. - $objtest_py --coin=eth
  231. - $objattrtest_py
  232. "
  233. f_obj='Data object tests completed'
  234. i_color='Color'
  235. s_color='Testing terminal colors'
  236. t_color="- $colortest_py"
  237. f_color='Terminal color tests completed'
  238. i_dep='Dependency'
  239. s_dep='Testing for installed dependencies'
  240. t_dep="- $unit_tests_py testdep dep daemon.exec"
  241. f_dep='Dependency tests completed'
  242. i_unit='Unit'
  243. s_unit='The bitcoin and bitcoin-bchn mainnet daemons must be running for the following tests'
  244. t_unit="- $unit_tests_py --exclude testdep,dep,daemon"
  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. 256 $python test/hashfunc.py sha256 $rounds_max
  250. 512 $python test/hashfunc.py sha512 $rounds_max # native SHA512 - not used by the MMGen wallet
  251. keccak $python test/hashfunc.py keccak $rounds_max
  252. "
  253. f_hash='Hash function tests completed'
  254. [ "$ARM32" ] && t_hash_skip='512' # gmpy produces invalid init constants
  255. [ "$MSYS2" ] && t_hash_skip='512 keccak' # 2:py_long_long issues, 3:no pysha3 for keccak reference
  256. [ "$SKIP_ALT_DEP" ] && t_hash_skip+=' keccak'
  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. e # ethkey
  295. e $gentest_py --all 2:ethkey $rounds
  296. m # moneropy
  297. m $gentest_py --all --coin=xmr 2:moneropy $rounds_min # very slow, be patient!
  298. z # zcash-mini
  299. z $gentest_py --all 2:zcash-mini $rounds_mid
  300. "
  301. [ "$MSYS2" ] && t_alts_skip='m z' # no moneropy (pysha3), zcash-mini (golang)
  302. f_alts='Gen-only altcoin tests completed'
  303. create_tmpdir() {
  304. if [ "$MSYS2" ]; then
  305. TMPDIR='/tmp/mmgen-test-release'
  306. else
  307. TMPDIR='/tmp/mmgen-test-release-'$(cat /dev/urandom | base32 - | head -n1 | cut -b 1-16)
  308. fi
  309. mkdir -p $TMPDIR
  310. }
  311. rm -rf /tmp/mmgen-test-release*
  312. create_tmpdir
  313. i_xmr='Monero xmrwallet'
  314. s_xmr='Testing xmrwallet operations'
  315. t_xmr="
  316. - $test_py --coin=xmr xmrwallet
  317. "
  318. f_xmr='Monero xmrwallet tests completed'
  319. i_eth='Ethereum'
  320. s_eth='Testing transaction and tracking wallet operations for Ethereum'
  321. t_eth="
  322. oe $test_py --coin=eth --daemon-id=openethereum ethdev
  323. geth $test_py --coin=eth --daemon-id=geth ethdev
  324. parity $test_py --coin=etc ethdev
  325. "
  326. f_eth='Ethereum tests completed'
  327. [ "$FAST" ] && t_eth_skip='oe'
  328. i_autosign='Autosign'
  329. s_autosign='The bitcoin, bitcoin-bchn and litecoin mainnet and testnet daemons must be running for the following test'
  330. t_autosign="- $test_py autosign"
  331. f_autosign='Autosign test completed'
  332. i_autosign_btc='Autosign BTC'
  333. s_autosign_btc='The bitcoin mainnet and testnet daemons must be running for the following test'
  334. t_autosign_btc="- $test_py autosign_btc"
  335. f_autosign_btc='Autosign BTC test completed'
  336. i_autosign_live='Autosign Live'
  337. s_autosign_live="The bitcoin mainnet and testnet daemons must be running for the following test\n"
  338. s_autosign_live+="${YELLOW}Mountpoint, '/etc/fstab' and removable device must be configured "
  339. s_autosign_live+="as described in 'mmgen-autosign --help'${RESET}"
  340. t_autosign_live="- $test_py autosign_live"
  341. f_autosign_live='Autosign Live test completed'
  342. i_btc='Bitcoin mainnet'
  343. s_btc='The bitcoin (mainnet) daemon must both be running for the following tests'
  344. t_btc="
  345. - $test_py --exclude regtest,autosign,ref_altcoin
  346. - $test_py --segwit
  347. - $test_py --segwit-random
  348. - $test_py --bech32
  349. - $python scripts/compute-file-chksum.py $REFDIR/*testnet.rawtx >/dev/null 2>&1
  350. "
  351. f_btc='Bitcoin mainnet tests completed'
  352. i_btc_tn='Bitcoin testnet'
  353. s_btc_tn='The bitcoin testnet daemon must both be running for the following tests'
  354. t_btc_tn="
  355. - $test_py --testnet=1
  356. - $test_py --testnet=1 --segwit
  357. - $test_py --testnet=1 --segwit-random
  358. - $test_py --testnet=1 --bech32
  359. "
  360. f_btc_tn='Bitcoin testnet tests completed'
  361. i_btc_rt='Bitcoin regtest'
  362. s_btc_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  363. t_btc_rt="- $test_py regtest"
  364. f_btc_rt='Regtest (Bob and Alice) mode tests for BTC completed'
  365. i_bch='BitcoinCashNode (BCH) mainnet'
  366. s_bch='The bitcoin-bchn mainnet daemon must both be running for the following tests'
  367. t_bch="- $test_py --coin=bch --exclude regtest"
  368. f_bch='BitcoinCashNode (BCH) mainnet tests completed'
  369. i_bch_tn='BitcoinCashNode (BCH) testnet'
  370. s_bch_tn='The bitcoin-bchn testnet daemon must both be running for the following tests'
  371. t_bch_tn="- $test_py --coin=bch --testnet=1 --exclude regtest"
  372. f_bch_tn='BitcoinCashNode (BCH) testnet tests completed'
  373. i_bch_rt='BitcoinCashNode (BCH) regtest'
  374. s_bch_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  375. t_bch_rt="- $test_py --coin=bch regtest"
  376. f_bch_rt='Regtest (Bob and Alice) mode tests for BCH completed'
  377. i_ltc='Litecoin'
  378. s_ltc='The litecoin mainnet daemon must both be running for the following tests'
  379. t_ltc="
  380. - $test_py --coin=ltc --exclude regtest
  381. - $test_py --coin=ltc --segwit
  382. - $test_py --coin=ltc --segwit-random
  383. - $test_py --coin=ltc --bech32
  384. "
  385. f_ltc='Litecoin mainnet tests completed'
  386. i_ltc_tn='Litecoin testnet'
  387. s_ltc_tn='The litecoin testnet daemon must both be running for the following tests'
  388. t_ltc_tn="
  389. - $test_py --coin=ltc --testnet=1 --exclude regtest
  390. - $test_py --coin=ltc --testnet=1 --segwit
  391. - $test_py --coin=ltc --testnet=1 --segwit-random
  392. - $test_py --coin=ltc --testnet=1 --bech32
  393. "
  394. f_ltc_tn='Litecoin testnet tests completed'
  395. i_ltc_rt='Litecoin regtest'
  396. s_ltc_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  397. t_ltc_rt="- $test_py --coin=ltc regtest"
  398. f_ltc_rt='Regtest (Bob and Alice) mode tests for LTC completed'
  399. i_tool2='Tooltest2'
  400. s_tool2="The following tests will run '$tooltest2_py' for all supported coins"
  401. t_tool2="
  402. - $tooltest2_py --tool-api # test the tool_api subsystem
  403. - $tooltest2_py --tool-api --testnet=1
  404. - $tooltest2_py --tool-api --coin=eth
  405. - $tooltest2_py --tool-api --coin=xmr
  406. - $tooltest2_py --tool-api --coin=zec
  407. - $tooltest2_py
  408. - $tooltest2_py --testnet=1
  409. - $tooltest2_py --coin=ltc
  410. - $tooltest2_py --coin=ltc --testnet=1
  411. - $tooltest2_py --coin=bch
  412. - $tooltest2_py --coin=bch --testnet=1
  413. - $tooltest2_py --coin=zec
  414. - $tooltest2_py --coin=xmr
  415. - $tooltest2_py --coin=dash
  416. e $tooltest2_py --coin=eth
  417. e $tooltest2_py --coin=eth --testnet=1
  418. e $tooltest2_py --coin=eth --token=mm1
  419. e $tooltest2_py --coin=eth --token=mm1 --testnet=1
  420. e $tooltest2_py --coin=etc
  421. - $tooltest2_py --fork # run once with --fork so commands are actually executed
  422. "
  423. f_tool2='tooltest2 tests completed'
  424. [ "$SKIP_ALT_DEP" ] && t_tool2_skip='e' # skip ETH,ETC: txview requires py_ecc
  425. i_tool='Tooltest'
  426. s_tool="The following tests will run '$tooltest_py' for all supported coins"
  427. t_tool="
  428. - $tooltest_py --coin=btc cryptocoin
  429. - $tooltest_py --coin=btc mnemonic
  430. - $tooltest_py --coin=ltc cryptocoin
  431. - $tooltest_py --coin=eth cryptocoin
  432. - $tooltest_py --coin=etc cryptocoin
  433. - $tooltest_py --coin=dash cryptocoin
  434. - $tooltest_py --coin=doge cryptocoin
  435. - $tooltest_py --coin=emc cryptocoin
  436. - $tooltest_py --coin=zec cryptocoin
  437. z $tooltest_py --coin=zec --type=zcash_z cryptocoin
  438. "
  439. [ "$MSYS2" ] && t_tool_skip='z'
  440. f_tool='tooltest tests completed'
  441. i_gen='Gentest'
  442. s_gen="The following tests will run '$gentest_py' for BTC and LTC mainnet and testnet"
  443. t_gen="
  444. - # speed tests, no verification:
  445. - $gentest_py --coin=btc 2 $rounds
  446. - $gentest_py --coin=btc --type=compressed 2 $rounds
  447. - $gentest_py --coin=btc --type=segwit 2 $rounds
  448. - $gentest_py --coin=btc --type=bech32 2 $rounds
  449. - $gentest_py --coin=ltc 2 $rounds
  450. - $gentest_py --coin=ltc --type=compressed 2 $rounds
  451. - $gentest_py --coin=ltc --type=segwit 2 $rounds
  452. - $gentest_py --coin=ltc --type=bech32 2 $rounds
  453. - # wallet dumps:
  454. - $gentest_py 2 $REFDIR/btcwallet.dump
  455. - $gentest_py --type=segwit 2 $REFDIR/btcwallet-segwit.dump
  456. - $gentest_py --type=bech32 2 $REFDIR/btcwallet-bech32.dump
  457. - $gentest_py --testnet=1 2 $REFDIR/btcwallet-testnet.dump
  458. - $gentest_py --coin=ltc 2 $REFDIR/litecoin/ltcwallet.dump
  459. - $gentest_py --coin=ltc --type=segwit 2 $REFDIR/litecoin/ltcwallet-segwit.dump
  460. - $gentest_py --coin=ltc --type=bech32 2 $REFDIR/litecoin/ltcwallet-bech32.dump
  461. - $gentest_py --coin=ltc --testnet=1 2 $REFDIR/litecoin/ltcwallet-testnet.dump
  462. - # libsecp256k1 vs python-ecdsa:
  463. - $gentest_py 1:2 $rounds
  464. - $gentest_py --type=segwit 1:2 $rounds
  465. - $gentest_py --type=bech32 1:2 $rounds
  466. - $gentest_py --testnet=1 1:2 $rounds
  467. - $gentest_py --testnet=1 --type=segwit 1:2 $rounds
  468. - $gentest_py --coin=ltc 1:2 $rounds
  469. - $gentest_py --coin=ltc --type=segwit 1:2 $rounds
  470. - $gentest_py --coin=ltc --testnet=1 1:2 $rounds
  471. - $gentest_py --coin=ltc --testnet=1 --type=segwit 1:2 $rounds
  472. "
  473. f_gen='gentest tests completed'
  474. [ -d .git -a -n "$INSTALL" -a -z "$LIST_CMDS" ] && {
  475. check
  476. uninstall
  477. install
  478. cd .test-release/pydist/mmgen-*
  479. }
  480. [ "$INSTALL_ONLY" ] && exit
  481. prompt_skip() {
  482. echo -n "Enter 's' to skip, or ENTER to continue: "; read -n1; echo
  483. [ "$REPLY" == 's' ] && return 0
  484. return 1
  485. }
  486. run_tests() {
  487. [ "$LIST_CMDS" ] || echo "Running tests: $1"
  488. for t in $1; do
  489. if [ "$SKIP_ALT_DEP" ]; then
  490. ok=$(for a in $noalt_tests; do if [ $t == $a ]; then echo 'ok'; fi; done)
  491. if [ ! "$ok" ]; then
  492. echo -e "${BLUE}Skipping altcoin test '$t'$RESET"
  493. continue
  494. fi
  495. fi
  496. if [ "$LIST_CMDS" ]; then
  497. eval echo -e '\\n#' $(echo \$i_$t) "\($t\)"
  498. else
  499. eval echo -e "'\n'"\${GREEN}'###' Running $(echo \$i_$t) tests\$RESET
  500. eval echo -e $(echo \$s_$t)
  501. fi
  502. [ "$PAUSE" ] && prompt_skip && continue
  503. CUR_TEST=$t
  504. do_test $t
  505. [ "$LIST_CMDS" ] || eval echo -e $(echo \$f_$t)
  506. done
  507. }
  508. check_args() {
  509. for i in $tests; do
  510. echo "$dfl_tests $extra_tests" | grep -q "\<$i\>" || {
  511. echo "$i: unrecognized argument"
  512. exit 1
  513. }
  514. done
  515. }
  516. remove_skipped_tests() {
  517. tests=$(for t in $tests; do
  518. [ "$(for s in $SKIP_LIST; do [ $t == $s ] && echo y; done)" ] && continue
  519. echo $t
  520. done)
  521. tests=$(echo $tests)
  522. }
  523. remove_skipped_tests
  524. check_args
  525. start_time=$(date +%s)
  526. run_tests "$tests"
  527. elapsed=$(($(date +%s)-start_time))
  528. elapsed_fmt=$(printf %02d:%02d $((elapsed/60)) $((elapsed%60)))
  529. [ "$LIST_CMDS" ] || {
  530. if [ "$MMGEN_TEST_SUITE_DETERMINISTIC" ]; then
  531. echo -e "${GREEN}All OK"
  532. else
  533. echo -e "${GREEN}All OK. Total elapsed time: $elapsed_fmt$RESET"
  534. fi
  535. }