cfg.sh 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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 $rounds_max
  93. 512 $python test/hashfunc.py sha512 $rounds_max # native SHA512 - not used by the MMGen wallet
  94. keccak $python test/hashfunc.py keccak $rounds_max
  95. ripemd160 $python mmgen/contrib/ripemd160.py $VERBOSE
  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 $rounds
  118. - $gentest_py --coin=etc --use-internal-keccak-module 1 $rounds_min
  119. - $gentest_py --coin=eth 1 $rounds
  120. - $gentest_py --coin=eth --use-internal-keccak-module 1 $rounds_min
  121. - $gentest_py --coin=xmr 1 $rounds
  122. - $gentest_py --coin=xmr --use-internal-keccak-module 1 $rounds_min
  123. - $gentest_py --coin=zec 1 $rounds
  124. - $gentest_py --coin=zec --type=zcash_z 1 $rounds_mid
  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
  137. - $gentest_py --all-coins --type=compressed 1:keyconv $rounds
  138. e # ethkey
  139. e $gentest_py --coin=eth 1:ethkey $rounds
  140. e $gentest_py --coin=eth --use-internal-keccak-module 2:ethkey $rounds_mid
  141. m # moneropy
  142. m $gentest_py --coin=xmr all:moneropy $rounds_mid # very slow, please be patient!
  143. z # zcash-mini
  144. z $gentest_py --coin=zec --type=zcash_z all:zcash-mini $rounds_mid
  145. "
  146. [ "$MSYS2" ] && t_alts_skip='m z' # no moneropy (pysha3), zcash-mini (golang)
  147. [ "$ARM32" ] && t_alts_skip='z e'
  148. [ "$DISTRO" == 'arch' -o "$DISTRO" == 'archarm' ] || t_alts_skip+=' e' # ethkey available only on Arch Linux
  149. f_alts='Gen-only altcoin tests completed'
  150. i_xmr='Monero'
  151. s_xmr='Testing Monero operations'
  152. t_xmr="
  153. - $test_py --coin=xmr
  154. "
  155. f_xmr='Monero tests completed'
  156. i_eth='Ethereum'
  157. s_eth='Testing transaction and tracking wallet operations for Ethereum'
  158. t_eth="
  159. oe $test_py --coin=eth --daemon-id=openethereum ethdev
  160. geth $test_py --coin=eth --daemon-id=geth ethdev
  161. parity $test_py --coin=etc ethdev
  162. "
  163. f_eth='Ethereum tests completed'
  164. [ "$FAST" ] && t_eth_skip='oe'
  165. [ "$ARM32" -o "$ARM64" ] && t_eth_skip+=' parity'
  166. [ \( "$ARM32" -o "$ARM64" \) -a "$DISTRO" != 'archarm' ] && t_eth_skip+=' oe' # ARM oe available only on ArchLinuxArm
  167. i_autosign='Autosign'
  168. s_autosign='The bitcoin, bitcoin-bchn and litecoin mainnet and testnet daemons must be running for the following test'
  169. t_autosign="- $test_py autosign"
  170. f_autosign='Autosign test completed'
  171. i_autosign_btc='Autosign BTC'
  172. s_autosign_btc='The bitcoin mainnet and testnet daemons must be running for the following test'
  173. t_autosign_btc="- $test_py autosign_btc"
  174. f_autosign_btc='Autosign BTC test completed'
  175. i_autosign_live='Autosign Live'
  176. s_autosign_live="The bitcoin mainnet and testnet daemons must be running for the following test\n"
  177. s_autosign_live+="${YELLOW}Mountpoint, '/etc/fstab' and removable device must be configured "
  178. s_autosign_live+="as described in 'mmgen-autosign --help'${RESET}"
  179. t_autosign_live="- $test_py autosign_live"
  180. f_autosign_live='Autosign Live test completed'
  181. i_btc='Bitcoin mainnet'
  182. s_btc='The bitcoin (mainnet) daemon must both be running for the following tests'
  183. t_btc="
  184. - $test_py --exclude regtest,autosign,ref_altcoin
  185. - $test_py --segwit
  186. - $test_py --segwit-random
  187. - $test_py --bech32
  188. - $python scripts/compute-file-chksum.py $REFDIR/*testnet.rawtx >/dev/null 2>&1
  189. "
  190. f_btc='Bitcoin mainnet tests completed'
  191. i_btc_tn='Bitcoin testnet'
  192. s_btc_tn='The bitcoin testnet daemon must both be running for the following tests'
  193. t_btc_tn="
  194. - $test_py --testnet=1
  195. - $test_py --testnet=1 --segwit
  196. - $test_py --testnet=1 --segwit-random
  197. - $test_py --testnet=1 --bech32
  198. "
  199. f_btc_tn='Bitcoin testnet tests completed'
  200. i_btc_rt='Bitcoin regtest'
  201. s_btc_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  202. t_btc_rt="- $test_py regtest"
  203. f_btc_rt='Regtest (Bob and Alice) mode tests for BTC completed'
  204. i_bch='BitcoinCashNode (BCH) mainnet'
  205. s_bch='The bitcoin-bchn mainnet daemon must both be running for the following tests'
  206. t_bch="- $test_py --coin=bch --exclude regtest"
  207. f_bch='BitcoinCashNode (BCH) mainnet tests completed'
  208. i_bch_tn='BitcoinCashNode (BCH) testnet'
  209. s_bch_tn='The bitcoin-bchn testnet daemon must both be running for the following tests'
  210. t_bch_tn="- $test_py --coin=bch --testnet=1 --exclude regtest"
  211. f_bch_tn='BitcoinCashNode (BCH) testnet tests completed'
  212. i_bch_rt='BitcoinCashNode (BCH) regtest'
  213. s_bch_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  214. t_bch_rt="- $test_py --coin=bch regtest"
  215. f_bch_rt='Regtest (Bob and Alice) mode tests for BCH completed'
  216. i_ltc='Litecoin'
  217. s_ltc='The litecoin mainnet daemon must both be running for the following tests'
  218. t_ltc="
  219. - $test_py --coin=ltc --exclude regtest
  220. - $test_py --coin=ltc --segwit
  221. - $test_py --coin=ltc --segwit-random
  222. - $test_py --coin=ltc --bech32
  223. "
  224. f_ltc='Litecoin mainnet tests completed'
  225. i_ltc_tn='Litecoin testnet'
  226. s_ltc_tn='The litecoin testnet daemon must both be running for the following tests'
  227. t_ltc_tn="
  228. - $test_py --coin=ltc --testnet=1 --exclude regtest
  229. - $test_py --coin=ltc --testnet=1 --segwit
  230. - $test_py --coin=ltc --testnet=1 --segwit-random
  231. - $test_py --coin=ltc --testnet=1 --bech32
  232. "
  233. f_ltc_tn='Litecoin testnet tests completed'
  234. i_ltc_rt='Litecoin regtest'
  235. s_ltc_rt="The following tests will test MMGen's regtest (Bob and Alice) mode"
  236. t_ltc_rt="- $test_py --coin=ltc regtest"
  237. f_ltc_rt='Regtest (Bob and Alice) mode tests for LTC completed'
  238. i_tool2='Tooltest2'
  239. s_tool2="The following tests will run '$tooltest2_py' for all supported coins"
  240. t_tool2="
  241. - $tooltest2_py --tool-api # test the tool_api subsystem
  242. - $tooltest2_py --tool-api --testnet=1
  243. e $tooltest2_py --tool-api --coin=eth
  244. a $tooltest2_py --tool-api --coin=xmr
  245. a $tooltest2_py --tool-api --coin=zec
  246. - $tooltest2_py
  247. - $tooltest2_py --testnet=1
  248. a $tooltest2_py --coin=ltc
  249. a $tooltest2_py --coin=ltc --testnet=1
  250. a $tooltest2_py --coin=bch
  251. a $tooltest2_py --coin=bch --testnet=1
  252. a $tooltest2_py --coin=zec
  253. a $tooltest2_py --coin=xmr
  254. a $tooltest2_py --coin=dash
  255. e $tooltest2_py --coin=eth
  256. e $tooltest2_py --coin=eth --testnet=1
  257. e $tooltest2_py --coin=eth --token=mm1
  258. e $tooltest2_py --coin=eth --token=mm1 --testnet=1
  259. e $tooltest2_py --coin=etc
  260. - $tooltest2_py --fork # run once with --fork so commands are actually executed
  261. "
  262. f_tool2='tooltest2 tests completed'
  263. [ "$SKIP_ALT_DEP" ] && t_tool2_skip='a e' # skip ETH,ETC: txview requires py_ecc
  264. i_tool='Tooltest'
  265. s_tool="The following tests will run '$tooltest_py' for all supported coins"
  266. t_tool="
  267. - $tooltest_py --coin=btc cryptocoin
  268. - $tooltest_py --coin=btc mnemonic
  269. a $tooltest_py --coin=ltc cryptocoin
  270. a $tooltest_py --coin=eth cryptocoin
  271. a $tooltest_py --coin=etc cryptocoin
  272. a $tooltest_py --coin=dash cryptocoin
  273. a $tooltest_py --coin=doge cryptocoin
  274. a $tooltest_py --coin=emc cryptocoin
  275. a $tooltest_py --coin=xmr cryptocoin
  276. a $tooltest_py --coin=zec cryptocoin
  277. z $tooltest_py --coin=zec --type=zcash_z cryptocoin
  278. "
  279. [ "$MSYS2" -o "$ARM32" ] && t_tool_skip='z'
  280. [ "$SKIP_ALT_DEP" ] && t_tool_skip='a z'
  281. f_tool='tooltest tests completed'
  282. i_gen='Gentest'
  283. s_gen="The following tests will run '$gentest_py' for configured coins and address types"
  284. t_gen="
  285. - # speed tests, no verification:
  286. - $gentest_py --coin=btc 1 $rounds
  287. - $gentest_py --coin=btc --type=compressed 1 $rounds
  288. - $gentest_py --coin=btc --type=segwit 1 $rounds
  289. - $gentest_py --coin=btc --type=bech32 1 $rounds
  290. a $gentest_py --coin=ltc 1 $rounds
  291. a $gentest_py --coin=ltc --type=compressed 1 $rounds
  292. a $gentest_py --coin=ltc --type=segwit 1 $rounds
  293. a $gentest_py --coin=ltc --type=bech32 1 $rounds
  294. - # wallet dumps:
  295. - $gentest_py --type=compressed 1 $REFDIR/btcwallet.dump
  296. - $gentest_py --type=segwit 1 $REFDIR/btcwallet-segwit.dump
  297. - $gentest_py --type=bech32 1 $REFDIR/btcwallet-bech32.dump
  298. - $gentest_py --type=compressed --testnet=1 1 $REFDIR/btcwallet-testnet.dump
  299. a $gentest_py --coin=ltc --type=compressed 1 $REFDIR/litecoin/ltcwallet.dump
  300. a $gentest_py --coin=ltc --type=segwit 1 $REFDIR/litecoin/ltcwallet-segwit.dump
  301. a $gentest_py --coin=ltc --type=bech32 1 $REFDIR/litecoin/ltcwallet-bech32.dump
  302. a $gentest_py --coin=ltc --type=compressed --testnet=1 1 $REFDIR/litecoin/ltcwallet-testnet.dump
  303. - # libsecp256k1 vs python-ecdsa:
  304. - $gentest_py 1:2 $rounds
  305. - $gentest_py --type=segwit 1:2 $rounds
  306. - $gentest_py --type=bech32 1:2 $rounds
  307. - $gentest_py --testnet=1 1:2 $rounds
  308. - $gentest_py --testnet=1 --type=segwit 1:2 $rounds
  309. a $gentest_py --coin=ltc 1:2 $rounds
  310. a $gentest_py --coin=ltc --type=segwit 1:2 $rounds
  311. a $gentest_py --coin=ltc --testnet=1 1:2 $rounds
  312. a $gentest_py --coin=ltc --testnet=1 --type=segwit 1:2 $rounds
  313. - # all backends vs pycoin:
  314. - $gentest_py all:pycoin $rounds
  315. "
  316. [ "$SKIP_ALT_DEP" ] && t_gen_skip='a'
  317. f_gen='gentest tests completed'
  318. }