test-release.sh 21 KB

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