cfg.sh 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. #!/bin/bash
  2. #
  3. # mmgen = Multi-Mode GENerator, a command-line cryptocurrency wallet
  4. # Copyright (C)2013-2024 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-wallet
  9. # https://gitlab.com/mmgen/mmgen-wallet
  10. all_tests="dep dev lint obj color unit hash ref altref altgen xmr eth autosign btc btc_tn btc_rt bch bch_tn bch_rt ltc ltc_tn ltc_rt tool tool2 gen alt"
  11. groups_desc="
  12. default - All tests minus the extra tests
  13. extra - All tests minus the default tests
  14. noalt - BTC-only tests
  15. quick - Default tests minus btc_tn, bch, bch_rt, ltc and ltc_rt
  16. qskip - The tests skipped in the 'quick' test group
  17. "
  18. init_groups() {
  19. dfl_tests='dep alt obj color unit hash ref tool tool2 gen autosign btc btc_tn btc_rt altref altgen bch bch_rt ltc ltc_rt eth etc xmr'
  20. extra_tests='dep dev lint autosign_btc autosign_live ltc_tn bch_tn'
  21. noalt_tests='dep alt obj color unit hash ref tool tool2 gen autosign_btc btc btc_tn btc_rt'
  22. quick_tests='dep alt obj color unit hash ref tool tool2 gen autosign btc btc_rt altref altgen eth etc xmr'
  23. qskip_tests='lint btc_tn bch bch_rt ltc ltc_rt'
  24. [ "$MSYS2" ] && SKIP_LIST='autosign autosign_btc autosign_live'
  25. [ "$ARM32" -o "$ARM64" ] && SKIP_LIST+=' etc'
  26. true
  27. }
  28. init_tests() {
  29. REFDIR='test/ref'
  30. d_alt="altcoin module"
  31. t_alt="
  32. - python3 -m test.altcointest $altcoin_mod_opts
  33. "
  34. d_obj="data objects"
  35. t_obj="
  36. - $objtest_py --coin=btc
  37. - $objtest_py --getobj --coin=btc
  38. - $objtest_py --coin=btc --testnet=1
  39. a $objtest_py --coin=ltc
  40. a $objtest_py --coin=ltc --testnet=1
  41. a $objtest_py --coin=eth
  42. - $objattrtest_py
  43. "
  44. [ "$SKIP_ALT_DEP" ] && t_obj_skip='a'
  45. [ "$PYTHONOPTIMIZE" ] && {
  46. echo -e "${YELLOW}PYTHONOPTIMIZE set, skipping object tests$RESET"
  47. t_obj_skip='-'
  48. }
  49. d_color="color handling"
  50. t_color='- test/colortest.py'
  51. d_dep="system and testing dependencies"
  52. t_dep="- $unit_tests_py testdep dep daemon.exec"
  53. d_dev="developer scripts ${YELLOW}(additional dependencies required)$RESET"
  54. t_dev="
  55. - $cmdtest_py dev
  56. "
  57. d_lint="code errors with static code analyzer"
  58. t_lint="
  59. - $pylint --errors-only mmgen
  60. - $pylint --errors-only test
  61. - $pylint --errors-only examples
  62. - $pylint --errors-only --disable=relative-beyond-top-level test/cmdtest_py_d
  63. "
  64. d_unit="low-level subsystems"
  65. t_unit="- $unit_tests_py --exclude testdep,dep,daemon"
  66. d_hash="internal hash function implementations"
  67. t_hash="
  68. 256 $python test/hashfunc.py sha256 $rounds5x
  69. 512 $python test/hashfunc.py sha512 $rounds5x # native SHA512 - not used by the MMGen wallet
  70. keccak $python test/hashfunc.py keccak $rounds5x
  71. ripemd160 $python mmgen/contrib/ripemd160.py $VERBOSE $fast_opt
  72. "
  73. [ "$ARM32" ] && t_hash_skip='512' # gmpy produces invalid init constants
  74. [ "$MSYS2" ] && t_hash_skip='512' # 2:py_long_long issues
  75. [ "$SKIP_ALT_DEP" ] && t_hash_skip+=' keccak'
  76. d_ref="generated values against reference data"
  77. t_ref="
  78. - $scrambletest_py
  79. "
  80. d_altref="altcoin reference file checks"
  81. t_altref="
  82. - $cmdtest_py ref_altcoin # generated addrfiles verified against checksums
  83. "
  84. d_altgen="altcoin address generation"
  85. t_altgen="
  86. - # speed tests, no verification:
  87. - $gentest_py --coin=etc 1 $rounds10x
  88. - $gentest_py --coin=etc --use-internal-keccak-module 1 $rounds10x
  89. - $gentest_py --coin=eth 1 $rounds10x
  90. - $gentest_py --coin=eth --use-internal-keccak-module 1 $rounds10x
  91. - $gentest_py --coin=xmr 1 $rounds10x
  92. - $gentest_py --coin=xmr --use-internal-keccak-module 1 $rounds10x
  93. - $gentest_py --coin=zec 1 $rounds10x
  94. - $gentest_py --coin=zec --type=zcash_z 1 $rounds10x
  95. - # verification against external libraries and tools:
  96. - # pycoin
  97. - $gentest_py --all-coins --type=legacy 1:pycoin $rounds
  98. - $gentest_py --all-coins --type=compressed 1:pycoin $rounds
  99. - $gentest_py --all-coins --type=segwit 1:pycoin $rounds
  100. - $gentest_py --all-coins --type=bech32 1:pycoin $rounds
  101. - $gentest_py --all-coins --type=legacy --testnet=1 1:pycoin $rounds
  102. - $gentest_py --all-coins --type=compressed --testnet=1 1:pycoin $rounds
  103. - $gentest_py --all-coins --type=segwit --testnet=1 1:pycoin $rounds
  104. - $gentest_py --all-coins --type=bech32 --testnet=1 1:pycoin $rounds
  105. - # keyconv
  106. - $gentest_py --all-coins --type=legacy 1:keyconv $rounds_min
  107. - $gentest_py --all-coins --type=compressed 1:keyconv $rounds_min
  108. e # ethkey
  109. e $gentest_py --coin=eth 1:ethkey $rounds10x
  110. e $gentest_py --coin=eth --use-internal-keccak-module 2:ethkey $rounds5x
  111. m # monero-python
  112. m $gentest_py --coin=xmr 1:monero-python $rounds100x
  113. M $gentest_py --coin=xmr all:monero-python $rounds_min # very slow, please be patient!
  114. z # zcash-mini
  115. z $gentest_py --coin=zec --type=zcash_z all:zcash-mini $rounds50x
  116. "
  117. [ "$MSYS2" ] && t_altgen_skip='z' # no zcash-mini (golang)
  118. [ "$ARM32" ] && t_altgen_skip='z e'
  119. [ "$FAST" ] && t_altgen_skip+=' M'
  120. # ARM ethkey available only on Arch Linux:
  121. [ \( "$ARM32" -o "$ARM64" \) -a "$DISTRO" != 'archarm' ] && t_altgen_skip+=' e'
  122. d_xmr="Monero xmrwallet operations"
  123. t_xmr="
  124. - $cmdtest_py --coin=xmr
  125. "
  126. d_eth="operations for Ethereum using devnet"
  127. t_eth="geth $cmdtest_py --coin=eth ethdev"
  128. d_etc="operations for Ethereum Classic using devnet"
  129. t_etc="parity $cmdtest_py --coin=etc ethdev"
  130. d_autosign="transaction autosigning with automount"
  131. t_autosign="
  132. - $cmdtest_py autosign autosign_clean autosign_automount
  133. - $cmdtest_py --coin=bch autosign_automount
  134. s $cmdtest_py --coin=ltc autosign_automount
  135. - $cmdtest_py --coin=eth autosign_eth
  136. s $cmdtest_py --coin=etc autosign_eth
  137. "
  138. [ "$FAST" ] && t_autosign_skip='s'
  139. d_autosign_btc="transaction and message autosigning (Bitcoin only)"
  140. t_autosign_btc="- $cmdtest_py autosign_btc"
  141. d_autosign_btc="transaction and message autosigning (interactive)"
  142. t_autosign_live="- $cmdtest_py autosign_live"
  143. d_btc="overall operations with emulated RPC data (Bitcoin)"
  144. t_btc="
  145. - $cmdtest_py --exclude regtest,autosign,autosign_clean,autosign_automount,ref_altcoin
  146. - $cmdtest_py --segwit
  147. - $cmdtest_py --segwit-random
  148. - $cmdtest_py --bech32
  149. "
  150. d_btc_tn="overall operations with emulated RPC data (Bitcoin testnet)"
  151. t_btc_tn="
  152. - $cmdtest_py --testnet=1
  153. - $cmdtest_py --testnet=1 --segwit
  154. - $cmdtest_py --testnet=1 --segwit-random
  155. - $cmdtest_py --testnet=1 --bech32
  156. "
  157. d_btc_rt="overall operations using the regtest network (Bitcoin)"
  158. t_btc_rt="
  159. - $cmdtest_py regtest
  160. - $cmdtest_py regtest_legacy
  161. "
  162. d_bch="overall operations with emulated RPC data (Bitcoin Cash Node)"
  163. t_bch="- $cmdtest_py --coin=bch --exclude regtest"
  164. d_bch_tn="overall operations with emulated RPC data (Bitcoin Cash Node testnet)"
  165. t_bch_tn="- $cmdtest_py --coin=bch --testnet=1"
  166. d_bch_rt="overall operations using the regtest network (Bitcoin Cash Node)"
  167. t_bch_rt="- $cmdtest_py --coin=bch regtest"
  168. d_ltc="overall operations with emulated RPC data (Litecoin)"
  169. t_ltc="
  170. - $cmdtest_py --coin=ltc --exclude regtest
  171. - $cmdtest_py --coin=ltc --segwit
  172. - $cmdtest_py --coin=ltc --segwit-random
  173. - $cmdtest_py --coin=ltc --bech32
  174. "
  175. d_ltc_tn="overall operations with emulated RPC data (Litecoin testnet)"
  176. t_ltc_tn="
  177. - $cmdtest_py --coin=ltc --testnet=1
  178. - $cmdtest_py --coin=ltc --testnet=1 --segwit
  179. - $cmdtest_py --coin=ltc --testnet=1 --segwit-random
  180. - $cmdtest_py --coin=ltc --testnet=1 --bech32
  181. "
  182. d_ltc_rt="overall operations using the regtest network (Litecoin)"
  183. t_ltc_rt="- $cmdtest_py --coin=ltc regtest"
  184. d_tool2="'mmgen-tool' utility with data check"
  185. t_tool2="
  186. - $tooltest2_py --tool-api # test the tool_api subsystem
  187. - $tooltest2_py --tool-api --testnet=1
  188. e $tooltest2_py --tool-api --coin=eth
  189. a $tooltest2_py --tool-api --coin=xmr
  190. a $tooltest2_py --tool-api --coin=zec
  191. - $tooltest2_py
  192. - $tooltest2_py --testnet=1
  193. a $tooltest2_py --coin=ltc
  194. a $tooltest2_py --coin=ltc --testnet=1
  195. a $tooltest2_py --coin=bch
  196. a $tooltest2_py --coin=bch --testnet=1
  197. a $tooltest2_py --coin=zec
  198. a $tooltest2_py --coin=xmr
  199. a $tooltest2_py --coin=dash
  200. e $tooltest2_py --coin=eth
  201. e $tooltest2_py --coin=eth --testnet=1
  202. e $tooltest2_py --coin=eth --token=mm1
  203. e $tooltest2_py --coin=eth --token=mm1 --testnet=1
  204. e $tooltest2_py --coin=etc
  205. - $tooltest2_py --fork # run once with --fork so commands are actually executed
  206. "
  207. [ "$SKIP_ALT_DEP" ] && t_tool2_skip='a e' # skip ETH,ETC: txview requires py_ecc
  208. d_tool="'mmgen-tool' utility (all supported coins)"
  209. t_tool="
  210. - $tooltest_py --coin=btc cryptocoin
  211. - $tooltest_py --coin=btc mnemonic
  212. a $tooltest_py --coin=ltc cryptocoin
  213. a $tooltest_py --coin=eth cryptocoin
  214. a $tooltest_py --coin=etc cryptocoin
  215. a $tooltest_py --coin=dash cryptocoin
  216. a $tooltest_py --coin=doge cryptocoin
  217. a $tooltest_py --coin=emc cryptocoin
  218. a $tooltest_py --coin=xmr cryptocoin
  219. a $tooltest_py --coin=zec cryptocoin
  220. z $tooltest_py --coin=zec --type=zcash_z cryptocoin
  221. "
  222. [ "$MSYS2" -o "$ARM32" ] && t_tool_skip='z'
  223. [ "$SKIP_ALT_DEP" ] && t_tool_skip='a z'
  224. d_gen="Bitcoin and Litecoin address generation"
  225. t_gen="
  226. - # speed tests, no verification:
  227. - $gentest_py --coin=btc 1 $rounds10x
  228. - $gentest_py --coin=btc --type=compressed 1 $rounds10x
  229. - $gentest_py --coin=btc --type=segwit 1 $rounds10x
  230. - $gentest_py --coin=btc --type=bech32 1 $rounds10x
  231. a $gentest_py --coin=ltc 1 $rounds10x
  232. a $gentest_py --coin=ltc --type=compressed 1 $rounds10x
  233. a $gentest_py --coin=ltc --type=segwit 1 $rounds10x
  234. a $gentest_py --coin=ltc --type=bech32 1 $rounds10x
  235. - # wallet dumps:
  236. - $gentest_py --type=compressed 1 $REFDIR/btcwallet.dump
  237. - $gentest_py --type=segwit 1 $REFDIR/btcwallet-segwit.dump
  238. - $gentest_py --type=bech32 1 $REFDIR/btcwallet-bech32.dump
  239. - $gentest_py --type=compressed --testnet=1 1 $REFDIR/btcwallet-testnet.dump
  240. a $gentest_py --coin=ltc --type=compressed 1 $REFDIR/litecoin/ltcwallet.dump
  241. a $gentest_py --coin=ltc --type=segwit 1 $REFDIR/litecoin/ltcwallet-segwit.dump
  242. a $gentest_py --coin=ltc --type=bech32 1 $REFDIR/litecoin/ltcwallet-bech32.dump
  243. a $gentest_py --coin=ltc --type=compressed --testnet=1 1 $REFDIR/litecoin/ltcwallet-testnet.dump
  244. - # libsecp256k1 vs python-ecdsa:
  245. - $gentest_py --type=legacy 1:2 $rounds100x
  246. - $gentest_py --type=compressed 1:2 $rounds100x
  247. - $gentest_py --type=segwit 1:2 $rounds100x
  248. - $gentest_py --type=bech32 1:2 $rounds100x
  249. - $gentest_py --testnet=1 1:2 $rounds100x
  250. - $gentest_py --testnet=1 --type=segwit 1:2 $rounds100x
  251. a $gentest_py --coin=ltc 1:2 $rounds100x
  252. a $gentest_py --coin=ltc --type=segwit 1:2 $rounds100x
  253. a $gentest_py --coin=ltc --testnet=1 1:2 $rounds100x
  254. a $gentest_py --coin=ltc --testnet=1 --type=segwit 1:2 $rounds100x
  255. - # all backends vs pycoin:
  256. - $gentest_py all:pycoin $rounds100x
  257. "
  258. [ "$SKIP_ALT_DEP" ] && t_gen_skip='a'
  259. true
  260. }