Move test_data/* tests/data
In preparation for adding integration tests in the standard Rust `tests/` directroy; move the contents of `test_data` to `tests/data`.
This commit is contained in:
parent
bd80ecd92d
commit
72935a0f6e
|
@ -9,7 +9,7 @@ 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/"]
|
||||
exclude = ["tests/"]
|
||||
edition = "2018"
|
||||
|
||||
# Please don't forget to add relevant features to docs.rs below
|
||||
|
|
|
@ -564,7 +564,7 @@ mod test {
|
|||
#[test]
|
||||
fn test_blockfilters() {
|
||||
// test vectors from: https://github.com/jimpo/bitcoin/blob/c7efb652f3543b001b4dd22186a354605b14f47e/src/test/data/blockfilters.json
|
||||
let data = include_str!("../test_data/blockfilters.json");
|
||||
let data = include_str!("../tests/data/blockfilters.json");
|
||||
|
||||
let testdata = serde_json::from_str::<Value>(data).unwrap().as_array().unwrap().clone();
|
||||
for t in testdata.iter().skip(1) {
|
||||
|
|
|
@ -460,7 +460,7 @@ mod tests {
|
|||
// Check testnet block 000000000000045e0b1660b6445b5e5c5ab63c9a4f956be7e1e69be04fa4497b
|
||||
#[test]
|
||||
fn segwit_block_test() {
|
||||
let segwit_block = include_bytes!("../../test_data/testnet_block_000000000000045e0b1660b6445b5e5c5ab63c9a4f956be7e1e69be04fa4497b.raw").to_vec();
|
||||
let segwit_block = include_bytes!("../../tests/data/testnet_block_000000000000045e0b1660b6445b5e5c5ab63c9a4f956be7e1e69be04fa4497b.raw").to_vec();
|
||||
|
||||
let decode: Result<Block, _> = deserialize(&segwit_block);
|
||||
|
||||
|
@ -564,7 +564,7 @@ mod benches {
|
|||
|
||||
#[bench]
|
||||
pub fn bench_stream_reader(bh: &mut Bencher) {
|
||||
let big_block = include_bytes!("../../test_data/mainnet_block_000000000000000000000c835b2adcaedc20fdf6ee440009c249452c726dafae.raw");
|
||||
let big_block = include_bytes!("../../tests/data/mainnet_block_000000000000000000000c835b2adcaedc20fdf6ee440009c249452c726dafae.raw");
|
||||
assert_eq!(big_block.len(), 1_381_836);
|
||||
let big_block = black_box(big_block);
|
||||
|
||||
|
@ -577,7 +577,7 @@ mod benches {
|
|||
|
||||
#[bench]
|
||||
pub fn bench_block_serialize(bh: &mut Bencher) {
|
||||
let raw_block = include_bytes!("../../test_data/mainnet_block_000000000000000000000c835b2adcaedc20fdf6ee440009c249452c726dafae.raw");
|
||||
let raw_block = include_bytes!("../../tests/data/mainnet_block_000000000000000000000c835b2adcaedc20fdf6ee440009c249452c726dafae.raw");
|
||||
|
||||
let block: Block = deserialize(&raw_block[..]).unwrap();
|
||||
|
||||
|
@ -592,7 +592,7 @@ mod benches {
|
|||
|
||||
#[bench]
|
||||
pub fn bench_block_serialize_logic(bh: &mut Bencher) {
|
||||
let raw_block = include_bytes!("../../test_data/mainnet_block_000000000000000000000c835b2adcaedc20fdf6ee440009c249452c726dafae.raw");
|
||||
let raw_block = include_bytes!("../../tests/data/mainnet_block_000000000000000000000c835b2adcaedc20fdf6ee440009c249452c726dafae.raw");
|
||||
|
||||
let block: Block = deserialize(&raw_block[..]).unwrap();
|
||||
|
||||
|
@ -604,7 +604,7 @@ mod benches {
|
|||
|
||||
#[bench]
|
||||
pub fn bench_block_deserialize(bh: &mut Bencher) {
|
||||
let raw_block = include_bytes!("../../test_data/mainnet_block_000000000000000000000c835b2adcaedc20fdf6ee440009c249452c726dafae.raw");
|
||||
let raw_block = include_bytes!("../../tests/data/mainnet_block_000000000000000000000c835b2adcaedc20fdf6ee440009c249452c726dafae.raw");
|
||||
|
||||
bh.iter(|| {
|
||||
let block: Block = deserialize(&raw_block[..]).unwrap();
|
||||
|
|
|
@ -497,7 +497,7 @@ mod test {
|
|||
// TODO: Impl Rand traits here to easily generate random values.
|
||||
let version_msg: VersionMessage = deserialize(&Vec::from_hex("721101000100000000000000e6e0845300000000010000000000000000000000000000000000ffff0000000000000100000000000000fd87d87eeb4364f22cf54dca59412db7208d47d920cffce83ee8102f5361746f7368693a302e392e39392f2c9f040001").unwrap()).unwrap();
|
||||
let tx: Transaction = deserialize(&Vec::from_hex("0100000001a15d57094aa7a21a28cb20b59aab8fc7d1149a3bdbcddba9c622e4f5f6a99ece010000006c493046022100f93bb0e7d8db7bd46e40132d1f8242026e045f03a0efe71bbb8e3f475e970d790221009337cd7f1f929f00cc6ff01f03729b069a7c21b59b1736ddfee5db5946c5da8c0121033b9b137ee87d5a812d6f506efdd37f0affa7ffc310711c06c7f3e097c9447c52ffffffff0100e1f505000000001976a9140389035a9225b3839e2bbf32d826a1e222031fd888ac00000000").unwrap()).unwrap();
|
||||
let block: Block = deserialize(&include_bytes!("../../test_data/testnet_block_000000000000045e0b1660b6445b5e5c5ab63c9a4f956be7e1e69be04fa4497b.raw")[..]).unwrap();
|
||||
let block: Block = deserialize(&include_bytes!("../../tests/data/testnet_block_000000000000045e0b1660b6445b5e5c5ab63c9a4f956be7e1e69be04fa4497b.raw")[..]).unwrap();
|
||||
let header: BlockHeader = deserialize(&Vec::from_hex("010000004ddccd549d28f385ab457e98d1b11ce80bfea2c5ab93015ade4973e400000000bf4473e53794beae34e64fccc471dace6ae544180816f89591894e0f417a914cd74d6e49ffff001d323b3a7b").unwrap()).unwrap();
|
||||
let script: Script = deserialize(&Vec::from_hex("1976a91431a420903c05a0a7de2de40c9f02ebedbacdc17288ac").unwrap()).unwrap();
|
||||
let merkle_block: MerkleBlock = deserialize(&Vec::from_hex("0100000079cda856b143d9db2c1caff01d1aecc8630d30625d10e8b4b8b0000000000000b50cc069d6a3e33e3ff84a5c41d9d3febe7c770fdcc96b2c3ff60abe184f196367291b4d4c86041b8fa45d630100000001b50cc069d6a3e33e3ff84a5c41d9d3febe7c770fdcc96b2c3ff60abe184f19630101").unwrap()).unwrap();
|
||||
|
|
|
@ -1127,7 +1127,7 @@ mod tests {
|
|||
// These test vectors were stolen from libbtc, which is Copyright 2014 Jonas Schnelli MIT
|
||||
// They were transformed by replacing {...} with run_test_sighash(...), then the ones containing
|
||||
// OP_CODESEPARATOR in their pubkeys were removed
|
||||
let data = include_str!("../test_data/legacy_sighash.json");
|
||||
let data = include_str!("../tests/data/legacy_sighash.json");
|
||||
|
||||
let testdata = serde_json::from_str::<Value>(data).unwrap().as_array().unwrap().clone();
|
||||
for t in testdata.iter().skip(1) {
|
||||
|
@ -1479,7 +1479,7 @@ mod tests {
|
|||
}
|
||||
|
||||
fn bip_341_read_json() -> serde_json::Value {
|
||||
let json_str = include_str!("../test_data/bip341_tests.json");
|
||||
let json_str = include_str!("../tests/data/bip341_tests.json");
|
||||
serde_json::from_str(json_str).expect("JSON was not well-formatted")
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ mod tests {
|
|||
#[test]
|
||||
fn both_merkle_root_functions_return_the_same_result() {
|
||||
// testnet block 000000000000045e0b1660b6445b5e5c5ab63c9a4f956be7e1e69be04fa4497b
|
||||
let segwit_block = include_bytes!("../../test_data/testnet_block_000000000000045e0b1660b6445b5e5c5ab63c9a4f956be7e1e69be04fa4497b.raw");
|
||||
let segwit_block = include_bytes!("../../tests/data/testnet_block_000000000000045e0b1660b6445b5e5c5ab63c9a4f956be7e1e69be04fa4497b.raw");
|
||||
let block: Block = deserialize(&segwit_block[..]).expect("Failed to deserialize block");
|
||||
assert!(block.check_merkle_root()); // Sanity check.
|
||||
|
||||
|
|
|
@ -1664,9 +1664,9 @@ mod tests {
|
|||
// PSBTs taken from BIP 174 test vectors.
|
||||
#[test]
|
||||
fn combine_psbts() {
|
||||
let mut psbt1 = hex_psbt!(include_str!("../../../test_data/psbt1.hex")).unwrap();
|
||||
let psbt2 = hex_psbt!(include_str!("../../../test_data/psbt2.hex")).unwrap();
|
||||
let psbt_combined = hex_psbt!(include_str!("../../../test_data/psbt2.hex")).unwrap();
|
||||
let mut psbt1 = hex_psbt!(include_str!("../../../tests/data/psbt1.hex")).unwrap();
|
||||
let psbt2 = hex_psbt!(include_str!("../../../tests/data/psbt2.hex")).unwrap();
|
||||
let psbt_combined = hex_psbt!(include_str!("../../../tests/data/psbt2.hex")).unwrap();
|
||||
|
||||
psbt1.combine(psbt2).expect("psbt combine to succeed");
|
||||
assert_eq!(psbt1, psbt_combined);
|
||||
|
@ -1674,8 +1674,8 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn combine_psbts_commutative() {
|
||||
let mut psbt1 = hex_psbt!(include_str!("../../../test_data/psbt1.hex")).unwrap();
|
||||
let mut psbt2 = hex_psbt!(include_str!("../../../test_data/psbt2.hex")).unwrap();
|
||||
let mut psbt1 = hex_psbt!(include_str!("../../../tests/data/psbt1.hex")).unwrap();
|
||||
let mut psbt2 = hex_psbt!(include_str!("../../../tests/data/psbt2.hex")).unwrap();
|
||||
|
||||
let psbt1_clone = psbt1.clone();
|
||||
let psbt2_clone = psbt2.clone();
|
||||
|
|
|
@ -1438,7 +1438,7 @@ mod test {
|
|||
}
|
||||
|
||||
fn bip_341_read_json() -> serde_json::Value {
|
||||
let json_str = include_str!("../../test_data/bip341_tests.json");
|
||||
let json_str = include_str!("../../tests/data/bip341_tests.json");
|
||||
serde_json::from_str(json_str).expect("JSON was not well-formatted")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue