cfg.sh 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. #!/bin/bash
  2. #
  3. # mmgen = Multi-Mode GENerator, a command-line cryptocurrency wallet
  4. # Copyright (C)2013-2022 The MMGen Project <mmgen@tuta.io>
  5. # Licensed under the GNU General Public License, Version 3:
  6. # https://www.gnu.org/licenses
  7. # Public project repositories:
  8. # https://github.com/mmgen/mmgen
  9. # https://gitlab.com/mmgen/mmgen
  10. list_avail_tests() {
  11. echo "AVAILABLE TESTS:"
  12. echo " obj - data objects"
  13. echo " color - color handling"
  14. echo " unit - unit tests"
  15. echo " hash - internal hash function implementations"
  16. echo " ref - reference file checks"
  17. echo " altref - altcoin reference file checks"
  18. echo " alts - operations for all supported gen-only altcoins"
  19. echo " xmr - Monero xmrwallet operations"
  20. echo " eth - operations for Ethereum and Ethereum Classic"
  21. echo " autosign - autosign"
  22. echo " btc - Bitcoin"
  23. echo " btc_tn - Bitcoin testnet"
  24. echo " btc_rt - Bitcoin regtest"
  25. echo " bch - Bitcoin Cash Node (BCH)"
  26. echo " bch_tn - Bitcoin Cash Node (BCH) testnet"
  27. echo " bch_rt - Bitcoin Cash Node (BCH) regtest"
  28. echo " ltc - Litecoin"
  29. echo " ltc_tn - Litecoin testnet"
  30. echo " ltc_rt - Litecoin regtest"
  31. echo " tool - tooltest (all supported coins)"
  32. echo " tool2 - tooltest2 (all supported coins)"
  33. echo " gen - gentest (all supported coins)"
  34. echo " misc - miscellaneous tests that don't fit in the above categories"
  35. echo
  36. echo "AVAILABLE TEST GROUPS:"
  37. echo " default - All tests minus the extra tests"
  38. echo " extra - All tests minus the default tests"
  39. echo " noalt - BTC-only tests"
  40. echo " quick - Default tests minus btc_tn, bch, bch_rt, ltc and ltc_rt"
  41. echo " qskip - The tests skipped in the 'quick' test group"
  42. echo
  43. echo "By default, all tests are run"
  44. }
  45. init_groups() {
  46. dfl_tests='dep misc obj color unit hash ref tool tool2 gen autosign btc btc_tn btc_rt altref alts bch bch_rt ltc ltc_rt eth xmr'
  47. extra_tests='dep autosign_btc autosign_live ltc_tn bch_tn'
  48. noalt_tests='dep misc obj color unit hash ref tool tool2 gen autosign_btc btc btc_tn btc_rt'
  49. quick_tests='dep misc obj color unit hash ref tool tool2 gen autosign btc btc_rt altref alts eth xmr'
  50. qskip_tests='btc_tn bch bch_rt ltc ltc_rt'
  51. [ "$MSYS2" ] && SKIP_LIST='autosign autosign_btc autosign_live'
  52. }
  53. init_tests() {
  54. REFDIR='test/ref'
  55. i_misc='Miscellaneous'
  56. s_misc='Testing various subsystems'
  57. t_misc="
  58. - python3 -m mmgen.altcoin $altcoin_mod_opts
  59. "
  60. f_misc='Miscellaneous tests completed'
  61. i_obj='Data object'
  62. s_obj='Testing data objects'
  63. t_obj="
  64. - $objtest_py --coin=btc
  65. - $objtest_py --getobj --coin=btc
  66. - $objtest_py --coin=btc --testnet=1
  67. - $objtest_py --coin=ltc
  68. - $objtest_py --coin=ltc --testnet=1
  69. - $objtest_py --coin=eth
  70. - $objattrtest_py
  71. "
  72. f_obj='Data object tests completed'
  73. [ "$PYTHONOPTIMIZE" ] && {
  74. echo -e "${YELLOW}PYTHONOPTIMIZE set, skipping object tests$RESET"
  75. t_obj_skip='-'
  76. }
  77. i_color='Color'
  78. s_color='Testing terminal colors'
  79. t_color='- test/colortest.py'
  80. f_color='Terminal color tests completed'
  81. i_dep='Dependency'
  82. s_dep='Testing for installed dependencies'
  83. t_dep="- $unit_tests_py testdep dep daemon.exec"
  84. f_dep='Dependency tests completed'
  85. i_unit='Unit'
  86. s_unit='The bitcoin and bitcoin-bchn mainnet daemons must be running for the following tests'
  87. t_unit="- $unit_tests_py --exclude testdep,dep,daemon"
  88. f_unit='Unit tests completed'
  89. i_hash='Internal hash function implementations'
  90. s_hash='Testing internal hash function implementations'
  91. t_hash="
  92. 256 $python test/hashfunc.py sha256 $rounds5x
  93. 512 $python test/hashfunc.py sha512 $rounds5x # native SHA512 - not used by the MMGen wallet
  94. keccak $python test/hashfunc.py keccak $rounds5x
  95. ripemd160 $python mmgen/contrib/ripemd160.py $VERBOSE $fast_opt
  96. "
  97. f_hash='Hash function tests completed'
  98. [ "$ARM32" ] && t_hash_skip='512' # gmpy produces invalid init constants
  99. [ "$MSYS2" ] && t_hash_skip='512 keccak' # 2:py_long_long issues, 3:no pysha3 for keccak reference
  100. [ "$SKIP_ALT_DEP" ] && t_hash_skip+=' keccak'
  101. i_ref='Miscellaneous reference data'
  102. s_ref='The following tests will test some generated values against reference data'
  103. t_ref="
  104. - $scrambletest_py
  105. "
  106. f_ref='Miscellaneous reference data tests completed'
  107. i_altref='Altcoin reference file'
  108. s_altref='The following tests will test some generated altcoin files against reference data'
  109. t_altref="
  110. - $test_py ref_altcoin # generated addrfiles verified against checksums
  111. "
  112. f_altref='Altcoin reference file tests completed'
  113. i_alts='Gen-only altcoin'
  114. s_alts='The following tests will test generation operations for all supported altcoins'
  115. t_alts="
  116. - # speed tests, no verification:
  117. - $gentest_py --coin=etc 1 $rounds10x
  118. - $gentest_py --coin=etc --use-internal-keccak-module 1 $rounds10x
  119. - $gentest_py --coin=eth 1 $rounds10x
  120. - $gentest_py --coin=eth --use-internal-keccak-module 1 $rounds10x
  121. - $gentest_py --coin=xmr 1 $rounds10x
  122. - $gentest_py --coin=xmr --use-internal-keccak-module 1 $rounds10x
  123. - $gentest_py --coin=zec 1 $rounds10x
  124. - $gentest_py --coin=zec --type=zcash_z 1 $rounds10x
  125. - # verification against external libraries and tools:
  126. - # pycoin
  127. - $gentest_py --all-coins --type=legacy 1:pycoin $rounds
  128. - $gentest_py --all-coins --type=compressed 1:pycoin $rounds
  129. - $gentest_py --all-coins --type=segwit 1:pycoin $rounds
  130. - $gentest_py --all-coins --type=bech32 1:pycoin $rounds
  131. - $gentest_py --all-coins --type=legacy --testnet=1 1:pycoin $rounds
  132. - $gentest_py --all-coins --type=compressed --testnet=1 1:pycoin $rounds
  133. - $gentest_py --all-coins --type=segwit --testnet=1 1:pycoin $rounds
  134. - $gentest_py --all-coins --type=bech32 --testnet=1 1:pycoin $rounds
  135. - # keyconv
  136. - $gentest_py --all-coins --type=legacy 1:keyconv $rounds_min
  137. - $gentest_py --all-coins --type=compressed 1:keyconv $rounds_min
  138. e # ethkey
  139. e $gentest_py --coin=eth 1:ethkey $rounds10x
  140. e $gentest_py --coin=eth --use-internal-keccak-module 2:ethkey $rounds5x
  141. m # monero-python
  142. m $gentest_py --coin=xmr 1:monero-python $rounds100x
  143. M $gentest_py --coin=xmr all:monero-python $rounds_min # very slow, please be patient!
  144. z # zcash-mini
  145. z $gentest_py --coin=zec --type=zcash_z all:zcash-mini $rounds50x
  146. "
  147. [ "$MSYS2" ] && t_alts_skip='M m z' # no moneropy (pysha3), zcash-mini (golang)
  148. [ "$ARM32" ] && t_alts_skip='z e'
  149. [ "$FAST" ] && t_alts_skip+=' M'
  150. # ARM ethkey available only on Arch Linux:
  151. [ \( "$ARM32" -o "$ARM64" \) -a "$DISTRO" != 'archarm' ] && t_alts_skip+=' e'
  152. f_alts='Gen-only altcoin tests completed'
  153. i_xmr='Monero'
  154. s_xmr='Testing Monero operations'
  155. t_xmr="
  156. - $test_py --coin=xmr
  157. "
  158. f_xmr='Monero tests completed'
  159. i_eth='Ethereum'
  160. s_eth='Testing transaction and tracking wallet operations for Ethereum'
  161. t_eth="
  162. oe $test_py --coin=eth --daemon-id=openethereum ethdev
  163. geth $test_py --coin=eth --daemon-id=geth ethdev
  164. parity $test_py --coin=etc ethdev
  165. "
  166. f_eth='Ethereum tests completed'
  167. [ "$FAST" ] && t_eth_skip='oe'
  168. [ "$ARM32" -o "$ARM64" ] && t_eth_skip+=' parity'
  169. # ARM openethereum available only on ArchLinuxArm:
  170. [ \( "$ARM32" -o "$ARM64" \) -a "$DISTRO" != 'archarm' ] && t_eth_skip+=' oe'
  171. i_autosign='Autosign'
  172. s_autosign='The bitcoin, bitcoin-bchn and litecoin mainnet and testnet daemons must be running for the following test'
  173. t_autosign="- $test_py autosign"
  174. f_autosign='Autosign test completed'
  175. i_autosign_btc='Autosign BTC'
  176. s_autosign_btc='The bitcoin mainnet and testnet daemons must be running for the following test'
  177. t_autosign_btc="- $test_py autosign_btc"
  178. f_autosign_btc='Autosign BTC test completed'
  179. i_autosign_live='Autosign Live'
  180. s_autosign_live="The bitcoin mainnet and testnet daemons must be running for the following test\n"
  181. s_autosign_live+="${YELLOW}Mountpoint, '/etc/fstab' and removable device must be configured "
  182. s_autosign_live+="as described in 'mmgen-autosign --help'${RESET}"
  183. t_autosign_live="- $test_py autosign_live"
  184. f_autosign_live='Autosign Live test completed'
  185. i_btc='Bitcoin mainnet'
  186. s_btc='The bitcoin (mainnet) daemon must both be running for the following tests'
  187. t_btc="
  188. - $test_py --exclude regtest,autosign,ref_altcoin
  189. - $test_py --segwit
  190. - $test_py --segwit-random
  191. - $test_py --bech32
  192. - $python scripts/compute-file-chksum.py $REFDIR/*testnet.rawtx >/dev/null 2>&1
  193. "
  194. f_btc='Bitcoin mainnet tests completed'
  195. i_btc_tn='Bitcoin testnet'
  196. s_btc_tn='The bitcoin testnet daemon must both be running for the following tests'
  197. t_btc_tn="
  198. - $test_py --testnet=1
  199. - $test_py --testnet=1 --segwit
  200. - $test_py --testnet=1 --segwit-random
  201. - $test_py --testnet=1 --bech32
  202. "
  203. f_btc_tn='Bitcoin testnet tests completed'
  204. i_btc_rt='Bitcoin regtest'
  205. s_btc_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  206. t_btc_rt="- $test_py regtest"
  207. f_btc_rt='Regtest (Bob and Alice) mode tests for BTC completed'
  208. i_bch='BitcoinCashNode (BCH) mainnet'
  209. s_bch='The bitcoin-bchn mainnet daemon must both be running for the following tests'
  210. t_bch="- $test_py --coin=bch --exclude regtest"
  211. f_bch='BitcoinCashNode (BCH) mainnet tests completed'
  212. i_bch_tn='BitcoinCashNode (BCH) testnet'
  213. s_bch_tn='The bitcoin-bchn testnet daemon must both be running for the following tests'
  214. t_bch_tn="- $test_py --coin=bch --testnet=1 --exclude regtest"
  215. f_bch_tn='BitcoinCashNode (BCH) testnet tests completed'
  216. i_bch_rt='BitcoinCashNode (BCH) regtest'
  217. s_bch_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  218. t_bch_rt="- $test_py --coin=bch regtest"
  219. f_bch_rt='Regtest (Bob and Alice) mode tests for BCH completed'
  220. i_ltc='Litecoin'
  221. s_ltc='The litecoin mainnet daemon must both be running for the following tests'
  222. t_ltc="
  223. - $test_py --coin=ltc --exclude regtest
  224. - $test_py --coin=ltc --segwit
  225. - $test_py --coin=ltc --segwit-random
  226. - $test_py --coin=ltc --bech32
  227. "
  228. f_ltc='Litecoin mainnet tests completed'
  229. i_ltc_tn='Litecoin testnet'
  230. s_ltc_tn='The litecoin testnet daemon must both be running for the following tests'
  231. t_ltc_tn="
  232. - $test_py --coin=ltc --testnet=1 --exclude regtest
  233. - $test_py --coin=ltc --testnet=1 --segwit
  234. - $test_py --coin=ltc --testnet=1 --segwit-random
  235. - $test_py --coin=ltc --testnet=1 --bech32
  236. "
  237. f_ltc_tn='Litecoin testnet tests completed'
  238. i_ltc_rt='Litecoin regtest'
  239. s_ltc_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  240. t_ltc_rt="- $test_py --coin=ltc regtest"
  241. f_ltc_rt='Regtest (Bob and Alice) mode tests for LTC completed'
  242. i_tool2='Tooltest2'
  243. s_tool2="The following tests will run '$tooltest2_py' for all supported coins"
  244. t_tool2="
  245. - $tooltest2_py --tool-api # test the tool_api subsystem
  246. - $tooltest2_py --tool-api --testnet=1
  247. e $tooltest2_py --tool-api --coin=eth
  248. a $tooltest2_py --tool-api --coin=xmr
  249. a $tooltest2_py --tool-api --coin=zec
  250. - $tooltest2_py
  251. - $tooltest2_py --testnet=1
  252. a $tooltest2_py --coin=ltc
  253. a $tooltest2_py --coin=ltc --testnet=1
  254. a $tooltest2_py --coin=bch
  255. a $tooltest2_py --coin=bch --testnet=1
  256. a $tooltest2_py --coin=zec
  257. a $tooltest2_py --coin=xmr
  258. a $tooltest2_py --coin=dash
  259. e $tooltest2_py --coin=eth
  260. e $tooltest2_py --coin=eth --testnet=1
  261. e $tooltest2_py --coin=eth --token=mm1
  262. e $tooltest2_py --coin=eth --token=mm1 --testnet=1
  263. e $tooltest2_py --coin=etc
  264. - $tooltest2_py --fork # run once with --fork so commands are actually executed
  265. "
  266. f_tool2='tooltest2 tests completed'
  267. [ "$SKIP_ALT_DEP" ] && t_tool2_skip='a e' # skip ETH,ETC: txview requires py_ecc
  268. i_tool='Tooltest'
  269. s_tool="The following tests will run '$tooltest_py' for all supported coins"
  270. t_tool="
  271. - $tooltest_py --coin=btc cryptocoin
  272. - $tooltest_py --coin=btc mnemonic
  273. a $tooltest_py --coin=ltc cryptocoin
  274. a $tooltest_py --coin=eth cryptocoin
  275. a $tooltest_py --coin=etc cryptocoin
  276. a $tooltest_py --coin=dash cryptocoin
  277. a $tooltest_py --coin=doge cryptocoin
  278. a $tooltest_py --coin=emc cryptocoin
  279. a $tooltest_py --coin=xmr cryptocoin
  280. a $tooltest_py --coin=zec cryptocoin
  281. z $tooltest_py --coin=zec --type=zcash_z cryptocoin
  282. "
  283. [ "$MSYS2" -o "$ARM32" ] && t_tool_skip='z'
  284. [ "$SKIP_ALT_DEP" ] && t_tool_skip='a z'
  285. f_tool='tooltest tests completed'
  286. i_gen='Gentest'
  287. s_gen="The following tests will run '$gentest_py' for configured coins and address types"
  288. t_gen="
  289. - # speed tests, no verification:
  290. - $gentest_py --coin=btc 1 $rounds10x
  291. - $gentest_py --coin=btc --type=compressed 1 $rounds10x
  292. - $gentest_py --coin=btc --type=segwit 1 $rounds10x
  293. - $gentest_py --coin=btc --type=bech32 1 $rounds10x
  294. a $gentest_py --coin=ltc 1 $rounds10x
  295. a $gentest_py --coin=ltc --type=compressed 1 $rounds10x
  296. a $gentest_py --coin=ltc --type=segwit 1 $rounds10x
  297. a $gentest_py --coin=ltc --type=bech32 1 $rounds10x
  298. - # wallet dumps:
  299. - $gentest_py --type=compressed 1 $REFDIR/btcwallet.dump
  300. - $gentest_py --type=segwit 1 $REFDIR/btcwallet-segwit.dump
  301. - $gentest_py --type=bech32 1 $REFDIR/btcwallet-bech32.dump
  302. - $gentest_py --type=compressed --testnet=1 1 $REFDIR/btcwallet-testnet.dump
  303. a $gentest_py --coin=ltc --type=compressed 1 $REFDIR/litecoin/ltcwallet.dump
  304. a $gentest_py --coin=ltc --type=segwit 1 $REFDIR/litecoin/ltcwallet-segwit.dump
  305. a $gentest_py --coin=ltc --type=bech32 1 $REFDIR/litecoin/ltcwallet-bech32.dump
  306. a $gentest_py --coin=ltc --type=compressed --testnet=1 1 $REFDIR/litecoin/ltcwallet-testnet.dump
  307. - # libsecp256k1 vs python-ecdsa:
  308. - $gentest_py 1:2 $rounds100x
  309. - $gentest_py --type=segwit 1:2 $rounds100x
  310. - $gentest_py --type=bech32 1:2 $rounds100x
  311. - $gentest_py --testnet=1 1:2 $rounds100x
  312. - $gentest_py --testnet=1 --type=segwit 1:2 $rounds100x
  313. a $gentest_py --coin=ltc 1:2 $rounds100x
  314. a $gentest_py --coin=ltc --type=segwit 1:2 $rounds100x
  315. a $gentest_py --coin=ltc --testnet=1 1:2 $rounds100x
  316. a $gentest_py --coin=ltc --testnet=1 --type=segwit 1:2 $rounds100x
  317. - # all backends vs pycoin:
  318. - $gentest_py all:pycoin $rounds100x
  319. "
  320. [ "$SKIP_ALT_DEP" ] && t_gen_skip='a'
  321. f_gen='gentest tests completed'
  322. }