From 022730bd8d740b877befa611046c99cd7ceeebfe Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 8 Sep 2022 09:32:08 +1000 Subject: [PATCH] Add a workspace to the top level directory. Create a directory `bitcoin` and move into it the following as is with no code changes: - src - Cargo.toml - contrib - test_data - examples Then do: - Add a workspace to the repository root directory. - Add the newly created `bitcoin` crate to the workspace. - Exclude `fuzz` and `embedded` crates from the workspace. - Add a contrib/test.sh script that runs contrib/test.sh in each sub-crate - Fix the bitcoin/contrib/test.sh script --- Cargo.toml | 65 +-------- bitcoin/Cargo.toml | 62 +++++++++ {contrib => bitcoin/contrib}/act/event.json | 0 bitcoin/contrib/test.sh | 127 ++++++++++++++++++ {examples => bitcoin/examples}/bip32.rs | 0 {examples => bitcoin/examples}/ecdsa-psbt.rs | 0 {examples => bitcoin/examples}/handshake.rs | 0 {src => bitcoin/src}/address.rs | 0 {src => bitcoin/src}/bip158.rs | 0 {src => bitcoin/src}/blockdata/block.rs | 0 {src => bitcoin/src}/blockdata/constants.rs | 0 .../src}/blockdata/locktime/absolute.rs | 0 .../src}/blockdata/locktime/mod.rs | 0 .../src}/blockdata/locktime/relative.rs | 0 {src => bitcoin/src}/blockdata/mod.rs | 0 {src => bitcoin/src}/blockdata/opcodes.rs | 0 {src => bitcoin/src}/blockdata/script.rs | 0 {src => bitcoin/src}/blockdata/transaction.rs | 0 {src => bitcoin/src}/blockdata/witness.rs | 0 {src => bitcoin/src}/consensus/encode.rs | 0 {src => bitcoin/src}/consensus/mod.rs | 0 {src => bitcoin/src}/consensus/params.rs | 0 {src => bitcoin/src}/error.rs | 0 {src => bitcoin/src}/hash_types.rs | 0 {src => bitcoin/src}/internal_macros.rs | 0 {src => bitcoin/src}/lib.rs | 0 {src => bitcoin/src}/network/address.rs | 0 {src => bitcoin/src}/network/constants.rs | 0 {src => bitcoin/src}/network/message.rs | 0 .../src}/network/message_blockdata.rs | 0 {src => bitcoin/src}/network/message_bloom.rs | 0 .../src}/network/message_compact_blocks.rs | 0 .../src}/network/message_filter.rs | 0 .../src}/network/message_network.rs | 0 {src => bitcoin/src}/network/mod.rs | 0 {src => bitcoin/src}/parse.rs | 0 {src => bitcoin/src}/policy.rs | 0 {src => bitcoin/src}/serde_utils.rs | 0 {src => bitcoin/src}/test_macros.rs | 0 {src => bitcoin/src}/util/amount.rs | 0 {src => bitcoin/src}/util/base58.rs | 0 {src => bitcoin/src}/util/bip143.rs | 0 {src => bitcoin/src}/util/bip152.rs | 0 {src => bitcoin/src}/util/bip32.rs | 0 {src => bitcoin/src}/util/ecdsa.rs | 0 {src => bitcoin/src}/util/endian.rs | 0 {src => bitcoin/src}/util/hash.rs | 0 {src => bitcoin/src}/util/key.rs | 0 {src => bitcoin/src}/util/merkleblock.rs | 0 {src => bitcoin/src}/util/misc.rs | 0 {src => bitcoin/src}/util/mod.rs | 0 {src => bitcoin/src}/util/psbt/error.rs | 0 {src => bitcoin/src}/util/psbt/macros.rs | 0 {src => bitcoin/src}/util/psbt/map/global.rs | 0 {src => bitcoin/src}/util/psbt/map/input.rs | 0 {src => bitcoin/src}/util/psbt/map/mod.rs | 0 {src => bitcoin/src}/util/psbt/map/output.rs | 0 {src => bitcoin/src}/util/psbt/mod.rs | 0 {src => bitcoin/src}/util/psbt/raw.rs | 0 {src => bitcoin/src}/util/psbt/serialize.rs | 0 {src => bitcoin/src}/util/schnorr.rs | 0 {src => bitcoin/src}/util/sighash.rs | 0 {src => bitcoin/src}/util/taproot.rs | 0 {src => bitcoin/src}/util/uint.rs | 0 .../test_data}/bip341_tests.json | 0 .../test_data}/blockfilters.json | 0 .../test_data}/legacy_sighash.json | 0 ...2adcaedc20fdf6ee440009c249452c726dafae.raw | Bin {test_data => bitcoin/test_data}/psbt1.hex | 0 {test_data => bitcoin/test_data}/psbt2.hex | 0 .../test_data}/psbt_combined.hex | 0 ...5b5e5c5ab63c9a4f956be7e1e69be04fa4497b.raw | Bin contrib/test.sh | 123 +---------------- embedded/Cargo.toml | 2 +- fuzz/Cargo.toml | 2 +- rustfmt.toml | 8 +- 76 files changed, 205 insertions(+), 184 deletions(-) create mode 100644 bitcoin/Cargo.toml rename {contrib => bitcoin/contrib}/act/event.json (100%) create mode 100755 bitcoin/contrib/test.sh rename {examples => bitcoin/examples}/bip32.rs (100%) rename {examples => bitcoin/examples}/ecdsa-psbt.rs (100%) rename {examples => bitcoin/examples}/handshake.rs (100%) rename {src => bitcoin/src}/address.rs (100%) rename {src => bitcoin/src}/bip158.rs (100%) rename {src => bitcoin/src}/blockdata/block.rs (100%) rename {src => bitcoin/src}/blockdata/constants.rs (100%) rename {src => bitcoin/src}/blockdata/locktime/absolute.rs (100%) rename {src => bitcoin/src}/blockdata/locktime/mod.rs (100%) rename {src => bitcoin/src}/blockdata/locktime/relative.rs (100%) rename {src => bitcoin/src}/blockdata/mod.rs (100%) rename {src => bitcoin/src}/blockdata/opcodes.rs (100%) rename {src => bitcoin/src}/blockdata/script.rs (100%) rename {src => bitcoin/src}/blockdata/transaction.rs (100%) rename {src => bitcoin/src}/blockdata/witness.rs (100%) rename {src => bitcoin/src}/consensus/encode.rs (100%) rename {src => bitcoin/src}/consensus/mod.rs (100%) rename {src => bitcoin/src}/consensus/params.rs (100%) rename {src => bitcoin/src}/error.rs (100%) rename {src => bitcoin/src}/hash_types.rs (100%) rename {src => bitcoin/src}/internal_macros.rs (100%) rename {src => bitcoin/src}/lib.rs (100%) rename {src => bitcoin/src}/network/address.rs (100%) rename {src => bitcoin/src}/network/constants.rs (100%) rename {src => bitcoin/src}/network/message.rs (100%) rename {src => bitcoin/src}/network/message_blockdata.rs (100%) rename {src => bitcoin/src}/network/message_bloom.rs (100%) rename {src => bitcoin/src}/network/message_compact_blocks.rs (100%) rename {src => bitcoin/src}/network/message_filter.rs (100%) rename {src => bitcoin/src}/network/message_network.rs (100%) rename {src => bitcoin/src}/network/mod.rs (100%) rename {src => bitcoin/src}/parse.rs (100%) rename {src => bitcoin/src}/policy.rs (100%) rename {src => bitcoin/src}/serde_utils.rs (100%) rename {src => bitcoin/src}/test_macros.rs (100%) rename {src => bitcoin/src}/util/amount.rs (100%) rename {src => bitcoin/src}/util/base58.rs (100%) rename {src => bitcoin/src}/util/bip143.rs (100%) rename {src => bitcoin/src}/util/bip152.rs (100%) rename {src => bitcoin/src}/util/bip32.rs (100%) rename {src => bitcoin/src}/util/ecdsa.rs (100%) rename {src => bitcoin/src}/util/endian.rs (100%) rename {src => bitcoin/src}/util/hash.rs (100%) rename {src => bitcoin/src}/util/key.rs (100%) rename {src => bitcoin/src}/util/merkleblock.rs (100%) rename {src => bitcoin/src}/util/misc.rs (100%) rename {src => bitcoin/src}/util/mod.rs (100%) rename {src => bitcoin/src}/util/psbt/error.rs (100%) rename {src => bitcoin/src}/util/psbt/macros.rs (100%) rename {src => bitcoin/src}/util/psbt/map/global.rs (100%) rename {src => bitcoin/src}/util/psbt/map/input.rs (100%) rename {src => bitcoin/src}/util/psbt/map/mod.rs (100%) rename {src => bitcoin/src}/util/psbt/map/output.rs (100%) rename {src => bitcoin/src}/util/psbt/mod.rs (100%) rename {src => bitcoin/src}/util/psbt/raw.rs (100%) rename {src => bitcoin/src}/util/psbt/serialize.rs (100%) rename {src => bitcoin/src}/util/schnorr.rs (100%) rename {src => bitcoin/src}/util/sighash.rs (100%) rename {src => bitcoin/src}/util/taproot.rs (100%) rename {src => bitcoin/src}/util/uint.rs (100%) rename {test_data => bitcoin/test_data}/bip341_tests.json (100%) rename {test_data => bitcoin/test_data}/blockfilters.json (100%) rename {test_data => bitcoin/test_data}/legacy_sighash.json (100%) rename {test_data => bitcoin/test_data}/mainnet_block_000000000000000000000c835b2adcaedc20fdf6ee440009c249452c726dafae.raw (100%) rename {test_data => bitcoin/test_data}/psbt1.hex (100%) rename {test_data => bitcoin/test_data}/psbt2.hex (100%) rename {test_data => bitcoin/test_data}/psbt_combined.hex (100%) rename {test_data => bitcoin/test_data}/testnet_block_000000000000045e0b1660b6445b5e5c5ab63c9a4f956be7e1e69be04fa4497b.raw (100%) diff --git a/Cargo.toml b/Cargo.toml index 0a371932..db18ff4d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,62 +1,3 @@ -[package] -name = "bitcoin" -version = "0.29.0" -authors = ["Andrew Poelstra "] -license = "CC0-1.0" -homepage = "https://github.com/rust-bitcoin/rust-bitcoin/" -repository = "https://github.com/rust-bitcoin/rust-bitcoin/" -documentation = "https://docs.rs/bitcoin/" -description = "General purpose library for using and interoperating with Bitcoin and other cryptocurrencies." -keywords = [ "crypto", "bitcoin" ] -readme = "README.md" -exclude = ["./test_data"] -edition = "2018" - -# Please don't forget to add relevant features to docs.rs below -[features] -default = [ "std", "secp-recovery" ] -rand = ["secp256k1/rand-std"] -serde = ["actual-serde", "bitcoin_hashes/serde", "secp256k1/serde"] -secp-lowmemory = ["secp256k1/lowmemory"] -secp-recovery = ["secp256k1/recovery"] - -# At least one of std, no-std must be enabled. -# -# The no-std feature doesn't disable std - you need to turn off the std feature for that by disabling default. -# Instead no-std enables additional features required for this crate to be usable without std. -# As a result, both can be enabled without conflict. -std = ["secp256k1/std", "bitcoin_hashes/std", "bech32/std"] -no-std = ["hashbrown", "core2/alloc", "bitcoin_hashes/alloc", "secp256k1/alloc"] - -[package.metadata.docs.rs] -features = [ "std", "secp-recovery", "base64", "rand", "serde", "bitcoinconsensus" ] -rustdoc-args = ["--cfg", "docsrs"] - -[dependencies] -bech32 = { version = "0.9.0", default-features = false } -bitcoin_hashes = { version = "0.11.0", default-features = false } -secp256k1 = { version = "0.24.0", default-features = false, features = ["bitcoin_hashes"] } -core2 = { version = "0.3.0", optional = true, default-features = false } - -base64 = { version = "0.13.0", optional = true } -bitcoinconsensus = { version = "0.20.2-0.5.0", optional = true } -# Do NOT use this as a feature! Use the `serde` feature instead. -actual-serde = { package = "serde", version = "1", default-features = false, features = [ "derive", "alloc" ], optional = true } -hashbrown = { version = "0.8", optional = true } - -[dev-dependencies] -serde_json = "<1.0.45" -serde_test = "1" -secp256k1 = { version = "0.24.0", features = [ "recovery", "rand-std" ] } -bincode = "1.3.1" - -[[example]] -name = "bip32" - -[[example]] -name = "handshake" -required-features = ["std"] - -[[example]] -name = "ecdsa-psbt" -required-features = ["std", "bitcoinconsensus"] +[workspace] +members = ["bitcoin"] +exclude = ["embedded", "fuzz"] diff --git a/bitcoin/Cargo.toml b/bitcoin/Cargo.toml new file mode 100644 index 00000000..0a371932 --- /dev/null +++ b/bitcoin/Cargo.toml @@ -0,0 +1,62 @@ +[package] +name = "bitcoin" +version = "0.29.0" +authors = ["Andrew Poelstra "] +license = "CC0-1.0" +homepage = "https://github.com/rust-bitcoin/rust-bitcoin/" +repository = "https://github.com/rust-bitcoin/rust-bitcoin/" +documentation = "https://docs.rs/bitcoin/" +description = "General purpose library for using and interoperating with Bitcoin and other cryptocurrencies." +keywords = [ "crypto", "bitcoin" ] +readme = "README.md" +exclude = ["./test_data"] +edition = "2018" + +# Please don't forget to add relevant features to docs.rs below +[features] +default = [ "std", "secp-recovery" ] +rand = ["secp256k1/rand-std"] +serde = ["actual-serde", "bitcoin_hashes/serde", "secp256k1/serde"] +secp-lowmemory = ["secp256k1/lowmemory"] +secp-recovery = ["secp256k1/recovery"] + +# At least one of std, no-std must be enabled. +# +# The no-std feature doesn't disable std - you need to turn off the std feature for that by disabling default. +# Instead no-std enables additional features required for this crate to be usable without std. +# As a result, both can be enabled without conflict. +std = ["secp256k1/std", "bitcoin_hashes/std", "bech32/std"] +no-std = ["hashbrown", "core2/alloc", "bitcoin_hashes/alloc", "secp256k1/alloc"] + +[package.metadata.docs.rs] +features = [ "std", "secp-recovery", "base64", "rand", "serde", "bitcoinconsensus" ] +rustdoc-args = ["--cfg", "docsrs"] + +[dependencies] +bech32 = { version = "0.9.0", default-features = false } +bitcoin_hashes = { version = "0.11.0", default-features = false } +secp256k1 = { version = "0.24.0", default-features = false, features = ["bitcoin_hashes"] } +core2 = { version = "0.3.0", optional = true, default-features = false } + +base64 = { version = "0.13.0", optional = true } +bitcoinconsensus = { version = "0.20.2-0.5.0", optional = true } +# Do NOT use this as a feature! Use the `serde` feature instead. +actual-serde = { package = "serde", version = "1", default-features = false, features = [ "derive", "alloc" ], optional = true } +hashbrown = { version = "0.8", optional = true } + +[dev-dependencies] +serde_json = "<1.0.45" +serde_test = "1" +secp256k1 = { version = "0.24.0", features = [ "recovery", "rand-std" ] } +bincode = "1.3.1" + +[[example]] +name = "bip32" + +[[example]] +name = "handshake" +required-features = ["std"] + +[[example]] +name = "ecdsa-psbt" +required-features = ["std", "bitcoinconsensus"] diff --git a/contrib/act/event.json b/bitcoin/contrib/act/event.json similarity index 100% rename from contrib/act/event.json rename to bitcoin/contrib/act/event.json diff --git a/bitcoin/contrib/test.sh b/bitcoin/contrib/test.sh new file mode 100755 index 00000000..69805acc --- /dev/null +++ b/bitcoin/contrib/test.sh @@ -0,0 +1,127 @@ +#!/bin/sh + +set -ex + +FEATURES="base64 bitcoinconsensus serde rand secp-recovery" + +if [ "$DO_COV" = true ] +then + export RUSTFLAGS="-C link-dead-code" +fi + +cargo --version +rustc --version + +# Work out if we are using a nightly toolchain. +NIGHTLY=false +if cargo --version | grep nightly; then + NIGHTLY=true +fi + +# We should not have any duplicate dependencies. This catches mistakes made upgrading dependencies +# in one crate and not in another (e.g. upgrade bitcoin_hashes in bitcoin but not in secp). +cargo update -p serde --precise 1.0.142 +cargo update -p serde_test --precise 1.0.142 +cargo update -p serde_derive --precise 1.0.142 +duplicate_dependencies=$(cargo tree --target=all --all-features --duplicates | wc -l) +if [ "$duplicate_dependencies" -ne 0 ]; then + echo "Dependency tree is broken, contains duplicates" + cargo tree --target=all --all-features --duplicates + exit 1 +fi + +if [ "$DO_LINT" = true ] +then + cargo clippy --all-features --all-targets -- -D warnings + cargo clippy --example bip32 -- -D warnings + cargo clippy --example handshake -- -D warnings + cargo clippy --example ecdsa-psbt --features=bitcoinconsensus -- -D warnings +fi + +echo "********* Testing std *************" +# Test without any features other than std first +cargo test --verbose --no-default-features --features="std" + +echo "********* Testing default *************" +# Then test with the default features +cargo test --verbose + +if [ "$DO_NO_STD" = true ] +then + echo "********* Testing no-std build *************" + # Build no_std, to make sure that cfg(test) doesn't hide any issues + cargo build --verbose --features="no-std" --no-default-features + + # Build std + no_std, to make sure they are not incompatible + cargo build --verbose --features="no-std" + + # Test no_std + cargo test --verbose --features="no-std" --no-default-features + + # Build all features + cargo build --verbose --features="no-std $FEATURES" --no-default-features + + # Build specific features + for feature in ${FEATURES} + do + cargo build --verbose --features="no-std $feature" + done + + cargo run --example bip32 7934c09359b234e076b9fa5a1abfd38e3dc2a9939745b7cc3c22a48d831d14bd + cargo run --no-default-features --features no-std --example bip32 7934c09359b234e076b9fa5a1abfd38e3dc2a9939745b7cc3c22a48d831d14bd +fi + +# Test each feature +for feature in ${FEATURES} +do + echo "********* Testing $feature *************" + cargo test --verbose --features="$feature" +done + +cargo run --example ecdsa-psbt --features=bitcoinconsensus + +# Build the docs if told to (this only works with the nightly toolchain) +if [ "$DO_DOCS" = true ]; then + RUSTDOCFLAGS="--cfg docsrs" cargo +nightly rustdoc --features="$FEATURES" -- -D rustdoc::broken-intra-doc-links +fi + +# Fuzz if told to +if [ "$DO_FUZZ" = true ] +then + ( + cd fuzz + cargo test --verbose + ./travis-fuzz.sh + ) +fi + +# Bench if told to, only works with non-stable toolchain (nightly, beta). +if [ "$DO_BENCH" = true ] +then + if [ "$NIGHTLY" = false ] + then + if [ -n "$RUSTUP_TOOLCHAIN" ] + then + echo "RUSTUP_TOOLCHAIN is set to a non-nightly toolchain but DO_BENCH requires a nightly toolchain" + else + echo "DO_BENCH requires a nightly toolchain" + fi + exit 1 + fi + RUSTFLAGS='--cfg=bench' cargo bench +fi + +# Use as dependency if told to +if [ "$AS_DEPENDENCY" = true ] +then + cargo new dep_test 2> /dev/null # Mute warning about workspace, fixed below. + cd dep_test + echo 'bitcoin = { path = "..", features = ["serde"] }\n\n' >> Cargo.toml + # Adding an empty workspace section excludes this crate from the rust-bitcoin workspace. + echo '[workspace]\n\n' >> Cargo.toml + + cargo update -p serde --precise 1.0.142 + cargo update -p serde_derive --precise 1.0.142 + + cargo test --verbose +fi diff --git a/examples/bip32.rs b/bitcoin/examples/bip32.rs similarity index 100% rename from examples/bip32.rs rename to bitcoin/examples/bip32.rs diff --git a/examples/ecdsa-psbt.rs b/bitcoin/examples/ecdsa-psbt.rs similarity index 100% rename from examples/ecdsa-psbt.rs rename to bitcoin/examples/ecdsa-psbt.rs diff --git a/examples/handshake.rs b/bitcoin/examples/handshake.rs similarity index 100% rename from examples/handshake.rs rename to bitcoin/examples/handshake.rs diff --git a/src/address.rs b/bitcoin/src/address.rs similarity index 100% rename from src/address.rs rename to bitcoin/src/address.rs diff --git a/src/bip158.rs b/bitcoin/src/bip158.rs similarity index 100% rename from src/bip158.rs rename to bitcoin/src/bip158.rs diff --git a/src/blockdata/block.rs b/bitcoin/src/blockdata/block.rs similarity index 100% rename from src/blockdata/block.rs rename to bitcoin/src/blockdata/block.rs diff --git a/src/blockdata/constants.rs b/bitcoin/src/blockdata/constants.rs similarity index 100% rename from src/blockdata/constants.rs rename to bitcoin/src/blockdata/constants.rs diff --git a/src/blockdata/locktime/absolute.rs b/bitcoin/src/blockdata/locktime/absolute.rs similarity index 100% rename from src/blockdata/locktime/absolute.rs rename to bitcoin/src/blockdata/locktime/absolute.rs diff --git a/src/blockdata/locktime/mod.rs b/bitcoin/src/blockdata/locktime/mod.rs similarity index 100% rename from src/blockdata/locktime/mod.rs rename to bitcoin/src/blockdata/locktime/mod.rs diff --git a/src/blockdata/locktime/relative.rs b/bitcoin/src/blockdata/locktime/relative.rs similarity index 100% rename from src/blockdata/locktime/relative.rs rename to bitcoin/src/blockdata/locktime/relative.rs diff --git a/src/blockdata/mod.rs b/bitcoin/src/blockdata/mod.rs similarity index 100% rename from src/blockdata/mod.rs rename to bitcoin/src/blockdata/mod.rs diff --git a/src/blockdata/opcodes.rs b/bitcoin/src/blockdata/opcodes.rs similarity index 100% rename from src/blockdata/opcodes.rs rename to bitcoin/src/blockdata/opcodes.rs diff --git a/src/blockdata/script.rs b/bitcoin/src/blockdata/script.rs similarity index 100% rename from src/blockdata/script.rs rename to bitcoin/src/blockdata/script.rs diff --git a/src/blockdata/transaction.rs b/bitcoin/src/blockdata/transaction.rs similarity index 100% rename from src/blockdata/transaction.rs rename to bitcoin/src/blockdata/transaction.rs diff --git a/src/blockdata/witness.rs b/bitcoin/src/blockdata/witness.rs similarity index 100% rename from src/blockdata/witness.rs rename to bitcoin/src/blockdata/witness.rs diff --git a/src/consensus/encode.rs b/bitcoin/src/consensus/encode.rs similarity index 100% rename from src/consensus/encode.rs rename to bitcoin/src/consensus/encode.rs diff --git a/src/consensus/mod.rs b/bitcoin/src/consensus/mod.rs similarity index 100% rename from src/consensus/mod.rs rename to bitcoin/src/consensus/mod.rs diff --git a/src/consensus/params.rs b/bitcoin/src/consensus/params.rs similarity index 100% rename from src/consensus/params.rs rename to bitcoin/src/consensus/params.rs diff --git a/src/error.rs b/bitcoin/src/error.rs similarity index 100% rename from src/error.rs rename to bitcoin/src/error.rs diff --git a/src/hash_types.rs b/bitcoin/src/hash_types.rs similarity index 100% rename from src/hash_types.rs rename to bitcoin/src/hash_types.rs diff --git a/src/internal_macros.rs b/bitcoin/src/internal_macros.rs similarity index 100% rename from src/internal_macros.rs rename to bitcoin/src/internal_macros.rs diff --git a/src/lib.rs b/bitcoin/src/lib.rs similarity index 100% rename from src/lib.rs rename to bitcoin/src/lib.rs diff --git a/src/network/address.rs b/bitcoin/src/network/address.rs similarity index 100% rename from src/network/address.rs rename to bitcoin/src/network/address.rs diff --git a/src/network/constants.rs b/bitcoin/src/network/constants.rs similarity index 100% rename from src/network/constants.rs rename to bitcoin/src/network/constants.rs diff --git a/src/network/message.rs b/bitcoin/src/network/message.rs similarity index 100% rename from src/network/message.rs rename to bitcoin/src/network/message.rs diff --git a/src/network/message_blockdata.rs b/bitcoin/src/network/message_blockdata.rs similarity index 100% rename from src/network/message_blockdata.rs rename to bitcoin/src/network/message_blockdata.rs diff --git a/src/network/message_bloom.rs b/bitcoin/src/network/message_bloom.rs similarity index 100% rename from src/network/message_bloom.rs rename to bitcoin/src/network/message_bloom.rs diff --git a/src/network/message_compact_blocks.rs b/bitcoin/src/network/message_compact_blocks.rs similarity index 100% rename from src/network/message_compact_blocks.rs rename to bitcoin/src/network/message_compact_blocks.rs diff --git a/src/network/message_filter.rs b/bitcoin/src/network/message_filter.rs similarity index 100% rename from src/network/message_filter.rs rename to bitcoin/src/network/message_filter.rs diff --git a/src/network/message_network.rs b/bitcoin/src/network/message_network.rs similarity index 100% rename from src/network/message_network.rs rename to bitcoin/src/network/message_network.rs diff --git a/src/network/mod.rs b/bitcoin/src/network/mod.rs similarity index 100% rename from src/network/mod.rs rename to bitcoin/src/network/mod.rs diff --git a/src/parse.rs b/bitcoin/src/parse.rs similarity index 100% rename from src/parse.rs rename to bitcoin/src/parse.rs diff --git a/src/policy.rs b/bitcoin/src/policy.rs similarity index 100% rename from src/policy.rs rename to bitcoin/src/policy.rs diff --git a/src/serde_utils.rs b/bitcoin/src/serde_utils.rs similarity index 100% rename from src/serde_utils.rs rename to bitcoin/src/serde_utils.rs diff --git a/src/test_macros.rs b/bitcoin/src/test_macros.rs similarity index 100% rename from src/test_macros.rs rename to bitcoin/src/test_macros.rs diff --git a/src/util/amount.rs b/bitcoin/src/util/amount.rs similarity index 100% rename from src/util/amount.rs rename to bitcoin/src/util/amount.rs diff --git a/src/util/base58.rs b/bitcoin/src/util/base58.rs similarity index 100% rename from src/util/base58.rs rename to bitcoin/src/util/base58.rs diff --git a/src/util/bip143.rs b/bitcoin/src/util/bip143.rs similarity index 100% rename from src/util/bip143.rs rename to bitcoin/src/util/bip143.rs diff --git a/src/util/bip152.rs b/bitcoin/src/util/bip152.rs similarity index 100% rename from src/util/bip152.rs rename to bitcoin/src/util/bip152.rs diff --git a/src/util/bip32.rs b/bitcoin/src/util/bip32.rs similarity index 100% rename from src/util/bip32.rs rename to bitcoin/src/util/bip32.rs diff --git a/src/util/ecdsa.rs b/bitcoin/src/util/ecdsa.rs similarity index 100% rename from src/util/ecdsa.rs rename to bitcoin/src/util/ecdsa.rs diff --git a/src/util/endian.rs b/bitcoin/src/util/endian.rs similarity index 100% rename from src/util/endian.rs rename to bitcoin/src/util/endian.rs diff --git a/src/util/hash.rs b/bitcoin/src/util/hash.rs similarity index 100% rename from src/util/hash.rs rename to bitcoin/src/util/hash.rs diff --git a/src/util/key.rs b/bitcoin/src/util/key.rs similarity index 100% rename from src/util/key.rs rename to bitcoin/src/util/key.rs diff --git a/src/util/merkleblock.rs b/bitcoin/src/util/merkleblock.rs similarity index 100% rename from src/util/merkleblock.rs rename to bitcoin/src/util/merkleblock.rs diff --git a/src/util/misc.rs b/bitcoin/src/util/misc.rs similarity index 100% rename from src/util/misc.rs rename to bitcoin/src/util/misc.rs diff --git a/src/util/mod.rs b/bitcoin/src/util/mod.rs similarity index 100% rename from src/util/mod.rs rename to bitcoin/src/util/mod.rs diff --git a/src/util/psbt/error.rs b/bitcoin/src/util/psbt/error.rs similarity index 100% rename from src/util/psbt/error.rs rename to bitcoin/src/util/psbt/error.rs diff --git a/src/util/psbt/macros.rs b/bitcoin/src/util/psbt/macros.rs similarity index 100% rename from src/util/psbt/macros.rs rename to bitcoin/src/util/psbt/macros.rs diff --git a/src/util/psbt/map/global.rs b/bitcoin/src/util/psbt/map/global.rs similarity index 100% rename from src/util/psbt/map/global.rs rename to bitcoin/src/util/psbt/map/global.rs diff --git a/src/util/psbt/map/input.rs b/bitcoin/src/util/psbt/map/input.rs similarity index 100% rename from src/util/psbt/map/input.rs rename to bitcoin/src/util/psbt/map/input.rs diff --git a/src/util/psbt/map/mod.rs b/bitcoin/src/util/psbt/map/mod.rs similarity index 100% rename from src/util/psbt/map/mod.rs rename to bitcoin/src/util/psbt/map/mod.rs diff --git a/src/util/psbt/map/output.rs b/bitcoin/src/util/psbt/map/output.rs similarity index 100% rename from src/util/psbt/map/output.rs rename to bitcoin/src/util/psbt/map/output.rs diff --git a/src/util/psbt/mod.rs b/bitcoin/src/util/psbt/mod.rs similarity index 100% rename from src/util/psbt/mod.rs rename to bitcoin/src/util/psbt/mod.rs diff --git a/src/util/psbt/raw.rs b/bitcoin/src/util/psbt/raw.rs similarity index 100% rename from src/util/psbt/raw.rs rename to bitcoin/src/util/psbt/raw.rs diff --git a/src/util/psbt/serialize.rs b/bitcoin/src/util/psbt/serialize.rs similarity index 100% rename from src/util/psbt/serialize.rs rename to bitcoin/src/util/psbt/serialize.rs diff --git a/src/util/schnorr.rs b/bitcoin/src/util/schnorr.rs similarity index 100% rename from src/util/schnorr.rs rename to bitcoin/src/util/schnorr.rs diff --git a/src/util/sighash.rs b/bitcoin/src/util/sighash.rs similarity index 100% rename from src/util/sighash.rs rename to bitcoin/src/util/sighash.rs diff --git a/src/util/taproot.rs b/bitcoin/src/util/taproot.rs similarity index 100% rename from src/util/taproot.rs rename to bitcoin/src/util/taproot.rs diff --git a/src/util/uint.rs b/bitcoin/src/util/uint.rs similarity index 100% rename from src/util/uint.rs rename to bitcoin/src/util/uint.rs diff --git a/test_data/bip341_tests.json b/bitcoin/test_data/bip341_tests.json similarity index 100% rename from test_data/bip341_tests.json rename to bitcoin/test_data/bip341_tests.json diff --git a/test_data/blockfilters.json b/bitcoin/test_data/blockfilters.json similarity index 100% rename from test_data/blockfilters.json rename to bitcoin/test_data/blockfilters.json diff --git a/test_data/legacy_sighash.json b/bitcoin/test_data/legacy_sighash.json similarity index 100% rename from test_data/legacy_sighash.json rename to bitcoin/test_data/legacy_sighash.json diff --git a/test_data/mainnet_block_000000000000000000000c835b2adcaedc20fdf6ee440009c249452c726dafae.raw b/bitcoin/test_data/mainnet_block_000000000000000000000c835b2adcaedc20fdf6ee440009c249452c726dafae.raw similarity index 100% rename from test_data/mainnet_block_000000000000000000000c835b2adcaedc20fdf6ee440009c249452c726dafae.raw rename to bitcoin/test_data/mainnet_block_000000000000000000000c835b2adcaedc20fdf6ee440009c249452c726dafae.raw diff --git a/test_data/psbt1.hex b/bitcoin/test_data/psbt1.hex similarity index 100% rename from test_data/psbt1.hex rename to bitcoin/test_data/psbt1.hex diff --git a/test_data/psbt2.hex b/bitcoin/test_data/psbt2.hex similarity index 100% rename from test_data/psbt2.hex rename to bitcoin/test_data/psbt2.hex diff --git a/test_data/psbt_combined.hex b/bitcoin/test_data/psbt_combined.hex similarity index 100% rename from test_data/psbt_combined.hex rename to bitcoin/test_data/psbt_combined.hex diff --git a/test_data/testnet_block_000000000000045e0b1660b6445b5e5c5ab63c9a4f956be7e1e69be04fa4497b.raw b/bitcoin/test_data/testnet_block_000000000000045e0b1660b6445b5e5c5ab63c9a4f956be7e1e69be04fa4497b.raw similarity index 100% rename from test_data/testnet_block_000000000000045e0b1660b6445b5e5c5ab63c9a4f956be7e1e69be04fa4497b.raw rename to bitcoin/test_data/testnet_block_000000000000045e0b1660b6445b5e5c5ab63c9a4f956be7e1e69be04fa4497b.raw diff --git a/contrib/test.sh b/contrib/test.sh index b46e8917..30483824 100755 --- a/contrib/test.sh +++ b/contrib/test.sh @@ -2,123 +2,14 @@ set -ex -FEATURES="base64 bitcoinconsensus serde rand secp-recovery" +CRATES="bitcoin" -if [ "$DO_COV" = true ] -then - export RUSTFLAGS="-C link-dead-code" -fi - -cargo --version -rustc --version - -# Work out if we are using a nightly toolchain. -NIGHTLY=false -if cargo --version | grep nightly; then - NIGHTLY=true -fi - -# We should not have any duplicate dependencies. This catches mistakes made upgrading dependencies -# in one crate and not in another (e.g. upgrade bitcoin_hashes in bitcoin but not in secp). -cargo update -p serde --precise 1.0.142 -cargo update -p serde_test --precise 1.0.142 -cargo update -p serde_derive --precise 1.0.142 -duplicate_dependencies=$(cargo tree --target=all --all-features --duplicates | wc -l) -if [ "$duplicate_dependencies" -ne 0 ]; then - echo "Dependency tree is broken, contains duplicates" - cargo tree --target=all --all-features --duplicates - exit 1 -fi - -if [ "$DO_LINT" = true ] -then - cargo clippy --all-features --all-targets -- -D warnings - cargo clippy --example bip32 -- -D warnings - cargo clippy --example handshake -- -D warnings - cargo clippy --example ecdsa-psbt --features=bitcoinconsensus -- -D warnings -fi - -echo "********* Testing std *************" -# Test without any features other than std first -cargo test --verbose --no-default-features --features="std" - -echo "********* Testing default *************" -# Then test with the default features -cargo test --verbose - -if [ "$DO_NO_STD" = true ] -then - echo "********* Testing no-std build *************" - # Build no_std, to make sure that cfg(test) doesn't hide any issues - cargo build --verbose --features="no-std" --no-default-features - - # Build std + no_std, to make sure they are not incompatible - cargo build --verbose --features="no-std" - - # Test no_std - cargo test --verbose --features="no-std" --no-default-features - - # Build all features - cargo build --verbose --features="no-std $FEATURES" --no-default-features - - # Build specific features - for feature in ${FEATURES} - do - cargo build --verbose --features="no-std $feature" - done - - cargo run --example bip32 7934c09359b234e076b9fa5a1abfd38e3dc2a9939745b7cc3c22a48d831d14bd - cargo run --no-default-features --features no-std --example bip32 7934c09359b234e076b9fa5a1abfd38e3dc2a9939745b7cc3c22a48d831d14bd -fi - -# Test each feature -for feature in ${FEATURES} +for crate in ${CRATES} do - echo "********* Testing $feature *************" - cargo test --verbose --features="$feature" + ( + cd "$crate" + ./contrib/test.sh + ) done -cargo run --example ecdsa-psbt --features=bitcoinconsensus - -# Build the docs if told to (this only works with the nightly toolchain) -if [ "$DO_DOCS" = true ]; then - RUSTDOCFLAGS="--cfg docsrs" cargo +nightly rustdoc --features="$FEATURES" -- -D rustdoc::broken-intra-doc-links -fi - -# Fuzz if told to -if [ "$DO_FUZZ" = true ] -then - ( - cd fuzz - cargo test --verbose - ./travis-fuzz.sh - ) -fi - -# Bench if told to, only works with non-stable toolchain (nightly, beta). -if [ "$DO_BENCH" = true ] -then - if [ "$NIGHTLY" = false ] - then - if [ -n "$RUSTUP_TOOLCHAIN" ] - then - echo "RUSTUP_TOOLCHAIN is set to a non-nightly toolchain but DO_BENCH requires a nightly toolchain" - else - echo "DO_BENCH requires a nightly toolchain" - fi - exit 1 - fi - RUSTFLAGS='--cfg=bench' cargo bench -fi - -# Use as dependency if told to -if [ "$AS_DEPENDENCY" = true ] -then - cargo new dep_test - cd dep_test - echo 'bitcoin = { path = "..", features = ["serde"] }' >> Cargo.toml - cargo update -p serde --precise 1.0.142 - cargo update -p serde_derive --precise 1.0.142 - - cargo test --verbose -fi +exit 0 diff --git a/embedded/Cargo.toml b/embedded/Cargo.toml index f8c870b3..ef6d962e 100644 --- a/embedded/Cargo.toml +++ b/embedded/Cargo.toml @@ -11,7 +11,7 @@ cortex-m-rt = "0.6.10" cortex-m-semihosting = "0.3.3" panic-halt = "0.2.0" alloc-cortex-m = "0.4.1" -bitcoin = { path="../", default-features = false, features = ["no-std", "secp-lowmemory"] } +bitcoin = { path="../bitcoin", default-features = false, features = ["no-std", "secp-lowmemory"] } [[bin]] name = "embedded" diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 927a3b37..555ec383 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -14,7 +14,7 @@ honggfuzz_fuzz = ["honggfuzz"] [dependencies] honggfuzz = { version = "0.5", optional = true, default-features = false } afl = { version = "0.4", optional = true } -bitcoin = { path = ".." } +bitcoin = { path = "../bitcoin" } # Prevent this from interfering with workspaces [workspace] diff --git a/rustfmt.toml b/rustfmt.toml index 68b410f6..a80a8e64 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,9 +1,9 @@ # Eventually this shoud be: ignore = [] ignore = [ - "src/blockdata", - "src/consensus", - "src/network", - "src/util", + "bitcoin/src/blockdata", + "bitcoin/src/consensus", + "bitcoin/src/network", + "bitcoin/src/util", ] hard_tabs = false