test-release.sh 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. #!/bin/bash
  2. # Tested on Linux, Armbian, Raspbian, MSYS2
  3. REFDIR='test/ref'
  4. if [ "$(uname -m)" == 'armv7l' ]; then
  5. ARM32=1
  6. elif [ "$(uname -m)" == 'aarch64' ]; then
  7. ARM64=1
  8. elif uname -a | grep -q 'MSYS'; then
  9. MSYS2=1;
  10. fi
  11. trap 'echo -e "${GREEN}Exiting at user request$RESET"; exit' INT
  12. umask 0022
  13. export MMGEN_TEST_SUITE=1
  14. export MMGEN_NO_LICENSE=1
  15. export PYTHONPATH=.
  16. test_py='test/test.py -n'
  17. objtest_py='test/objtest.py'
  18. objattrtest_py='test/objattrtest.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_mod_opts='--quiet'
  25. mmgen_tool='cmds/mmgen-tool'
  26. python='python3'
  27. rounds=100 rounds_min=20 rounds_mid=250 rounds_max=500
  28. 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'
  29. extra_tests='dep autosign_btc autosign_live ltc_tn bch_tn'
  30. noalt_tests='dep misc obj color unit hash ref autosign_btc btc btc_tn btc_rt tool tool2 gen'
  31. quick_tests='dep misc obj color unit hash ref altref alts xmr eth autosign btc btc_rt tool tool2 gen'
  32. qskip_tests='btc_tn bch bch_rt ltc ltc_rt'
  33. [ "$MSYS2" ] && SKIP_LIST='autosign autosign_btc autosign_live'
  34. ORIG_ARGS=$@
  35. PROGNAME=$(basename $0)
  36. while getopts hAbCdDfFlNOps:StvV OPT
  37. do
  38. case "$OPT" in
  39. h) printf " %-16s Test MMGen release\n" "${PROGNAME}:"
  40. echo " USAGE: $PROGNAME [options] [tests or test group]"
  41. echo " OPTIONS: -h Print this help message"
  42. echo " -A Skip tests requiring altcoin modules or daemons"
  43. echo " -b Buffer keypresses for all invocations of 'test/test.py'"
  44. echo " -C Run tests in coverage mode"
  45. echo " -d Enable Python Development Mode"
  46. echo " -D Run tests in deterministic mode"
  47. echo " -f Speed up the tests by using fewer rounds"
  48. echo " -F Reduce rounds even further"
  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 " -S Build SDIST distribution, unpack, and run test"
  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
  95. test_py+=" --no-altcoin"
  96. unit_tests_py+=" --no-altcoin-deps"
  97. scrambletest_py+=" --no-altcoin" ;;
  98. b) test_py+=" --buf-keypress" ;;
  99. C) mkdir -p 'test/trace'
  100. touch 'test/trace.acc'
  101. test_py+=" --coverage"
  102. tooltest_py+=" --coverage"
  103. tooltest2_py+=" --fork --coverage"
  104. scrambletest_py+=" --coverage"
  105. python="python3 -m trace --count --file=test/trace.acc --coverdir=test/trace"
  106. unit_tests_py="$python $unit_tests_py"
  107. objtest_py="$python $objtest_py"
  108. objattrtest_py="$python $objattrtest_py"
  109. gentest_py="$python $gentest_py"
  110. mmgen_tool="$python $mmgen_tool" ;&
  111. d) export PYTHONDEVMODE=1
  112. export PYTHONWARNINGS='error' ;;
  113. D) export MMGEN_TEST_SUITE_DETERMINISTIC=1
  114. export MMGEN_DISABLE_COLOR=1 ;;
  115. f) FAST=1 rounds=10 rounds_min=3 rounds_mid=25 rounds_max=50 unit_tests_py+=" --fast" ;;
  116. F) FAST=1 rounds=3 rounds_min=1 rounds_mid=3 rounds_max=5 unit_tests_py+=" --fast" ;;
  117. l) echo -e "Default tests:\n $dfl_tests"
  118. echo -e "Extra tests:\n $extra_tests"
  119. echo -e "'noalt' test group:\n $noalt_tests"
  120. echo -e "'quick' test group:\n $quick_tests"
  121. echo -e "'qskip' test group:\n $qskip_tests"
  122. exit ;;
  123. N) test_py+=" --no-timings" ;;
  124. O) test_py+=" --pexpect-spawn" ;;
  125. p) PAUSE=1 ;;
  126. s) SKIP_LIST+=" $OPTARG" ;;
  127. S) SDIST_TEST=1 ;;
  128. t) LIST_CMDS=1 ;;
  129. v) EXACT_OUTPUT=1 test_py+=" --exact-output" ;&
  130. V) VERBOSE='--verbose'
  131. [ "$EXACT_OUTPUT" ] || test_py+=" --verbose"
  132. unit_tests_py="${unit_tests_py/--quiet/--verbose}"
  133. altcoin_mod_opts="${altcoin_mod_opts/--quiet/--verbose}"
  134. tooltest2_py="${tooltest2_py/--quiet/--verbose}"
  135. gentest_py="${gentest_py/--quiet/--verbose}"
  136. tooltest_py+=" --verbose"
  137. mmgen_tool+=" --verbose"
  138. objattrtest_py+=" --verbose"
  139. scrambletest_py+=" --verbose" ;;
  140. *) exit ;;
  141. esac
  142. done
  143. [ "$MMGEN_DISABLE_COLOR" ] || {
  144. RED="\e[31;1m" GREEN="\e[32;1m" YELLOW="\e[33;1m" BLUE="\e[34;1m" MAGENTA="\e[35;1m" CYAN="\e[36;1m"
  145. RESET="\e[0m"
  146. }
  147. [ "$MSYS2" -a ! "$FAST" ] && tooltest2_py+=' --fork'
  148. [ "$EXACT_OUTPUT" -o "$VERBOSE" ] || objtest_py+=" -S"
  149. shift $((OPTIND-1))
  150. [ "$SDIST_TEST" -a -z "$MMGEN_TEST_RELEASE_IN_SDIST" ] && {
  151. test_dir='.sdist-test'
  152. rm -rf build dist MMGen.egg-info $test_dir
  153. python3 -m build --no-isolation --sdist
  154. mkdir $test_dir
  155. tar -C $test_dir -axf dist/*.tar.gz
  156. cd $test_dir/MMGen-*
  157. python3 setup.py build_ext --inplace
  158. echo -e "\n${BLUE}Running 'test/test-release $ORIG_ARGS'$RESET $YELLOW[PWD=$PWD]$RESET\n"
  159. export MMGEN_TEST_RELEASE_IN_SDIST=1
  160. test/test-release.sh $ORIG_ARGS
  161. exit
  162. }
  163. case $1 in
  164. '') tests=$dfl_tests ;;
  165. 'default') tests=$dfl_tests ;;
  166. 'extra') tests=$extra_tests ;;
  167. 'noalt') tests=$noalt_tests
  168. SKIP_ALT_DEP=1
  169. test_py+=" --no-altcoin"
  170. unit_tests_py+=" --no-altcoin-deps"
  171. scrambletest_py+=" --no-altcoin" ;;
  172. 'quick') tests=$quick_tests ;;
  173. 'qskip') tests=$qskip_tests ;;
  174. *) tests="$*" ;;
  175. esac
  176. set -e
  177. do_test() {
  178. set +x
  179. tests="t_$1"
  180. skips="t_$1_skip"
  181. while read skip test; do
  182. [ "$test" ] || continue
  183. echo "${!skips}" | grep -q $skip && continue
  184. if [ "$LIST_CMDS" ]; then
  185. echo $test
  186. else
  187. test_disp=$YELLOW${test/\#/$RESET$MAGENTA\#}$RESET
  188. if [ "${test:0:1}" == '#' ]; then
  189. echo -e "$test_disp"
  190. else
  191. echo -e "${GREEN}Running:$RESET $test_disp"
  192. eval "$test" || {
  193. echo -e $RED"test-release.sh: test '$CUR_TEST' failed at command '$test'"$RESET
  194. exit 1
  195. }
  196. fi
  197. fi
  198. done <<<${!tests}
  199. }
  200. i_misc='Miscellaneous'
  201. s_misc='Testing various subsystems'
  202. t_misc="
  203. - python3 -m mmgen.altcoin $altcoin_mod_opts
  204. "
  205. f_misc='Miscellaneous tests completed'
  206. i_obj='Data object'
  207. s_obj='Testing data objects'
  208. t_obj="
  209. - $objtest_py --coin=btc
  210. - $objtest_py --getobj --coin=btc
  211. - $objtest_py --coin=btc --testnet=1
  212. - $objtest_py --coin=ltc
  213. - $objtest_py --coin=ltc --testnet=1
  214. - $objtest_py --coin=eth
  215. - $objattrtest_py
  216. "
  217. f_obj='Data object tests completed'
  218. [ "$PYTHONOPTIMIZE" ] && {
  219. echo -e "${YELLOW}PYTHONOPTIMIZE set, skipping object tests$RESET"
  220. t_obj_skip='-'
  221. }
  222. i_color='Color'
  223. s_color='Testing terminal colors'
  224. t_color="- $colortest_py"
  225. f_color='Terminal color tests completed'
  226. i_dep='Dependency'
  227. s_dep='Testing for installed dependencies'
  228. t_dep="- $unit_tests_py testdep dep daemon.exec"
  229. f_dep='Dependency tests completed'
  230. i_unit='Unit'
  231. s_unit='The bitcoin and bitcoin-bchn mainnet daemons must be running for the following tests'
  232. t_unit="- $unit_tests_py --exclude testdep,dep,daemon"
  233. f_unit='Unit tests completed'
  234. i_hash='Internal hash function implementations'
  235. s_hash='Testing internal hash function implementations'
  236. t_hash="
  237. 256 $python test/hashfunc.py sha256 $rounds_max
  238. 512 $python test/hashfunc.py sha512 $rounds_max # native SHA512 - not used by the MMGen wallet
  239. keccak $python test/hashfunc.py keccak $rounds_max
  240. ripemd160 $python mmgen/contrib/ripemd160.py $VERBOSE
  241. "
  242. f_hash='Hash function tests completed'
  243. [ "$ARM32" ] && t_hash_skip='512' # gmpy produces invalid init constants
  244. [ "$MSYS2" ] && t_hash_skip='512 keccak' # 2:py_long_long issues, 3:no pysha3 for keccak reference
  245. [ "$SKIP_ALT_DEP" ] && t_hash_skip+=' keccak'
  246. i_ref='Miscellaneous reference data'
  247. s_ref='The following tests will test some generated values against reference data'
  248. t_ref="
  249. - $scrambletest_py
  250. "
  251. f_ref='Miscellaneous reference data tests completed'
  252. i_altref='Altcoin reference file'
  253. s_altref='The following tests will test some generated altcoin files against reference data'
  254. t_altref="
  255. - $test_py ref_altcoin # generated addrfiles verified against checksums
  256. "
  257. f_altref='Altcoin reference file tests completed'
  258. i_alts='Gen-only altcoin'
  259. s_alts='The following tests will test generation operations for all supported altcoins'
  260. t_alts="
  261. - # speed tests, no verification:
  262. - $gentest_py --coin=etc 1 $rounds
  263. - $gentest_py --coin=etc --use-internal-keccak-module 1 $rounds_min
  264. - $gentest_py --coin=eth 1 $rounds
  265. - $gentest_py --coin=eth --use-internal-keccak-module 1 $rounds_min
  266. - $gentest_py --coin=xmr 1 $rounds
  267. - $gentest_py --coin=xmr --use-internal-keccak-module 1 $rounds_min
  268. - $gentest_py --coin=zec 1 $rounds
  269. - $gentest_py --coin=zec --type=zcash_z 1 $rounds_mid
  270. - # verification against external libraries and tools:
  271. - # pycoin
  272. - $gentest_py --all-coins --type=legacy 1:pycoin $rounds
  273. - $gentest_py --all-coins --type=compressed 1:pycoin $rounds
  274. - $gentest_py --all-coins --type=segwit 1:pycoin $rounds
  275. - $gentest_py --all-coins --type=bech32 1:pycoin $rounds
  276. - $gentest_py --all-coins --type=legacy --testnet=1 1:pycoin $rounds
  277. - $gentest_py --all-coins --type=compressed --testnet=1 1:pycoin $rounds
  278. - $gentest_py --all-coins --type=segwit --testnet=1 1:pycoin $rounds
  279. - $gentest_py --all-coins --type=bech32 --testnet=1 1:pycoin $rounds
  280. - # keyconv
  281. - $gentest_py --all-coins --type=legacy 1:keyconv $rounds
  282. - $gentest_py --all-coins --type=compressed 1:keyconv $rounds
  283. e # ethkey
  284. e $gentest_py --coin=eth 1:ethkey $rounds
  285. e $gentest_py --coin=eth --use-internal-keccak-module 2:ethkey $rounds_mid
  286. m # moneropy
  287. m $gentest_py --coin=xmr all:moneropy $rounds_mid # very slow, please be patient!
  288. z # zcash-mini
  289. z $gentest_py --coin=zec --type=zcash_z all:zcash-mini $rounds_mid
  290. "
  291. [ "$MSYS2" ] && t_alts_skip='m z' # no moneropy (pysha3), zcash-mini (golang)
  292. [ "$ARM32" ] && t_alts_skip='z e'
  293. f_alts='Gen-only altcoin tests completed'
  294. create_tmpdir() {
  295. if [ "$MSYS2" ]; then
  296. TMPDIR='/tmp/mmgen-test-release'
  297. else
  298. TMPDIR='/tmp/mmgen-test-release-'$(cat /dev/urandom | base32 - | head -n1 | cut -b 1-16)
  299. fi
  300. mkdir -p $TMPDIR
  301. }
  302. rm -rf /tmp/mmgen-test-release*
  303. create_tmpdir
  304. i_xmr='Monero'
  305. s_xmr='Testing Monero operations'
  306. t_xmr="
  307. - $test_py --coin=xmr
  308. "
  309. f_xmr='Monero tests completed'
  310. i_eth='Ethereum'
  311. s_eth='Testing transaction and tracking wallet operations for Ethereum'
  312. t_eth="
  313. oe $test_py --coin=eth --daemon-id=openethereum ethdev
  314. geth $test_py --coin=eth --daemon-id=geth ethdev
  315. parity $test_py --coin=etc ethdev
  316. "
  317. f_eth='Ethereum tests completed'
  318. [ "$FAST" ] && t_eth_skip='oe'
  319. [ "$ARM32" -o "$ARM64" ] && t_eth_skip='oe parity'
  320. i_autosign='Autosign'
  321. s_autosign='The bitcoin, bitcoin-bchn and litecoin mainnet and testnet daemons must be running for the following test'
  322. t_autosign="- $test_py autosign"
  323. f_autosign='Autosign test completed'
  324. i_autosign_btc='Autosign BTC'
  325. s_autosign_btc='The bitcoin mainnet and testnet daemons must be running for the following test'
  326. t_autosign_btc="- $test_py autosign_btc"
  327. f_autosign_btc='Autosign BTC test completed'
  328. i_autosign_live='Autosign Live'
  329. s_autosign_live="The bitcoin mainnet and testnet daemons must be running for the following test\n"
  330. s_autosign_live+="${YELLOW}Mountpoint, '/etc/fstab' and removable device must be configured "
  331. s_autosign_live+="as described in 'mmgen-autosign --help'${RESET}"
  332. t_autosign_live="- $test_py autosign_live"
  333. f_autosign_live='Autosign Live test completed'
  334. i_btc='Bitcoin mainnet'
  335. s_btc='The bitcoin (mainnet) daemon must both be running for the following tests'
  336. t_btc="
  337. - $test_py --exclude regtest,autosign,ref_altcoin
  338. - $test_py --segwit
  339. - $test_py --segwit-random
  340. - $test_py --bech32
  341. - $python scripts/compute-file-chksum.py $REFDIR/*testnet.rawtx >/dev/null 2>&1
  342. "
  343. f_btc='Bitcoin mainnet tests completed'
  344. i_btc_tn='Bitcoin testnet'
  345. s_btc_tn='The bitcoin testnet daemon must both be running for the following tests'
  346. t_btc_tn="
  347. - $test_py --testnet=1
  348. - $test_py --testnet=1 --segwit
  349. - $test_py --testnet=1 --segwit-random
  350. - $test_py --testnet=1 --bech32
  351. "
  352. f_btc_tn='Bitcoin testnet tests completed'
  353. i_btc_rt='Bitcoin regtest'
  354. s_btc_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  355. t_btc_rt="- $test_py regtest"
  356. f_btc_rt='Regtest (Bob and Alice) mode tests for BTC completed'
  357. i_bch='BitcoinCashNode (BCH) mainnet'
  358. s_bch='The bitcoin-bchn mainnet daemon must both be running for the following tests'
  359. t_bch="- $test_py --coin=bch --exclude regtest"
  360. f_bch='BitcoinCashNode (BCH) mainnet tests completed'
  361. i_bch_tn='BitcoinCashNode (BCH) testnet'
  362. s_bch_tn='The bitcoin-bchn testnet daemon must both be running for the following tests'
  363. t_bch_tn="- $test_py --coin=bch --testnet=1 --exclude regtest"
  364. f_bch_tn='BitcoinCashNode (BCH) testnet tests completed'
  365. i_bch_rt='BitcoinCashNode (BCH) regtest'
  366. s_bch_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  367. t_bch_rt="- $test_py --coin=bch regtest"
  368. f_bch_rt='Regtest (Bob and Alice) mode tests for BCH completed'
  369. i_ltc='Litecoin'
  370. s_ltc='The litecoin mainnet daemon must both be running for the following tests'
  371. t_ltc="
  372. - $test_py --coin=ltc --exclude regtest
  373. - $test_py --coin=ltc --segwit
  374. - $test_py --coin=ltc --segwit-random
  375. - $test_py --coin=ltc --bech32
  376. "
  377. f_ltc='Litecoin mainnet tests completed'
  378. i_ltc_tn='Litecoin testnet'
  379. s_ltc_tn='The litecoin testnet daemon must both be running for the following tests'
  380. t_ltc_tn="
  381. - $test_py --coin=ltc --testnet=1 --exclude regtest
  382. - $test_py --coin=ltc --testnet=1 --segwit
  383. - $test_py --coin=ltc --testnet=1 --segwit-random
  384. - $test_py --coin=ltc --testnet=1 --bech32
  385. "
  386. f_ltc_tn='Litecoin testnet tests completed'
  387. i_ltc_rt='Litecoin regtest'
  388. s_ltc_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  389. t_ltc_rt="- $test_py --coin=ltc regtest"
  390. f_ltc_rt='Regtest (Bob and Alice) mode tests for LTC completed'
  391. i_tool2='Tooltest2'
  392. s_tool2="The following tests will run '$tooltest2_py' for all supported coins"
  393. t_tool2="
  394. - $tooltest2_py --tool-api # test the tool_api subsystem
  395. - $tooltest2_py --tool-api --testnet=1
  396. e $tooltest2_py --tool-api --coin=eth
  397. a $tooltest2_py --tool-api --coin=xmr
  398. a $tooltest2_py --tool-api --coin=zec
  399. - $tooltest2_py
  400. - $tooltest2_py --testnet=1
  401. a $tooltest2_py --coin=ltc
  402. a $tooltest2_py --coin=ltc --testnet=1
  403. a $tooltest2_py --coin=bch
  404. a $tooltest2_py --coin=bch --testnet=1
  405. a $tooltest2_py --coin=zec
  406. a $tooltest2_py --coin=xmr
  407. a $tooltest2_py --coin=dash
  408. e $tooltest2_py --coin=eth
  409. e $tooltest2_py --coin=eth --testnet=1
  410. e $tooltest2_py --coin=eth --token=mm1
  411. e $tooltest2_py --coin=eth --token=mm1 --testnet=1
  412. e $tooltest2_py --coin=etc
  413. - $tooltest2_py --fork # run once with --fork so commands are actually executed
  414. "
  415. f_tool2='tooltest2 tests completed'
  416. [ "$SKIP_ALT_DEP" ] && t_tool2_skip='a e' # skip ETH,ETC: txview requires py_ecc
  417. i_tool='Tooltest'
  418. s_tool="The following tests will run '$tooltest_py' for all supported coins"
  419. t_tool="
  420. - $tooltest_py --coin=btc cryptocoin
  421. - $tooltest_py --coin=btc mnemonic
  422. a $tooltest_py --coin=ltc cryptocoin
  423. a $tooltest_py --coin=eth cryptocoin
  424. a $tooltest_py --coin=etc cryptocoin
  425. a $tooltest_py --coin=dash cryptocoin
  426. a $tooltest_py --coin=doge cryptocoin
  427. a $tooltest_py --coin=emc cryptocoin
  428. a $tooltest_py --coin=xmr cryptocoin
  429. a $tooltest_py --coin=zec cryptocoin
  430. z $tooltest_py --coin=zec --type=zcash_z cryptocoin
  431. "
  432. [ "$MSYS2" -o "$ARM32" ] && t_tool_skip='z'
  433. [ "$SKIP_ALT_DEP" ] && t_tool_skip='a z'
  434. f_tool='tooltest tests completed'
  435. i_gen='Gentest'
  436. s_gen="The following tests will run '$gentest_py' for configured coins and address types"
  437. t_gen="
  438. - # speed tests, no verification:
  439. - $gentest_py --coin=btc 1 $rounds
  440. - $gentest_py --coin=btc --type=compressed 1 $rounds
  441. - $gentest_py --coin=btc --type=segwit 1 $rounds
  442. - $gentest_py --coin=btc --type=bech32 1 $rounds
  443. a $gentest_py --coin=ltc 1 $rounds
  444. a $gentest_py --coin=ltc --type=compressed 1 $rounds
  445. a $gentest_py --coin=ltc --type=segwit 1 $rounds
  446. a $gentest_py --coin=ltc --type=bech32 1 $rounds
  447. - # wallet dumps:
  448. - $gentest_py --type=compressed 1 $REFDIR/btcwallet.dump
  449. - $gentest_py --type=segwit 1 $REFDIR/btcwallet-segwit.dump
  450. - $gentest_py --type=bech32 1 $REFDIR/btcwallet-bech32.dump
  451. - $gentest_py --type=compressed --testnet=1 1 $REFDIR/btcwallet-testnet.dump
  452. a $gentest_py --coin=ltc --type=compressed 1 $REFDIR/litecoin/ltcwallet.dump
  453. a $gentest_py --coin=ltc --type=segwit 1 $REFDIR/litecoin/ltcwallet-segwit.dump
  454. a $gentest_py --coin=ltc --type=bech32 1 $REFDIR/litecoin/ltcwallet-bech32.dump
  455. a $gentest_py --coin=ltc --type=compressed --testnet=1 1 $REFDIR/litecoin/ltcwallet-testnet.dump
  456. - # libsecp256k1 vs python-ecdsa:
  457. - $gentest_py 1:2 $rounds
  458. - $gentest_py --type=segwit 1:2 $rounds
  459. - $gentest_py --type=bech32 1:2 $rounds
  460. - $gentest_py --testnet=1 1:2 $rounds
  461. - $gentest_py --testnet=1 --type=segwit 1:2 $rounds
  462. a $gentest_py --coin=ltc 1:2 $rounds
  463. a $gentest_py --coin=ltc --type=segwit 1:2 $rounds
  464. a $gentest_py --coin=ltc --testnet=1 1:2 $rounds
  465. a $gentest_py --coin=ltc --testnet=1 --type=segwit 1:2 $rounds
  466. - # all backends vs pycoin:
  467. - $gentest_py all:pycoin $rounds
  468. "
  469. [ "$SKIP_ALT_DEP" ] && t_gen_skip='a'
  470. f_gen='gentest tests completed'
  471. prompt_skip() {
  472. echo -n "Enter 's' to skip, or ENTER to continue: "; read -n1; echo
  473. [ "$REPLY" == 's' ] && return 0
  474. return 1
  475. }
  476. run_tests() {
  477. [ "$LIST_CMDS" ] || echo "Running tests: $1"
  478. for t in $1; do
  479. if [ "$SKIP_ALT_DEP" ]; then
  480. ok=$(for a in $noalt_tests; do if [ $t == $a ]; then echo 'ok'; fi; done)
  481. if [ ! "$ok" ]; then
  482. echo -e "${BLUE}Skipping altcoin test '$t'$RESET"
  483. continue
  484. fi
  485. fi
  486. if [ "$LIST_CMDS" ]; then
  487. eval echo -e '\\n#' $(echo \$i_$t) "\($t\)"
  488. else
  489. eval echo -e "'\n'"\${GREEN}'###' Running $(echo \$i_$t) tests\$RESET
  490. eval echo -e $(echo \$s_$t)
  491. fi
  492. [ "$PAUSE" ] && prompt_skip && continue
  493. CUR_TEST=$t
  494. do_test $t
  495. [ "$LIST_CMDS" ] || eval echo -e $(echo \$f_$t)
  496. done
  497. }
  498. check_tests() {
  499. for i in $tests; do
  500. echo "$dfl_tests $extra_tests" | grep -q "\<$i\>" || {
  501. echo "$i: unrecognized argument"
  502. exit 1
  503. }
  504. done
  505. }
  506. remove_skipped_tests() {
  507. tests=$(for t in $tests; do
  508. [ "$(for s in $SKIP_LIST; do [ $t == $s ] && echo y; done)" ] && continue
  509. echo $t
  510. done)
  511. tests=$(echo $tests)
  512. }
  513. remove_skipped_tests
  514. check_tests
  515. start_time=$(date +%s)
  516. run_tests "$tests"
  517. elapsed=$(($(date +%s)-start_time))
  518. elapsed_fmt=$(printf %02d:%02d $((elapsed/60)) $((elapsed%60)))
  519. [ "$LIST_CMDS" ] || {
  520. if [ "$MMGEN_TEST_SUITE_DETERMINISTIC" ]; then
  521. echo -e "${GREEN}All OK"
  522. else
  523. echo -e "${GREEN}All OK. Total elapsed time: $elapsed_fmt$RESET"
  524. fi
  525. }