test-release.sh 21 KB

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