test-release.sh 21 KB

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