test-release.sh 21 KB

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