cfg.sh 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. #!/usr/bin/env bash
  2. #
  3. # MMGen Wallet, a terminal-based cryptocurrency wallet
  4. # Copyright (C)2013-2025 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 daemon mod hash ref altref altgen xmr geth reth autosign btc btc_tn btc_rt bch bch_tn bch_rt ltc ltc_tn ltc_rt tool tool2 gen alt help"
  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 daemon alt obj color mod hash ref tool tool2 gen help autosign btc btc_tn btc_rt altref altgen bch bch_rt ltc ltc_rt geth reth etc rune xmr'
  20. extra_tests='dep dev lint pylint autosign_live ltc_tn bch_tn'
  21. noalt_tests='dep daemon alt obj color mod hash ref tool tool2 gen help autosign btc btc_tn btc_rt'
  22. quick_tests='dep daemon alt obj color mod hash ref tool tool2 gen help autosign btc btc_rt altref altgen geth etc rune xmr'
  23. qskip_tests='lint btc_tn bch bch_rt ltc ltc_rt'
  24. noalt_ok_tests='lint'
  25. [ "$MSYS2" ] && SKIP_LIST='autosign autosign_live'
  26. [ "$SKIP_PARITY" ] && SKIP_LIST+=' etc'
  27. true
  28. }
  29. init_tests() {
  30. REFDIR='test/ref'
  31. d_alt="altcoin module"
  32. t_alt="
  33. - python3 -m test.altcointest $altcoin_mod_opts
  34. "
  35. d_obj="data objects"
  36. t_obj="
  37. x $objtest_py --coin=btc
  38. x $objtest_py --getobj --coin=btc
  39. x $objtest_py --coin=btc --testnet=1
  40. a $objtest_py --coin=ltc
  41. a $objtest_py --coin=ltc --testnet=1
  42. a $objtest_py --coin=eth
  43. x $objattrtest_py
  44. "
  45. [ "$SKIP_ALT_DEP" ] && t_obj_skip='a'
  46. [ "$PYTHONOPTIMIZE" ] && {
  47. echo -e "${YELLOW}PYTHONOPTIMIZE set, skipping object tests$RESET"
  48. t_obj_skip='x a'
  49. }
  50. d_color="color handling"
  51. t_color='- test/colortest.py'
  52. d_dep="system and testing dependencies"
  53. t_dep="
  54. - $modtest_py testdep dep
  55. - $daemontest_py exec
  56. "
  57. d_dev="developer scripts ${YELLOW}(additional dependencies required)$RESET"
  58. t_dev="
  59. - $cmdtest_py dev
  60. "
  61. [ "$VERBOSE" ] || STDOUT_DEVNULL='> /dev/null'
  62. d_lint="code errors with Ruff static code analyzer"
  63. e_lint="Error checking failed!"
  64. t_lint="
  65. b ruff check setup.py $STDOUT_DEVNULL
  66. b ruff check mmgen $STDOUT_DEVNULL
  67. b ruff check test $STDOUT_DEVNULL
  68. b ruff check examples $STDOUT_DEVNULL
  69. "
  70. PYLINT_OPTS='--errors-only --jobs=0'
  71. d_pylint="code errors with Pylint static code analyzer"
  72. e_pylint="Error checking failed!"
  73. # use pylint==3.1.1
  74. t_pylint="
  75. b $pylint $PYLINT_OPTS mmgen
  76. b $pylint $PYLINT_OPTS test
  77. b $pylint $PYLINT_OPTS --disable=relative-beyond-top-level test/cmdtest_d
  78. a $pylint $PYLINT_OPTS --ignore-paths '.*/eth/.*' mmgen
  79. a $pylint $PYLINT_OPTS --ignore-paths '.*/dep.py,.*/testdep.py' test
  80. a $pylint $PYLINT_OPTS --ignore-paths '.*/ethdev.py' --disable=relative-beyond-top-level test/cmdtest_d
  81. - $pylint $PYLINT_OPTS examples
  82. "
  83. if [ "$SKIP_ALT_DEP" ]; then t_pylint_skip='b'; else t_pylint_skip='a'; fi
  84. d_daemon="low-level subsystems involving coin daemons"
  85. t_daemon="- $daemontest_py --exclude exec"
  86. d_mod="low-level subsystems"
  87. t_mod="- $modtest_py --exclude testdep,dep"
  88. d_hash="internal hash function implementations"
  89. t_hash="
  90. 256 $python test/hashfunc.py sha256 $rounds5x
  91. 512 $python test/hashfunc.py sha512 $rounds5x # native SHA512 - not used by the MMGen wallet
  92. keccak $python test/hashfunc.py keccak $rounds5x
  93. ripemd160 $python mmgen/contrib/ripemd160.py $VERBOSE $fast_opt
  94. "
  95. [ "$ARM32" ] && t_hash_skip='512' # gmpy produces invalid init constants
  96. [ "$MSYS2" ] && t_hash_skip='512' # 2:py_long_long issues
  97. [ "$SKIP_ALT_DEP" ] && t_hash_skip+=' keccak'
  98. d_ref="generated values against reference data"
  99. t_ref="
  100. - $scrambletest_py
  101. "
  102. d_altref="altcoin reference file checks"
  103. t_altref="
  104. - $cmdtest_py ref_altcoin # generated addrfiles verified against checksums
  105. "
  106. d_altgen="altcoin address generation"
  107. t_altgen="
  108. - # speed tests, no verification:
  109. - $gentest_py --coin=etc 1 $rounds10x
  110. - $gentest_py --coin=etc --use-internal-keccak-module 1 $rounds10x
  111. - $gentest_py --coin=eth 1 $rounds10x
  112. - $gentest_py --coin=eth --use-internal-keccak-module 1 $rounds10x
  113. - $gentest_py --coin=xmr 1 $rounds10x
  114. - $gentest_py --coin=xmr --use-internal-keccak-module 1 $rounds10x
  115. - $gentest_py --coin=zec 1 $rounds10x
  116. - $gentest_py --coin=zec --type=zcash_z 1 $rounds10x
  117. - # verification against external libraries and tools:
  118. - # pycoin
  119. - $gentest_py --all-coins --type=legacy 1:pycoin $rounds
  120. - $gentest_py --all-coins --type=compressed 1:pycoin $rounds
  121. - $gentest_py --all-coins --type=segwit 1:pycoin $rounds
  122. - $gentest_py --all-coins --type=bech32 1:pycoin $rounds
  123. - $gentest_py --all-coins --type=legacy --testnet=1 1:pycoin $rounds
  124. - $gentest_py --all-coins --type=compressed --testnet=1 1:pycoin $rounds
  125. - $gentest_py --all-coins --type=segwit --testnet=1 1:pycoin $rounds
  126. - $gentest_py --all-coins --type=bech32 --testnet=1 1:pycoin $rounds
  127. - # keyconv
  128. - $gentest_py --all-coins --type=legacy 1:keyconv $rounds_min
  129. - $gentest_py --all-coins --type=compressed 1:keyconv $rounds_min
  130. e # eth-keys
  131. e $gentest_py --coin=eth 1:eth-keys $rounds10x
  132. e $gentest_py --coin=eth --use-internal-keccak-module 2:eth-keys $rounds5x
  133. m # monero-python
  134. m $gentest_py --coin=xmr 1:monero-python $rounds100x
  135. M $gentest_py --coin=xmr all:monero-python $rounds_min # very slow, please be patient!
  136. z # zcash-mini
  137. z $gentest_py --coin=zec --type=zcash_z all:zcash-mini $rounds50x
  138. "
  139. [ "$MSYS2" ] && t_altgen_skip='z' # no zcash-mini (golang)
  140. [ "$ARM32" ] && t_altgen_skip='z e'
  141. [ "$FAST" ] && t_altgen_skip+=' M'
  142. d_help="helpscreens for selected coins"
  143. t_help="
  144. - $cmdtest_py --coin=btc help
  145. a $cmdtest_py --coin=bch help
  146. a $cmdtest_py --coin=eth help
  147. a $cmdtest_py --coin=xmr help
  148. a $cmdtest_py --coin=rune help
  149. a $cmdtest_py --coin=doge help:helpscreens help:longhelpscreens
  150. "
  151. [ "$SKIP_ALT_DEP" ] && t_help_skip='a'
  152. d_autosign="transaction autosigning with automount"
  153. t_autosign="
  154. alt $cmdtest_py autosign_clean autosign_automount autosign
  155. btc $cmdtest_py autosign_clean autosign_automount autosign_btc
  156. ltc $cmdtest_py --coin=ltc autosign_automount
  157. bch $cmdtest_py --coin=bch autosign_automount
  158. "
  159. if [ "$SKIP_ALT_DEP" ]; then t_autosign_skip='ltc bch alt'; else t_autosign_skip='btc'; fi
  160. [ "$FAST" ] && t_autosign_skip+=' ltc'
  161. d_autosign_live="transaction and message autosigning (interactive)"
  162. t_autosign_live="- $cmdtest_py autosign_live"
  163. d_btc="overall operations with emulated RPC data (Bitcoin)"
  164. t_btc="
  165. - $cmdtest_py misc
  166. - $cmdtest_py opts
  167. - $cmdtest_py cfgfile
  168. - $cmdtest_py main
  169. - $cmdtest_py conv
  170. - $cmdtest_py ref
  171. - $cmdtest_py ref3
  172. - $cmdtest_py ref3_addr
  173. - $cmdtest_py ref3_pw
  174. - $cmdtest_py ref_altcoin
  175. - $cmdtest_py seedsplit
  176. - $cmdtest_py tool
  177. - $cmdtest_py input
  178. - $cmdtest_py output
  179. - $cmdtest_py --segwit
  180. - $cmdtest_py --segwit-random
  181. - $cmdtest_py --bech32
  182. "
  183. d_btc_tn="overall operations with emulated RPC data (Bitcoin testnet)"
  184. t_btc_tn="
  185. - $cmdtest_py --testnet=1
  186. - $cmdtest_py --testnet=1 --segwit
  187. - $cmdtest_py --testnet=1 --segwit-random
  188. - $cmdtest_py --testnet=1 --bech32
  189. "
  190. d_btc_rt="overall operations using the regtest network (Bitcoin, multicoin)"
  191. t_btc_rt="
  192. - $cmdtest_py regtest
  193. x $cmdtest_py regtest_legacy
  194. a $cmdtest_py swap
  195. "
  196. [ "$FAST" ] && t_btc_rt_skip='x'
  197. [ "$SKIP_ALT_DEP" ] && t_btc_rt_skip+=' a'
  198. d_bch="overall operations with emulated RPC data (Bitcoin Cash Node)"
  199. t_bch="
  200. - $cmdtest_py --coin=bch --exclude regtest,autosign_automount,help
  201. - $cmdtest_py --coin=bch --cashaddr=0 ref3_addr
  202. "
  203. d_bch_tn="overall operations with emulated RPC data (Bitcoin Cash Node testnet)"
  204. t_bch_tn="
  205. - $cmdtest_py --coin=bch --testnet=1
  206. - $cmdtest_py --coin=bch --testnet=1 --cashaddr=0 ref3_addr
  207. "
  208. d_bch_rt="overall operations using the regtest network (Bitcoin Cash Node)"
  209. t_bch_rt="- $cmdtest_py --coin=bch regtest"
  210. d_ltc="overall operations with emulated RPC data (Litecoin)"
  211. t_ltc="
  212. - $cmdtest_py --coin=ltc --exclude regtest,autosign_automount,help
  213. - $cmdtest_py --coin=ltc --segwit
  214. - $cmdtest_py --coin=ltc --segwit-random
  215. - $cmdtest_py --coin=ltc --bech32
  216. "
  217. d_ltc_tn="overall operations with emulated RPC data (Litecoin testnet)"
  218. t_ltc_tn="
  219. - $cmdtest_py --coin=ltc --testnet=1
  220. - $cmdtest_py --coin=ltc --testnet=1 --segwit
  221. - $cmdtest_py --coin=ltc --testnet=1 --segwit-random
  222. - $cmdtest_py --coin=ltc --testnet=1 --bech32
  223. "
  224. d_ltc_rt="overall operations using the regtest network (Litecoin)"
  225. t_ltc_rt="- $cmdtest_py --coin=ltc regtest"
  226. [ "$SOC" -o "$MSYS2" ] && {
  227. eth_env="MMGEN_TEST_SUITE_DEVNET_BLOCK_PERIOD=${MMGEN_TEST_SUITE_DEVNET_BLOCK_PERIOD:-22} "
  228. }
  229. d_geth="operations for Ethereum using devnet (Go-Ethereum daemon)"
  230. t_geth="
  231. - $cmdtest_py --coin=btc --eth-daemon-id=geth ethswap
  232. - $eth_env$cmdtest_py --coin=eth --eth-daemon-id=geth autosign_eth ethbump ethdev
  233. "
  234. d_reth="operations for Ethereum using devnet (Rust Ethereum daemon)"
  235. t_reth="
  236. r $cmdtest_py --coin=btc --eth-daemon-id=reth ethswap
  237. r $eth_env$cmdtest_py --coin=eth --eth-daemon-id=reth autosign_eth ethbump ethdev
  238. "
  239. [ "$FAST" ] && t_reth_skip='r'
  240. d_etc="operations for Ethereum Classic using devnet"
  241. t_etc="
  242. parity $cmdtest_py --coin=etc autosign_eth
  243. parity $cmdtest_py --coin=etc ethdev
  244. "
  245. [ "$SKIP_PARITY" ] && t_etc_skip='parity'
  246. d_rune="operations for THORChain RUNE using testnet"
  247. t_rune="
  248. - $cmdtest_py --coin=rune rune
  249. - $cmdtest_py runeswap
  250. "
  251. [ "$SOC" ] && {
  252. xmr_env1="MMGEN_TEST_SUITE_PEXPECT_TIMEOUT=${MMGEN_TEST_SUITE_PEXPECT_TIMEOUT:-300} "
  253. xmr_env2="MMGEN_HTTP_TIMEOUT=${MMGEN_HTTP_TIMEOUT:-300} "
  254. xmr_env3="MMGEN_DAEMON_STATE_TIMEOUT=${MMGEN_DAEMON_STATE_TIMEOUT:-180} "
  255. }
  256. d_xmr="Monero xmrwallet operations"
  257. t_xmr="
  258. - $xmr_env1$xmr_env2$xmr_env3$cmdtest_py --coin=xmr --exclude help
  259. "
  260. d_tool2="'mmgen-tool' utility with data check"
  261. t_tool2="
  262. - $tooltest2_py --tool-api # test the tool_api subsystem
  263. - $tooltest2_py --tool-api --testnet=1
  264. e $tooltest2_py --tool-api --coin=eth
  265. a $tooltest2_py --tool-api --coin=xmr
  266. a $tooltest2_py --tool-api --coin=zec
  267. - $tooltest2_py
  268. - $tooltest2_py --testnet=1
  269. a $tooltest2_py --coin=ltc
  270. a $tooltest2_py --coin=ltc --testnet=1
  271. a $tooltest2_py --coin=bch
  272. a $tooltest2_py --coin=bch --testnet=1
  273. a $tooltest2_py --coin=zec
  274. a $tooltest2_py --coin=xmr
  275. a $tooltest2_py --coin=dash
  276. e $tooltest2_py --coin=eth
  277. e $tooltest2_py --coin=eth --testnet=1
  278. e $tooltest2_py --coin=eth --token=mm1
  279. e $tooltest2_py --coin=eth --token=mm1 --testnet=1
  280. e $tooltest2_py --coin=etc
  281. t $tooltest2_py --coin=rune
  282. - $tooltest2_py --fork # run once with --fork so commands are actually executed
  283. "
  284. [ "$SKIP_ALT_DEP" ] && t_tool2_skip='a e t'
  285. d_tool="'mmgen-tool' utility (all supported coins)"
  286. t_tool="
  287. - $tooltest_py --coin=btc cryptocoin
  288. - $tooltest_py --coin=btc mnemonic
  289. a $tooltest_py --coin=ltc cryptocoin
  290. a $tooltest_py --coin=eth cryptocoin
  291. a $tooltest_py --coin=etc cryptocoin
  292. a $tooltest_py --coin=dash cryptocoin
  293. a $tooltest_py --coin=doge cryptocoin
  294. a $tooltest_py --coin=emc cryptocoin
  295. a $tooltest_py --coin=xmr cryptocoin
  296. a $tooltest_py --coin=zec cryptocoin
  297. z $tooltest_py --coin=zec --type=zcash_z cryptocoin
  298. "
  299. [ "$MSYS2" -o "$ARM32" ] && t_tool_skip='z'
  300. [ "$SKIP_ALT_DEP" ] && t_tool_skip='a z'
  301. d_gen="Bitcoin and Litecoin address generation"
  302. t_gen="
  303. - # speed tests, no verification:
  304. - $gentest_py --coin=btc 1 $rounds10x
  305. - $gentest_py --coin=btc --type=compressed 1 $rounds10x
  306. - $gentest_py --coin=btc --type=segwit 1 $rounds10x
  307. - $gentest_py --coin=btc --type=bech32 1 $rounds10x
  308. a $gentest_py --coin=ltc 1 $rounds10x
  309. a $gentest_py --coin=ltc --type=compressed 1 $rounds10x
  310. a $gentest_py --coin=ltc --type=segwit 1 $rounds10x
  311. a $gentest_py --coin=ltc --type=bech32 1 $rounds10x
  312. - # wallet dumps:
  313. - $gentest_py --type=compressed 1 $REFDIR/btcwallet.dump
  314. - $gentest_py --type=segwit 1 $REFDIR/btcwallet-segwit.dump
  315. - $gentest_py --type=bech32 1 $REFDIR/btcwallet-bech32.dump
  316. - $gentest_py --type=compressed --testnet=1 1 $REFDIR/btcwallet-testnet.dump
  317. a $gentest_py --coin=ltc --type=compressed 1 $REFDIR/litecoin/ltcwallet.dump
  318. a $gentest_py --coin=ltc --type=segwit 1 $REFDIR/litecoin/ltcwallet-segwit.dump
  319. a $gentest_py --coin=ltc --type=bech32 1 $REFDIR/litecoin/ltcwallet-bech32.dump
  320. a $gentest_py --coin=ltc --type=compressed --testnet=1 1 $REFDIR/litecoin/ltcwallet-testnet.dump
  321. a $gentest_py --coin=bch --type=compressed --cashaddr=0 1 $REFDIR/bitcoin_cash/bchwallet.dump
  322. a $gentest_py --coin=bch --type=compressed --cashaddr=1 1 $REFDIR/bitcoin_cash/bchwallet.dump
  323. a $gentest_py --coin=bch --type=compressed --testnet=1 1 $REFDIR/bitcoin_cash/bchwallet-testnet.dump
  324. - # libsecp256k1 vs python-ecdsa:
  325. - $gentest_py --type=legacy 1:2 $rounds100x
  326. - $gentest_py --type=compressed 1:2 $rounds100x
  327. - $gentest_py --type=segwit 1:2 $rounds100x
  328. - $gentest_py --type=bech32 1:2 $rounds100x
  329. - $gentest_py --testnet=1 1:2 $rounds100x
  330. - $gentest_py --testnet=1 --type=segwit 1:2 $rounds100x
  331. a $gentest_py --coin=ltc 1:2 $rounds100x
  332. a $gentest_py --coin=ltc --type=segwit 1:2 $rounds100x
  333. a $gentest_py --coin=ltc --testnet=1 1:2 $rounds100x
  334. a $gentest_py --coin=ltc --testnet=1 --type=segwit 1:2 $rounds100x
  335. - # all backends vs pycoin:
  336. - $gentest_py all:pycoin $rounds100x
  337. "
  338. [ "$SKIP_ALT_DEP" ] && t_gen_skip='a'
  339. true
  340. }