cfg.sh 9.8 KB

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