diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4b9732fb61..9d85c4dd11 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -35,24 +35,12 @@ jobs: override: true toolchain: stable - - name: Install from bitcoincore.org - if: ${{ matrix.os == 'ubuntu-latest' }} - run: | - curl -O https://bitcoincore.org/bin/bitcoin-core-23.0/bitcoin-23.0-x86_64-linux-gnu.tar.gz - tar xvf bitcoin-23.0-x86_64-linux-gnu.tar.gz - cp bitcoin-23.0/bin/bitcoind /usr/local/bin/ - - uses: Swatinem/rust-cache@v1 - name: Check Lockfile run: cargo update --locked --package ord - - name: Test on MacOS (unit tests) - if: ${{ matrix.os == 'macos-latest' }} - run: cargo test --bin ord - - - name: Test on Linux (all tests) - if: ${{ matrix.os == 'ubuntu-latest' }} + - name: Test run: cargo test --all - name: Clippy diff --git a/Cargo.lock b/Cargo.lock index cdd78baa6e..2358a5a9b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -71,17 +71,6 @@ dependencies = [ "opaque-debug", ] -[[package]] -name = "ahash" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" -dependencies = [ - "getrandom 0.2.7", - "once_cell", - "version_check", -] - [[package]] name = "aho-corasick" version = "0.7.19" @@ -196,7 +185,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "279cf904654eeebfa37ac9bb1598880884924aab82e290aa65c9e77a0e142e06" dependencies = [ "async-lock", - "autocfg 1.1.0", + "autocfg", "blocking", "futures-lite", ] @@ -238,7 +227,7 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83e21f3a490c72b3b0cf44962180e60045de2925d8dff97918f7ee43c8f637c7" dependencies = [ - "autocfg 1.1.0", + "autocfg", "concurrent-queue", "futures-lite", "libc", @@ -268,7 +257,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4051e67316bc7eff608fe723df5d32ed639946adcd69e07df41fd42a7b411f1f" dependencies = [ "async-io", - "autocfg 1.1.0", + "autocfg", "blocking", "futures-lite", ] @@ -280,7 +269,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02111fd8655a613c25069ea89fc8d9bb89331fa77486eb3bc059ee757cfa481c" dependencies = [ "async-io", - "autocfg 1.1.0", + "autocfg", "blocking", "cfg-if 1.0.0", "event-listener", @@ -351,15 +340,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "autocfg" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" -dependencies = [ - "autocfg 1.1.0", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -469,78 +449,24 @@ dependencies = [ "byteorder", ] -[[package]] -name = "bdk" -version = "0.22.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14836e8b1312be32e46f5da47e1189c2239fa75f9237a0a7c7aea9ee7071a2bc" -dependencies = [ - "ahash", - "async-trait", - "bdk-macros", - "bip39", - "bitcoin", - "bitcoincore-rpc", - "electrum-client", - "js-sys", - "log", - "miniscript", - "rand 0.7.3", - "rusqlite", - "serde", - "serde_json", - "sled", - "tokio", -] - -[[package]] -name = "bdk-macros" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81c1980e50ae23bb6efa9283ae8679d6ea2c6fa6a99fe62533f65f4a25a1a56c" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "bech32" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf9ff0bbfd639f15c74af777d81383cf53efb7c93613f6cab67c6c11e05bbf8b" -[[package]] -name = "bip39" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e89470017230c38e52b82b3ee3f530db1856ba1d434e3a67a3456a8a8dec5f" -dependencies = [ - "bitcoin_hashes 0.9.7", - "rand_core 0.4.2", - "serde", - "unicode-normalization", -] - [[package]] name = "bitcoin" version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05bba324e6baf655b882df672453dbbc527bc938cadd27750ae510aaccc3a66a" dependencies = [ - "base64-compat", "bech32", - "bitcoin_hashes 0.10.0", + "bitcoin_hashes", "secp256k1", "serde", ] -[[package]] -name = "bitcoin_hashes" -version = "0.9.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ce18265ec2324ad075345d5814fbeed4f41f0a660055dc78840b74d19b874b1" - [[package]] name = "bitcoin_hashes" version = "0.10.0" @@ -740,15 +666,6 @@ dependencies = [ "os_str_bytes", ] -[[package]] -name = "cloudabi" -version = "0.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" -dependencies = [ - "bitflags", -] - [[package]] name = "concurrent-queue" version = "1.2.4" @@ -818,15 +735,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcb25d077389e53838a8158c8e99174c5a9d902dee4904320db714f3c653ffba" -[[package]] -name = "crc32fast" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" -dependencies = [ - "cfg-if 1.0.0", -] - [[package]] name = "crossbeam-channel" version = "0.5.6" @@ -854,7 +762,7 @@ version = "0.9.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "045ebe27666471bb549370b4b0b3e51b07f56325befa4284db65fc89c02511b1" dependencies = [ - "autocfg 1.1.0", + "autocfg", "cfg-if 1.0.0", "crossbeam-utils", "memoffset", @@ -917,7 +825,7 @@ version = "3.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d91974fbbe88ec1df0c24a4f00f99583667a7e2e6272b2b92d294d81e462173" dependencies = [ - "nix 0.25.0", + "nix", "winapi", ] @@ -1057,24 +965,6 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" -[[package]] -name = "electrum-client" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af53c415260dcb220fa02182669727c730535bfed4edbfde42e1291342af95cd" -dependencies = [ - "bitcoin", - "byteorder", - "libc", - "log", - "rustls", - "serde", - "serde_json", - "webpki 0.22.0", - "webpki-roots 0.22.5", - "winapi", -] - [[package]] name = "encoding_rs" version = "0.8.31" @@ -1109,18 +999,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ebc5a6d89e3c90b84e8f33c8737933dda8f1c106b5415900b38b9d433841478" -[[package]] -name = "fallible-iterator" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" - -[[package]] -name = "fallible-streaming-iterator" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" - [[package]] name = "fastrand" version = "1.8.0" @@ -1160,22 +1038,6 @@ dependencies = [ "percent-encoding 2.2.0", ] -[[package]] -name = "fs2" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213" -dependencies = [ - "libc", - "winapi", -] - -[[package]] -name = "fuchsia-cprng" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" - [[package]] name = "futures" version = "0.1.31" @@ -1299,15 +1161,6 @@ dependencies = [ "slab", ] -[[package]] -name = "fxhash" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" -dependencies = [ - "byteorder", -] - [[package]] name = "generic-array" version = "0.14.6" @@ -1334,10 +1187,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ "cfg-if 1.0.0", - "js-sys", "libc", "wasi 0.9.0+wasi-snapshot-preview1", - "wasm-bindgen", ] [[package]] @@ -1411,30 +1262,12 @@ dependencies = [ "tracing", ] -[[package]] -name = "hashbrown" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" -dependencies = [ - "ahash", -] - [[package]] name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -[[package]] -name = "hashlink" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7249a3129cbc1ffccd74857f81464a323a152173cdb134e0fd81bc803b29facf" -dependencies = [ - "hashbrown 0.11.2", -] - [[package]] name = "heck" version = "0.4.0" @@ -1635,8 +1468,8 @@ version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" dependencies = [ - "autocfg 1.1.0", - "hashbrown 0.12.3", + "autocfg", + "hashbrown", ] [[package]] @@ -1810,23 +1643,13 @@ version = "0.2.133" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0f80d65747a3e43d1596c7c5492d95d5edddaabd45a7fcdb02b95f644164966" -[[package]] -name = "libsqlite3-sys" -version = "0.24.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "898745e570c7d0453cc1fbc4a701eb6c662ed54e8fec8b7d14be137ebeeb9d14" -dependencies = [ - "pkg-config", - "vcpkg", -] - [[package]] name = "lock_api" version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f80bf5aacaf25cbfc8210d1cfb718f2bf3b11c4c54e5afe36c236853a8ec390" dependencies = [ - "autocfg 1.1.0", + "autocfg", "scopeguard", ] @@ -1870,7 +1693,7 @@ version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" dependencies = [ - "autocfg 1.1.0", + "autocfg", ] [[package]] @@ -1895,16 +1718,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "miniscript" -version = "7.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da39fc7a8adea97a677337b0091779dd86349226b869053af496584a9b9e5847" -dependencies = [ - "bitcoin", - "serde", -] - [[package]] name = "miniz_oxide" version = "0.5.4" @@ -1965,25 +1778,13 @@ dependencies = [ "unicase", ] -[[package]] -name = "nix" -version = "0.24.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "195cdbc1741b8134346d515b3a56a1c94b0912758009cfd53f99ea0f57b065fc" -dependencies = [ - "bitflags", - "cfg-if 1.0.0", - "libc", - "memoffset", -] - [[package]] name = "nix" version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e322c04a9e3440c327fca7b6c8a63e6890a32fa2ad689db972425f07e0d22abb" dependencies = [ - "autocfg 1.1.0", + "autocfg", "bitflags", "cfg-if 1.0.0", "libc", @@ -2005,7 +1806,7 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" dependencies = [ - "autocfg 1.1.0", + "autocfg", "num-integer", "num-traits", ] @@ -2016,7 +1817,7 @@ version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" dependencies = [ - "autocfg 1.1.0", + "autocfg", "num-traits", ] @@ -2026,7 +1827,7 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" dependencies = [ - "autocfg 1.1.0", + "autocfg", ] [[package]] @@ -2116,7 +1917,7 @@ version = "0.9.75" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5f9bd0c2710541a3cda73d6f9ac4f1b240de4ae261065d309dbe73d9dceb42f" dependencies = [ - "autocfg 1.1.0", + "autocfg", "cc", "libc", "pkg-config", @@ -2130,7 +1931,6 @@ dependencies = [ "anyhow", "axum", "axum-server", - "bdk", "bitcoin", "bitcoincore-rpc", "boilerplate", @@ -2147,7 +1947,6 @@ dependencies = [ "lazy_static", "log", "mime_guess", - "nix 0.24.2", "pretty_assertions", "primes", "pulldown-cmark", @@ -2282,7 +2081,7 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "899b00b9c8ab553c743b3e11e87c5c7d423b2a2de229ba95b24a756344748011" dependencies = [ - "autocfg 1.1.0", + "autocfg", "cfg-if 1.0.0", "libc", "log", @@ -2404,25 +2203,6 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" -dependencies = [ - "autocfg 0.1.8", - "libc", - "rand_chacha 0.1.1", - "rand_core 0.4.2", - "rand_hc 0.1.0", - "rand_isaac", - "rand_jitter", - "rand_os", - "rand_pcg", - "rand_xorshift", - "winapi", -] - [[package]] name = "rand" version = "0.7.3" @@ -2433,7 +2213,7 @@ dependencies = [ "libc", "rand_chacha 0.2.2", "rand_core 0.5.1", - "rand_hc 0.2.0", + "rand_hc", ] [[package]] @@ -2447,16 +2227,6 @@ dependencies = [ "rand_core 0.6.4", ] -[[package]] -name = "rand_chacha" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" -dependencies = [ - "autocfg 0.1.8", - "rand_core 0.3.1", -] - [[package]] name = "rand_chacha" version = "0.2.2" @@ -2477,21 +2247,6 @@ dependencies = [ "rand_core 0.6.4", ] -[[package]] -name = "rand_core" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" -dependencies = [ - "rand_core 0.4.2", -] - -[[package]] -name = "rand_core" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" - [[package]] name = "rand_core" version = "0.5.1" @@ -2510,15 +2265,6 @@ dependencies = [ "getrandom 0.2.7", ] -[[package]] -name = "rand_hc" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "rand_hc" version = "0.2.0" @@ -2528,66 +2274,13 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "rand_isaac" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" -dependencies = [ - "rand_core 0.3.1", -] - -[[package]] -name = "rand_jitter" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" -dependencies = [ - "libc", - "rand_core 0.4.2", - "winapi", -] - -[[package]] -name = "rand_os" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" -dependencies = [ - "cloudabi", - "fuchsia-cprng", - "libc", - "rand_core 0.4.2", - "rdrand", - "winapi", -] - -[[package]] -name = "rand_pcg" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" -dependencies = [ - "autocfg 0.1.8", - "rand_core 0.4.2", -] - -[[package]] -name = "rand_xorshift" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "rayon" version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" dependencies = [ - "autocfg 1.1.0", + "autocfg", "crossbeam-deque", "either", "rayon-core", @@ -2617,15 +2310,6 @@ dependencies = [ "yasna", ] -[[package]] -name = "rdrand" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" -dependencies = [ - "rand_core 0.3.1", -] - [[package]] name = "redb" version = "0.7.0" @@ -2734,21 +2418,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rusqlite" -version = "0.27.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85127183a999f7db96d1a976a309eebbfb6ea3b0b400ddd8340190129de6eb7a" -dependencies = [ - "bitflags", - "fallible-iterator", - "fallible-streaming-iterator", - "hashlink", - "libsqlite3-sys", - "memchr", - "smallvec 1.9.0", -] - [[package]] name = "rust-embed" version = "6.4.1" @@ -2856,7 +2525,7 @@ dependencies = [ "tokio", "tokio-util 0.7.4", "url 2.3.0", - "webpki-roots 0.21.1", + "webpki-roots", "x509-parser", ] @@ -2916,7 +2585,6 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26947345339603ae8395f68e2f3d85a6b0a8ddfe6315818e80b8504415099db0" dependencies = [ - "rand 0.6.5", "secp256k1-sys", "serde", ] @@ -3101,23 +2769,7 @@ version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" dependencies = [ - "autocfg 1.1.0", -] - -[[package]] -name = "sled" -version = "0.34.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f96b4737c2ce5987354855aed3797279def4ebf734436c6aa4552cf8e169935" -dependencies = [ - "crc32fast", - "crossbeam-epoch", - "crossbeam-utils", - "fs2", - "fxhash", - "libc", - "log", - "parking_lot", + "autocfg", ] [[package]] @@ -3418,7 +3070,7 @@ version = "1.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0020c875007ad96677dcc890298f4b942882c5d4eb7cc8f439fc3bf813dc9c95" dependencies = [ - "autocfg 1.1.0", + "autocfg", "bytes", "libc", "memchr", @@ -3851,15 +3503,6 @@ dependencies = [ "webpki 0.21.4", ] -[[package]] -name = "webpki-roots" -version = "0.22.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368bfe657969fb01238bb756d351dcade285e0f6fcbd36dcb23359a5169975be" -dependencies = [ - "webpki 0.22.0", -] - [[package]] name = "wepoll-ffi" version = "0.1.2" diff --git a/Cargo.toml b/Cargo.toml index 5e27477b51..fe0b122a28 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,9 +47,7 @@ tower = "0.4.13" tower-http = { version = "0.3.3", features = ["cors"] } [dev-dependencies] -bdk = { version = "0.22.0", features = ["rpc", "keys-bip39", "sqlite"] } executable-path = "1.0.0" -nix = "0.24.1" pretty_assertions = "1.2.1" reqwest = { version = "0.11.10", features = ["blocking"] } tempfile = "3.2.0" diff --git a/src/index.rs b/src/index.rs index 0814bf037d..42dcede313 100644 --- a/src/index.rs +++ b/src/index.rs @@ -868,4 +868,26 @@ mod tests { let context = Context::new(); assert_eq!(context.index.find(50 * COIN_VALUE).unwrap(), None); } + + #[test] + fn find_first_satoshi_spent_in_second_block() { + let context = Context::new(); + context.rpc_server.mine_blocks(1); + let spend_txid = context + .rpc_server + .broadcast_tx(test_bitcoincore_rpc::TransactionTemplate { + input_slots: &[(1, 0, 0)], + output_count: 1, + fee: 0, + }); + context.rpc_server.mine_blocks(1); + context.index.index().unwrap(); + assert_eq!( + context.index.find(50 * COIN_VALUE).unwrap().unwrap(), + SatPoint { + outpoint: OutPoint::new(spend_txid, 0), + offset: 0, + } + ) + } } diff --git a/tests/expected.rs b/tests/expected.rs index 0a6b8a1e27..9659a71754 100644 --- a/tests/expected.rs +++ b/tests/expected.rs @@ -4,7 +4,6 @@ use super::*; pub(crate) enum Expected { String(String), Regex(Regex), - Ignore, } impl Expected { @@ -21,7 +20,6 @@ impl Expected { regex, output ), - Self::Ignore => {} } } } diff --git a/tests/find.rs b/tests/find.rs index e63bb84df9..1739f243e1 100644 --- a/tests/find.rs +++ b/tests/find.rs @@ -18,19 +18,3 @@ fn unmined_ordinal() { .expected_status(1) .run(); } - -#[test] -fn first_satoshi_spent_in_second_block() { - SlowTest::new() - .command("find 0") - .blocks(101) - .transaction(TransactionOptions { - slots: &[(1, 0, 0)], - output_count: 1, - fee: 0, - recipient: None, - }) - .blocks(1) - .expected_stdout("4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b:0:0\n") - .run(); -} diff --git a/tests/lib.rs b/tests/lib.rs index 8ed7fa4baa..4cd61ed3dd 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -1,34 +1,13 @@ #![allow(clippy::type_complexity)] use { - self::{ - command_builder::CommandBuilder, expected::Expected, slow_test::SlowTest, state::State, - transaction_options::TransactionOptions, - }, - bdk::{ - blockchain::{ - rpc::{RpcBlockchain, RpcConfig}, - ConfigurableBlockchain, - }, - database::MemoryDatabase, - keys::bip39::Mnemonic, - template::Bip84, - wallet::{signer::SignOptions, AddressIndex, SyncOptions, Wallet}, - KeychainKind, - }, - bitcoin::{hash_types::Txid, network::constants::Network, Block, OutPoint, Script, Transaction}, - bitcoincore_rpc::{Client, RawTx, RpcApi}, + self::{command_builder::CommandBuilder, expected::Expected}, executable_path::executable_path, - log::LevelFilter, regex::Regex, std::{ fs, - net::TcpListener, - process::{Child, Command, Stdio}, + process::{Command, Stdio}, str, - sync::Once, - thread::sleep, - time::Duration, }, tempfile::TempDir, unindent::Unindent, @@ -43,9 +22,6 @@ mod info; mod list; mod parse; mod range; -mod slow_test; -mod state; mod supply; mod traits; -mod transaction_options; mod version; diff --git a/tests/slow_test.rs b/tests/slow_test.rs deleted file mode 100644 index f627612618..0000000000 --- a/tests/slow_test.rs +++ /dev/null @@ -1,101 +0,0 @@ -use super::*; - -pub(crate) struct SlowTest { - args: Vec, - expected_status: i32, - expected_stderr: Expected, - expected_stdout: Expected, - state: State, -} - -impl SlowTest { - pub(crate) fn new() -> Self { - Self::with_state(State::new()) - } - - pub(crate) fn with_state(state: State) -> Self { - let test = Self { - args: Vec::new(), - state, - expected_status: 0, - expected_stderr: Expected::Ignore, - expected_stdout: Expected::String(String::new()), - }; - - test.state.sync(); - - test - } - - pub(crate) fn command(self, args: &str) -> Self { - Self { - args: args.split_whitespace().map(str::to_owned).collect(), - ..self - } - } - - pub(crate) fn expected_stdout(self, expected_stdout: impl AsRef) -> Self { - Self { - expected_stdout: Expected::String(expected_stdout.as_ref().to_owned()), - ..self - } - } - - pub(crate) fn run(self) { - self.output(); - } - - pub(crate) fn output(self) -> State { - let output = Command::new(executable_path("ord")) - .env("HOME", self.state.tempdir.path()) - .stdin(Stdio::null()) - .stdout(Stdio::piped()) - .stderr(if !matches!(self.expected_stderr, Expected::Ignore) { - Stdio::piped() - } else { - Stdio::inherit() - }) - .current_dir(&self.state.tempdir) - .arg(format!( - "--rpc-url=localhost:{}", - self.state.bitcoind_rpc_port - )) - .arg("--cookie-file=bitcoin/regtest/.cookie") - .args(self.args.clone()) - .output() - .unwrap(); - - let stdout = str::from_utf8(&output.stdout).unwrap(); - let stderr = str::from_utf8(&output.stderr).unwrap(); - - if output.status.code() != Some(self.expected_status) { - panic!( - "Test failed: {}\nstdout:\n{}\nstderr:\n{}", - output.status, stdout, stderr - ); - } - - let log_line_re = Regex::new(r"(?m)^\[.*\n").unwrap(); - - for log_line in log_line_re.find_iter(stderr) { - print!("{}", log_line.as_str()) - } - - let stripped_stderr = log_line_re.replace_all(stderr, ""); - - self.expected_stderr.assert_match(&stripped_stderr); - self.expected_stdout.assert_match(stdout); - - self.state - } - - pub(crate) fn blocks(self, n: u64) -> Self { - self.state.blocks(n); - self - } - - pub(crate) fn transaction(self, options: TransactionOptions) -> Self { - self.state.transaction(options); - self - } -} diff --git a/tests/state.rs b/tests/state.rs deleted file mode 100644 index 6a79b1c987..0000000000 --- a/tests/state.rs +++ /dev/null @@ -1,211 +0,0 @@ -use super::*; - -fn free_port() -> u16 { - TcpListener::bind("127.0.0.1:0") - .unwrap() - .local_addr() - .unwrap() - .port() -} - -pub(crate) struct State { - bitcoind: Child, - pub(crate) tempdir: TempDir, - pub(crate) client: Client, - pub(crate) wallet: Wallet, - pub(crate) blockchain: RpcBlockchain, - pub(crate) bitcoind_rpc_port: u16, - ord: Option, -} - -static ONCE: Once = Once::new(); - -impl State { - pub(crate) fn new() -> Self { - ONCE.call_once(env_logger::init); - - let tempdir = TempDir::new().unwrap(); - - fs::create_dir(tempdir.path().join("bitcoin")).unwrap(); - - let bitcoind_rpc_port = free_port(); - - let bitcoind = Command::new("bitcoind") - .stdout(if log::max_level() >= LevelFilter::Info { - Stdio::inherit() - } else { - Stdio::null() - }) - .args(&[ - "-txindex=1", - "-minrelaytxfee=0", - "-blockmintxfee=0", - "-dustrelayfee=0", - "-maxtxfee=21000000", - "-datadir=bitcoin", - "-regtest", - "-networkactive=0", - "-listen=0", - &format!("-rpcport={bitcoind_rpc_port}"), - ]) - .current_dir(&tempdir.path()) - .spawn() - .unwrap(); - - let cookiefile = tempdir.path().join("bitcoin/regtest/.cookie"); - - while !cookiefile.is_file() {} - - let client = Client::new( - &format!("localhost:{bitcoind_rpc_port}"), - bitcoincore_rpc::Auth::CookieFile(cookiefile.clone()), - ) - .unwrap(); - - for attempt in 0..=300 { - match client.get_blockchain_info() { - Ok(_) => break, - Err(err) => { - if attempt == 300 { - panic!("Failed to connect to bitcoind: {err}"); - } - } - } - sleep(Duration::from_millis(100)); - } - - let wallet = Wallet::new( - Bip84( - ( - Mnemonic::parse("book fit fly ketchup also elevator scout mind edit fatal where rookie") - .unwrap(), - None, - ), - KeychainKind::External, - ), - None, - Network::Regtest, - MemoryDatabase::new(), - ) - .unwrap(); - - let blockchain = RpcBlockchain::from_config(&RpcConfig { - url: format!("localhost:{bitcoind_rpc_port}"), - auth: bdk::blockchain::rpc::Auth::Cookie { file: cookiefile }, - network: Network::Regtest, - wallet_name: "test".to_string(), - sync_params: None, - }) - .unwrap(); - - State { - tempdir, - bitcoind_rpc_port, - bitcoind, - client, - wallet, - ord: None, - blockchain, - } - } - - pub(crate) fn get_block(&self, height: u64) -> Block { - self - .client - .get_block(&self.client.get_block_hash(height).unwrap()) - .unwrap() - } - - pub(crate) fn sync(&self) { - self - .wallet - .sync(&self.blockchain, SyncOptions::default()) - .unwrap(); - } - - pub(crate) fn blocks(&self, n: u64) -> Vec { - self - .client - .generate_to_address( - n, - &self - .wallet - .get_address(AddressIndex::Peek(0)) - .unwrap() - .address, - ) - .unwrap() - } - - pub(crate) fn transaction(&self, options: TransactionOptions) -> Transaction { - self.sync(); - - let input_value = options - .slots - .iter() - .map(|slot| self.get_block(slot.0 as u64).txdata[slot.1].output[slot.2].value) - .sum::(); - - let output_value = input_value - options.fee; - - let (mut psbt, _) = { - let mut builder = self.wallet.build_tx(); - - builder - .manually_selected_only() - .fee_absolute(options.fee) - .allow_dust(true) - .add_utxos( - &options - .slots - .iter() - .map(|slot| OutPoint { - txid: self.get_block(slot.0 as u64).txdata[slot.1].txid(), - vout: slot.2 as u32, - }) - .collect::>(), - ) - .unwrap() - .set_recipients(vec![ - ( - options.recipient.unwrap_or_else(|| self - .wallet - .get_address(AddressIndex::Peek(0)) - .unwrap() - .address - .script_pubkey()), - output_value / options.output_count as u64 - ); - options.output_count - ]); - - builder.finish().unwrap() - }; - - if !self.wallet.sign(&mut psbt, SignOptions::default()).unwrap() { - panic!("Failed to sign transaction"); - } - - let tx = psbt.extract_tx(); - - self - .client - .call::( - "sendrawtransaction", - &[tx.raw_hex().into(), 21000000.into()], - ) - .unwrap(); - - tx - } -} - -impl Drop for State { - fn drop(&mut self) { - if let Some(ord) = &mut self.ord { - ord.kill().unwrap(); - } - - self.bitcoind.kill().unwrap(); - } -} diff --git a/tests/transaction_options.rs b/tests/transaction_options.rs deleted file mode 100644 index 414b12b214..0000000000 --- a/tests/transaction_options.rs +++ /dev/null @@ -1,8 +0,0 @@ -use super::*; - -pub(crate) struct TransactionOptions<'a> { - pub(crate) slots: &'a [(usize, usize, usize)], - pub(crate) output_count: usize, - pub(crate) fee: u64, - pub(crate) recipient: Option