@btc-vision/bitcoin 6.4.9 → 6.4.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/.babelrc +4 -4
  2. package/.mocharc.json +13 -13
  3. package/.prettierrc.json +12 -12
  4. package/CHANGELOG.md +403 -403
  5. package/CONTRIBUTING.md +83 -83
  6. package/LICENSE +21 -21
  7. package/README.md +201 -201
  8. package/browser/index.d.ts +1 -1
  9. package/browser/index.js +1 -1
  10. package/browser/{ops.d.ts → opcodes.d.ts} +2 -3
  11. package/browser/script.d.ts +2 -2
  12. package/build/address.js +2 -1
  13. package/build/index.d.ts +1 -1
  14. package/build/index.js +1 -1
  15. package/build/{ops.d.ts → opcodes.d.ts} +2 -3
  16. package/build/{ops.js → opcodes.js} +4 -5
  17. package/build/payments/embed.js +1 -1
  18. package/build/payments/p2ms.js +1 -1
  19. package/build/payments/p2op.js +1 -1
  20. package/build/payments/p2pk.js +1 -1
  21. package/build/payments/p2pkh.js +1 -1
  22. package/build/payments/p2sh.js +3 -3
  23. package/build/payments/p2tr.js +1 -1
  24. package/build/payments/p2wpkh.js +2 -2
  25. package/build/payments/p2wsh.js +2 -2
  26. package/build/push_data.js +9 -9
  27. package/build/script.d.ts +2 -2
  28. package/build/script.js +12 -12
  29. package/build/transaction.js +1 -1
  30. package/cjs/package.json +3 -3
  31. package/gulpfile.js +42 -42
  32. package/package.json +150 -150
  33. package/src/address.ts +304 -303
  34. package/src/bip66.ts +107 -107
  35. package/src/block.ts +233 -233
  36. package/src/bufferutils.ts +188 -188
  37. package/src/crypto.ts +108 -108
  38. package/src/ecc_lib.ts +94 -94
  39. package/src/hooks/AdvancedSignatureManager.ts +104 -104
  40. package/src/hooks/SignatureManager.ts +84 -84
  41. package/src/index.ts +105 -105
  42. package/src/merkle.ts +31 -31
  43. package/src/{ops.ts → opcodes.ts} +280 -282
  44. package/src/payments/bip341.ts +140 -140
  45. package/src/payments/embed.ts +61 -61
  46. package/src/payments/index.ts +172 -172
  47. package/src/payments/lazy.ts +28 -28
  48. package/src/payments/p2ms.ts +156 -156
  49. package/src/payments/p2op.ts +195 -195
  50. package/src/payments/p2pk.ts +93 -93
  51. package/src/payments/p2pkh.ts +214 -214
  52. package/src/payments/p2sh.ts +210 -210
  53. package/src/payments/p2tr.ts +309 -309
  54. package/src/payments/p2wpkh.ts +144 -144
  55. package/src/payments/p2wsh.ts +217 -217
  56. package/src/psbt/bip371.ts +441 -441
  57. package/src/push_data.ts +97 -97
  58. package/src/script.ts +247 -247
  59. package/src/script_number.ts +72 -72
  60. package/src/script_signature.ts +91 -91
  61. package/src/transaction.ts +656 -656
  62. package/test/address.spec.ts +155 -155
  63. package/test/bitcoin.core.spec.ts +212 -212
  64. package/test/block.spec.ts +171 -171
  65. package/test/bufferutils.spec.ts +450 -450
  66. package/test/crypto.spec.ts +49 -49
  67. package/test/fixtures/address.json +329 -329
  68. package/test/fixtures/block.json +148 -148
  69. package/test/fixtures/bufferutils.json +102 -102
  70. package/test/fixtures/core/README.md +26 -26
  71. package/test/fixtures/core/base58_encode_decode.json +50 -50
  72. package/test/fixtures/core/base58_keys_invalid.json +152 -152
  73. package/test/fixtures/core/base58_keys_valid.json +452 -452
  74. package/test/fixtures/core/blocks.json +27 -27
  75. package/test/fixtures/core/sig_canonical.json +7 -7
  76. package/test/fixtures/core/sig_noncanonical.json +33 -33
  77. package/test/fixtures/core/sighash.json +3505 -3505
  78. package/test/fixtures/core/tx_valid.json +2023 -2023
  79. package/test/fixtures/crypto.json +43 -43
  80. package/test/fixtures/ecdsa.json +217 -217
  81. package/test/fixtures/ecpair.json +141 -141
  82. package/test/fixtures/embed.json +108 -108
  83. package/test/fixtures/p2ms.json +434 -434
  84. package/test/fixtures/p2pk.json +179 -179
  85. package/test/fixtures/p2pkh.json +276 -276
  86. package/test/fixtures/p2sh.json +508 -508
  87. package/test/fixtures/p2tr.json +1198 -1198
  88. package/test/fixtures/p2wpkh.json +290 -290
  89. package/test/fixtures/p2wsh.json +489 -489
  90. package/test/fixtures/psbt.json +924 -924
  91. package/test/fixtures/script.json +465 -465
  92. package/test/fixtures/script_number.json +225 -225
  93. package/test/fixtures/signature.json +140 -140
  94. package/test/fixtures/transaction.json +916 -916
  95. package/test/integration/_regtest.ts +6 -6
  96. package/test/integration/addresses.spec.ts +142 -142
  97. package/test/integration/bip32.spec.ts +130 -130
  98. package/test/integration/blocks.spec.ts +28 -28
  99. package/test/integration/cltv.spec.ts +241 -241
  100. package/test/integration/csv.spec.ts +452 -452
  101. package/test/integration/payments.spec.ts +110 -110
  102. package/test/integration/taproot.spec.ts +663 -663
  103. package/test/integration/transactions.spec.ts +668 -668
  104. package/test/payments.spec.ts +114 -114
  105. package/test/payments.utils.ts +165 -165
  106. package/test/psbt.spec.ts +1285 -1285
  107. package/test/script.spec.ts +186 -186
  108. package/test/script_number.spec.ts +26 -26
  109. package/test/script_signature.spec.ts +66 -66
  110. package/test/transaction.spec.ts +337 -337
  111. package/test/ts-node-register.js +7 -7
  112. package/test/tsconfig.json +48 -48
  113. package/test/types.spec.ts +53 -53
  114. package/tsconfig.base.json +27 -27
  115. package/tsconfig.json +19 -19
  116. package/tsconfig.webpack.json +18 -18
  117. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/.ready +0 -0
  118. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/.release-please-manifest.json +0 -3
  119. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/CHANGELOG.md +0 -962
  120. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/CONTRIBUTING.md +0 -34
  121. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/LICENSE +0 -24
  122. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/README.md +0 -273
  123. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/SECURITY.md +0 -2
  124. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/addon.gypi +0 -204
  125. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/bin/node-gyp.js +0 -138
  126. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/.release-please-manifest.json +0 -3
  127. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/LICENSE +0 -28
  128. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/data/ninja/build.ninja +0 -4
  129. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/data/win/large-pdb-shim.cc +0 -12
  130. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/GypVsCMake.md +0 -116
  131. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/Hacking.md +0 -46
  132. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/InputFormatReference.md +0 -1080
  133. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/LanguageSpecification.md +0 -430
  134. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/README.md +0 -27
  135. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/Testing.md +0 -450
  136. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/docs/UserDocumentation.md +0 -965
  137. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/gyp +0 -8
  138. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/gyp.bat +0 -5
  139. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/gyp_main.py +0 -45
  140. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSNew.py +0 -365
  141. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSProject.py +0 -206
  142. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings.py +0 -1272
  143. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSSettings_test.py +0 -1547
  144. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSToolFile.py +0 -59
  145. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSUserFile.py +0 -153
  146. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSUtil.py +0 -271
  147. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/MSVSVersion.py +0 -574
  148. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/__init__.py +0 -692
  149. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/common.py +0 -711
  150. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/common_test.py +0 -171
  151. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/easy_xml.py +0 -169
  152. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/easy_xml_test.py +0 -113
  153. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/flock_tool.py +0 -55
  154. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/__init__.py +0 -0
  155. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/analyzer.py +0 -804
  156. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/android.py +0 -1173
  157. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/cmake.py +0 -1318
  158. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/compile_commands_json.py +0 -127
  159. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/dump_dependency_json.py +0 -103
  160. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/eclipse.py +0 -461
  161. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/gypd.py +0 -89
  162. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/gypsh.py +0 -57
  163. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py +0 -2745
  164. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs.py +0 -3976
  165. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/msvs_test.py +0 -44
  166. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja.py +0 -2964
  167. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/ninja_test.py +0 -67
  168. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode.py +0 -1391
  169. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/generator/xcode_test.py +0 -25
  170. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/input.py +0 -3115
  171. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/input_test.py +0 -98
  172. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/mac_tool.py +0 -771
  173. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/msvs_emulation.py +0 -1260
  174. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/ninja_syntax.py +0 -174
  175. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/simple_copy.py +0 -61
  176. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/win_tool.py +0 -373
  177. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py +0 -1938
  178. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation_test.py +0 -53
  179. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcode_ninja.py +0 -302
  180. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xcodeproj_file.py +0 -3198
  181. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/gyp/xml_fix.py +0 -65
  182. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/LICENSE +0 -3
  183. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/LICENSE.APACHE +0 -177
  184. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/LICENSE.BSD +0 -23
  185. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/__init__.py +0 -15
  186. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_elffile.py +0 -108
  187. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_manylinux.py +0 -252
  188. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_musllinux.py +0 -83
  189. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_parser.py +0 -359
  190. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_structures.py +0 -61
  191. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/_tokenizer.py +0 -192
  192. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/markers.py +0 -252
  193. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/metadata.py +0 -825
  194. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/py.typed +0 -0
  195. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/requirements.py +0 -90
  196. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/specifiers.py +0 -1030
  197. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/tags.py +0 -553
  198. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/utils.py +0 -172
  199. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pylib/packaging/version.py +0 -563
  200. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/pyproject.toml +0 -120
  201. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/release-please-config.json +0 -11
  202. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/gyp/test_gyp.py +0 -261
  203. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/Find-VisualStudio.cs +0 -250
  204. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/build.js +0 -227
  205. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/clean.js +0 -15
  206. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/configure.js +0 -328
  207. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/create-config-gypi.js +0 -150
  208. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/download.js +0 -39
  209. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/find-node-directory.js +0 -63
  210. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/find-python.js +0 -310
  211. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/find-visualstudio.js +0 -590
  212. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/install.js +0 -415
  213. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/list.js +0 -26
  214. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/log.js +0 -168
  215. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/node-gyp.js +0 -188
  216. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/process-release.js +0 -146
  217. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/rebuild.js +0 -12
  218. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/remove.js +0 -43
  219. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/lib/util.js +0 -81
  220. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/macOS_Catalina_acid_test.sh +0 -21
  221. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/package.json +0 -51
  222. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/release-please-config.json +0 -40
  223. package/.yarn/unplugged/node-gyp-npm-10.2.0-cad1109948/node_modules/node-gyp/src/win_delay_load_hook.cc +0 -39
  224. package/coverage/tmp/coverage-31752-1735543485354-0.json +0 -1
  225. package/coverage/tmp/coverage-59920-1735543484555-0.json +0 -1
  226. package/coverage/tmp/coverage-66252-1735543483919-0.json +0 -1
  227. package/coverage/tmp/coverage-68440-1735543485236-0.json +0 -1
  228. package/coverage/tmp/coverage-70588-1735543484426-0.json +0 -1
  229. package/coverage/tmp/coverage-79292-1735543485296-0.json +0 -1
  230. package/coverage/tmp/coverage-80212-1735543483980-0.json +0 -1
