test-release.sh 18 KB

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