test-release.sh 19 KB

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