@@ -1,171 +0,0 @@
1
- #!/usr/bin/env python3
2
-
3
- # Copyright (c) 2012 Google Inc. All rights reserved.
4
- # Use of this source code is governed by a BSD-style license that can be
5
- # found in the LICENSE file.
6
-
7
- """Unit tests for the common.py file."""
8
-
9
- import gyp.common
10
- import unittest
11
- import sys
12
- import os
13
- from unittest.mock import patch, MagicMock
14
-
15
- class TestTopologicallySorted(unittest.TestCase):
16
- def test_Valid(self):
17
- """Test that sorting works on a valid graph with one possible order."""
18
- graph = {
19
- "a": ["b", "c"],
20
- "b": [],
21
- "c": ["d"],
22
- "d": ["b"],
23
- }
24
-
25
- def GetEdge(node):
26
- return tuple(graph[node])
27
-
28
- assert gyp.common.TopologicallySorted(
29
- graph.keys(), GetEdge) == ["a", "c", "d", "b"]
30
-
31
- def test_Cycle(self):
32
- """Test that an exception is thrown on a cyclic graph."""
33
- graph = {
34
- "a": ["b"],
35
- "b": ["c"],
36
- "c": ["d"],
37
- "d": ["a"],
38
- }
39
-
40
- def GetEdge(node):
41
- return tuple(graph[node])
42
-
43
- self.assertRaises(
44
- gyp.common.CycleError, gyp.common.TopologicallySorted, graph.keys(), GetEdge
45
- )
46
-
47
-
48
- class TestGetFlavor(unittest.TestCase):
49
- """Test that gyp.common.GetFlavor works as intended"""
50
-
51
- original_platform = ""
52
-
53
- def setUp(self):
54
- self.original_platform = sys.platform
55
-
56
- def tearDown(self):
57
- sys.platform = self.original_platform
58
-
59
- def assertFlavor(self, expected, argument, param):
60
- sys.platform = argument
61
- assert expected == gyp.common.GetFlavor(param)
62
-
63
- def test_platform_default(self):
64
- self.assertFlavor("freebsd", "freebsd9", {})
65
- self.assertFlavor("freebsd", "freebsd10", {})
66
- self.assertFlavor("openbsd", "openbsd5", {})
67
- self.assertFlavor("solaris", "sunos5", {})
68
- self.assertFlavor("solaris", "sunos", {})
69
- self.assertFlavor("linux", "linux2", {})
70
- self.assertFlavor("linux", "linux3", {})
71
- self.assertFlavor("linux", "linux", {})
72
-
73
- def test_param(self):
74
- self.assertFlavor("foobar", "linux2", {"flavor": "foobar"})
75
-
76
- class MockCommunicate:
77
- def __init__(self, stdout):
78
- self.stdout = stdout
79
-
80
- def decode(self, encoding):
81
- return self.stdout
82
-
83
- @patch("os.close")
84
- @patch("os.unlink")
85
- @patch("tempfile.mkstemp")
86
- def test_GetCrossCompilerPredefines(self, mock_mkstemp, mock_unlink, mock_close):
87
- mock_close.return_value = None
88
- mock_unlink.return_value = None
89
- mock_mkstemp.return_value = (0, "temp.c")
90
-
91
- def mock_run(env, defines_stdout, expected_cmd):
92
- with patch("subprocess.run") as mock_run:
93
- mock_process = MagicMock()
94
- mock_process.returncode = 0
95
- mock_process.stdout = TestGetFlavor.MockCommunicate(defines_stdout)
96
- mock_run.return_value = mock_process
97
- expected_input = "temp.c" if sys.platform == "win32" else "/dev/null"
98
- with patch.dict(os.environ, env):
99
- defines = gyp.common.GetCrossCompilerPredefines()
100
- flavor = gyp.common.GetFlavor({})
101
- if env.get("CC_target"):
102
- mock_run.assert_called_with(
103
- [
104
- *expected_cmd,
105
- "-dM", "-E", "-x", "c", expected_input
106
- ],
107
- shell=sys.platform == "win32",
108
- capture_output=True, check=True)
109
- return [defines, flavor]
110
-
111
- [defines1, _] = mock_run({}, "", [])
112
- assert {} == defines1
113
-
114
- [defines2, flavor2] = mock_run(
115
- { "CC_target": "/opt/wasi-sdk/bin/clang" },
116
- "#define __wasm__ 1\n#define __wasi__ 1\n",
117
- ["/opt/wasi-sdk/bin/clang"]
118
- )
119
- assert { "__wasm__": "1", "__wasi__": "1" } == defines2
120
- assert flavor2 == "wasi"
121
-
122
- [defines3, flavor3] = mock_run(
123
- { "CC_target": "/opt/wasi-sdk/bin/clang --target=wasm32" },
124
- "#define __wasm__ 1\n",
125
- ["/opt/wasi-sdk/bin/clang", "--target=wasm32"]
126
- )
127
- assert { "__wasm__": "1" } == defines3
128
- assert flavor3 == "wasm"
129
-
130
- [defines4, flavor4] = mock_run(
131
- { "CC_target": "/emsdk/upstream/emscripten/emcc" },
132
- "#define __EMSCRIPTEN__ 1\n",
133
- ["/emsdk/upstream/emscripten/emcc"]
134
- )
135
- assert { "__EMSCRIPTEN__": "1" } == defines4
136
- assert flavor4 == "emscripten"
137
-
138
- # Test path which include white space
139
- [defines5, flavor5] = mock_run(
140
- {
141
- "CC_target": "\"/Users/Toyo Li/wasi-sdk/bin/clang\" -O3",
142
- "CFLAGS": "--target=wasm32-wasi-threads -pthread"
143
- },
144
- "#define __wasm__ 1\n#define __wasi__ 1\n#define _REENTRANT 1\n",
145
- [
146
- "/Users/Toyo Li/wasi-sdk/bin/clang",
147
- "-O3",
148
- "--target=wasm32-wasi-threads",
149
- "-pthread"
150
- ]
151
- )
152
- assert {
153
- "__wasm__": "1",
154
- "__wasi__": "1",
155
- "_REENTRANT": "1"
156
- } == defines5
157
- assert flavor5 == "wasi"
158
-
159
- original_sep = os.sep
160
- os.sep = "\\"
161
- [defines6, flavor6] = mock_run(
162
- { "CC_target": "\"C:\\Program Files\\wasi-sdk\\clang.exe\"" },
163
- "#define __wasm__ 1\n#define __wasi__ 1\n",
164
- ["C:/Program Files/wasi-sdk/clang.exe"]
165
- )
166
- os.sep = original_sep
167
- assert { "__wasm__": "1", "__wasi__": "1" } == defines6
168
- assert flavor6 == "wasi"
169
-
170
- if __name__ == "__main__":
171
- unittest.main()
@@ -1,169 +0,0 @@
1
- # Copyright (c) 2011 Google Inc. All rights reserved.
2
- # Use of this source code is governed by a BSD-style license that can be
3
- # found in the LICENSE file.
4
-
5
- import sys
6
- import re
7
- import os
8
- import locale
9
- from functools import reduce
10
-
11
-
12
- def XmlToString(content, encoding="utf-8", pretty=False):
13
- """ Writes the XML content to disk, touching the file only if it has changed.
14
-
15
- Visual Studio files have a lot of pre-defined structures. This function makes
16
- it easy to represent these structures as Python data structures, instead of
17
- having to create a lot of function calls.
18
-
19
- Each XML element of the content is represented as a list composed of:
20
- 1. The name of the element, a string,
21
- 2. The attributes of the element, a dictionary (optional), and
22
- 3+. The content of the element, if any. Strings are simple text nodes and
23
- lists are child elements.
24
-
25
- Example 1:
26
- <test/>
27
- becomes
28
- ['test']
29
-
30
- Example 2:
31
- <myelement a='value1' b='value2'>
32
- <childtype>This is</childtype>
33
- <childtype>it!</childtype>
34
- </myelement>
35
-
36
- becomes
37
- ['myelement', {'a':'value1', 'b':'value2'},
38
- ['childtype', 'This is'],
39
- ['childtype', 'it!'],
40
- ]
41
-
42
- Args:
43
- content: The structured content to be converted.
44
- encoding: The encoding to report on the first XML line.
45
- pretty: True if we want pretty printing with indents and new lines.
46
-
47
- Returns:
48
- The XML content as a string.
49
- """
50
- # We create a huge list of all the elements of the file.
51
- xml_parts = ['<?xml version="1.0" encoding="%s"?>' % encoding]
52
- if pretty:
53
- xml_parts.append("\n")
54
- _ConstructContentList(xml_parts, content, pretty)
55
-
56
- # Convert it to a string
57
- return "".join(xml_parts)
58
-
59
-
60
- def _ConstructContentList(xml_parts, specification, pretty, level=0):
61
- """ Appends the XML parts corresponding to the specification.
62
-
63
- Args:
64
- xml_parts: A list of XML parts to be appended to.
65
- specification: The specification of the element. See EasyXml docs.
66
- pretty: True if we want pretty printing with indents and new lines.
67
- level: Indentation level.
68
- """
69
- # The first item in a specification is the name of the element.
70
- if pretty:
71
- indentation = " " * level
72
- new_line = "\n"
73
- else:
74
- indentation = ""
75
- new_line = ""
76
- name = specification[0]
77
- if not isinstance(name, str):
78
- raise Exception(
79
- "The first item of an EasyXml specification should be "
80
- "a string. Specification was " + str(specification)
81
- )
82
- xml_parts.append(indentation + "<" + name)
83
-
84
- # Optionally in second position is a dictionary of the attributes.
85
- rest = specification[1:]
86
- if rest and isinstance(rest[0], dict):
87
- for at, val in sorted(rest[0].items()):
88
- xml_parts.append(f' {at}="{_XmlEscape(val, attr=True)}"')
89
- rest = rest[1:]
90
- if rest:
91
- xml_parts.append(">")
92
- all_strings = reduce(lambda x, y: x and isinstance(y, str), rest, True)
93
- multi_line = not all_strings
94
- if multi_line and new_line:
95
- xml_parts.append(new_line)
96
- for child_spec in rest:
97
- # If it's a string, append a text node.
98
- # Otherwise recurse over that child definition
99
- if isinstance(child_spec, str):
100
- xml_parts.append(_XmlEscape(child_spec))
101
- else:
102
- _ConstructContentList(xml_parts, child_spec, pretty, level + 1)
103
- if multi_line and indentation:
104
- xml_parts.append(indentation)
105
- xml_parts.append(f"</{name}>{new_line}")
106
- else:
107
- xml_parts.append("/>%s" % new_line)
108
-
109
-
110
- def WriteXmlIfChanged(content, path, encoding="utf-8", pretty=False,
111
- win32=(sys.platform == "win32")):
112
- """ Writes the XML content to disk, touching the file only if it has changed.
113
-
114
- Args:
115
- content: The structured content to be written.
116
- path: Location of the file.
117
- encoding: The encoding to report on the first line of the XML file.
118
- pretty: True if we want pretty printing with indents and new lines.
119
- """
120
- xml_string = XmlToString(content, encoding, pretty)
121
- if win32 and os.linesep != "\r\n":
122
- xml_string = xml_string.replace("\n", "\r\n")
123
-
124
- try: # getdefaultlocale() was removed in Python 3.11
125
- default_encoding = locale.getdefaultlocale()[1]
126
- except AttributeError:
127
- default_encoding = locale.getencoding()
128
-
129
- if default_encoding and default_encoding.upper() != encoding.upper():
130
- xml_string = xml_string.encode(encoding)
131
-
132
- # Get the old content
133
- try:
134
- with open(path) as file:
135
- existing = file.read()
136
- except OSError:
137
- existing = None
138
-
139
- # It has changed, write it
140
- if existing != xml_string:
141
- with open(path, "wb") as file:
142
- file.write(xml_string)
143
-
144
-
145
- _xml_escape_map = {
146
- '"': "&quot;",
147
- "'": "&apos;",
148
- "<": "&lt;",
149
- ">": "&gt;",
150
- "&": "&amp;",
151
- "\n": "&#xA;",
152
- "\r": "&#xD;",
153
- }
154
-
155
-
156
- _xml_escape_re = re.compile("(%s)" % "|".join(map(re.escape, _xml_escape_map.keys())))
157
-
158
-
159
- def _XmlEscape(value, attr=False):
160
- """ Escape a string for inclusion in XML."""
161
-
162
- def replace(match):
163
- m = match.string[match.start() : match.end()]
164
- # don't replace single quotes in attrs
165
- if attr and m == "'":
166
- return m
167
- return _xml_escape_map[m]
168
-
169
- return _xml_escape_re.sub(replace, value)
@@ -1,113 +0,0 @@
1
- #!/usr/bin/env python3
2
-
3
- # Copyright (c) 2011 Google Inc. All rights reserved.
4
- # Use of this source code is governed by a BSD-style license that can be
5
- # found in the LICENSE file.
6
-
7
- """ Unit tests for the easy_xml.py file. """
8
-
9
- import gyp.easy_xml as easy_xml
10
- import unittest
11
-
12
- from io import StringIO
13
-
14
-
15
- class TestSequenceFunctions(unittest.TestCase):
16
- def setUp(self):
17
- self.stderr = StringIO()
18
-
19
- def test_EasyXml_simple(self):
20
- self.assertEqual(
21
- easy_xml.XmlToString(["test"]),
22
- '<?xml version="1.0" encoding="utf-8"?><test/>',
23
- )
24
-
25
- self.assertEqual(
26
- easy_xml.XmlToString(["test"], encoding="Windows-1252"),
27
- '<?xml version="1.0" encoding="Windows-1252"?><test/>',
28
- )
29
-
30
- def test_EasyXml_simple_with_attributes(self):
31
- self.assertEqual(
32
- easy_xml.XmlToString(["test2", {"a": "value1", "b": "value2"}]),
33
- '<?xml version="1.0" encoding="utf-8"?><test2 a="value1" b="value2"/>',
34
- )
35
-
36
- def test_EasyXml_escaping(self):
37
- original = "<test>'\"\r&\nfoo"
38
- converted = "&lt;test&gt;'&quot;&#xD;&amp;&#xA;foo"
39
- converted_apos = converted.replace("'", "&apos;")
40
- self.assertEqual(
41
- easy_xml.XmlToString(["test3", {"a": original}, original]),
42
- '<?xml version="1.0" encoding="utf-8"?><test3 a="%s">%s</test3>'
43
- % (converted, converted_apos),
44
- )
45
-
46
- def test_EasyXml_pretty(self):
47
- self.assertEqual(
48
- easy_xml.XmlToString(
49
- ["test3", ["GrandParent", ["Parent1", ["Child"]], ["Parent2"]]],
50
- pretty=True,
51
- ),
52
- '<?xml version="1.0" encoding="utf-8"?>\n'
53
- "<test3>\n"
54
- " <GrandParent>\n"
55
- " <Parent1>\n"
56
- " <Child/>\n"
57
- " </Parent1>\n"
58
- " <Parent2/>\n"
59
- " </GrandParent>\n"
60
- "</test3>\n",
61
- )
62
-
63
- def test_EasyXml_complex(self):
64
- # We want to create:
65
- target = (
66
- '<?xml version="1.0" encoding="utf-8"?>'
67
- "<Project>"
68
- '<PropertyGroup Label="Globals">'
69
- "<ProjectGuid>{D2250C20-3A94-4FB9-AF73-11BC5B73884B}</ProjectGuid>"
70
- "<Keyword>Win32Proj</Keyword>"
71
- "<RootNamespace>automated_ui_tests</RootNamespace>"
72
- "</PropertyGroup>"
73
- '<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.props"/>'
74
- "<PropertyGroup "
75
- "Condition=\"'$(Configuration)|$(Platform)'=="
76
- '\'Debug|Win32\'" Label="Configuration">'
77
- "<ConfigurationType>Application</ConfigurationType>"
78
- "<CharacterSet>Unicode</CharacterSet>"
79
- "<SpectreMitigation>SpectreLoadCF</SpectreMitigation>"
80
- "<VCToolsVersion>14.36.32532</VCToolsVersion>"
81
- "</PropertyGroup>"
82
- "</Project>"
83
- )
84
-
85
- xml = easy_xml.XmlToString(
86
- [
87
- "Project",
88
- [
89
- "PropertyGroup",
90
- {"Label": "Globals"},
91
- ["ProjectGuid", "{D2250C20-3A94-4FB9-AF73-11BC5B73884B}"],
92
- ["Keyword", "Win32Proj"],
93
- ["RootNamespace", "automated_ui_tests"],
94
- ],
95
- ["Import", {"Project": "$(VCTargetsPath)\\Microsoft.Cpp.props"}],
96
- [
97
- "PropertyGroup",
98
- {
99
- "Condition": "'$(Configuration)|$(Platform)'=='Debug|Win32'",
100
- "Label": "Configuration",
101
- },
102
- ["ConfigurationType", "Application"],
103
- ["CharacterSet", "Unicode"],
104
- ["SpectreMitigation", "SpectreLoadCF"],
105
- ["VCToolsVersion", "14.36.32532"],
106
- ],
107
- ]
108
- )
109
- self.assertEqual(xml, target)
110
-
111
-
112
- if __name__ == "__main__":
113
- unittest.main()
@@ -1,55 +0,0 @@
1
- #!/usr/bin/env python3
2
- # Copyright (c) 2011 Google Inc. All rights reserved.
3
- # Use of this source code is governed by a BSD-style license that can be
4
- # found in the LICENSE file.
5
-
6
- """These functions are executed via gyp-flock-tool when using the Makefile
7
- generator. Used on systems that don't have a built-in flock."""
8
-
9
- import fcntl
10
- import os
11
- import struct
12
- import subprocess
13
- import sys
14
-
15
-
16
- def main(args):
17
- executor = FlockTool()
18
- executor.Dispatch(args)
19
-
20
-
21
- class FlockTool:
22
- """This class emulates the 'flock' command."""
23
-
24
- def Dispatch(self, args):
25
- """Dispatches a string command to a method."""
26
- if len(args) < 1:
27
- raise Exception("Not enough arguments")
28
-
29
- method = "Exec%s" % self._CommandifyName(args[0])
30
- getattr(self, method)(*args[1:])
31
-
32
- def _CommandifyName(self, name_string):
33
- """Transforms a tool name like copy-info-plist to CopyInfoPlist"""
34
- return name_string.title().replace("-", "")
35
-
36
- def ExecFlock(self, lockfile, *cmd_list):
37
- """Emulates the most basic behavior of Linux's flock(1)."""
38
- # Rely on exception handling to report errors.
39
- # Note that the stock python on SunOS has a bug
40
- # where fcntl.flock(fd, LOCK_EX) always fails
41
- # with EBADF, that's why we use this F_SETLK
42
- # hack instead.
43
- fd = os.open(lockfile, os.O_WRONLY | os.O_NOCTTY | os.O_CREAT, 0o666)
44
- if sys.platform.startswith("aix") or sys.platform == "os400":
45
- # Python on AIX is compiled with LARGEFILE support, which changes the
46
- # struct size.
47
- op = struct.pack("hhIllqq", fcntl.F_WRLCK, 0, 0, 0, 0, 0, 0)
48
- else:
49
- op = struct.pack("hhllhhl", fcntl.F_WRLCK, 0, 0, 0, 0, 0, 0)
50
- fcntl.fcntl(fd, fcntl.F_SETLK, op)
51
- return subprocess.call(cmd_list)
52
-
53
-
54
- if __name__ == "__main__":
55
- sys.exit(main(sys.argv[1:]))