mirror of
https://github.com/romanz/electrs.git
synced 2024-11-19 01:43:29 +01:00
Add test for finding outputs
This commit is contained in:
parent
5c80c06d2b
commit
51fd5a7bb7
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -81,6 +81,12 @@ version = "0.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "73290177011694f38ec25e165d0387ab7ea749a4b81cd4c80dae5988229f7a57"
|
checksum = "73290177011694f38ec25e165d0387ab7ea749a4b81cd4c80dae5988229f7a57"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitcoin-test-data"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0c188654f9dce3bc6ce1bfa9c49777ad514bcad37e421b5f53e9d0ee10603f34"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitcoin_hashes"
|
name = "bitcoin_hashes"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
@ -348,6 +354,7 @@ version = "0.10.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bitcoin",
|
"bitcoin",
|
||||||
|
"bitcoin-test-data",
|
||||||
"bitcoin_slices",
|
"bitcoin_slices",
|
||||||
"bitcoincore-rpc",
|
"bitcoincore-rpc",
|
||||||
"configure_me",
|
"configure_me",
|
||||||
|
@ -51,5 +51,6 @@ features = ["zstd", "snappy"]
|
|||||||
configure_me_codegen = { version = "0.4.4", default-features = false }
|
configure_me_codegen = { version = "0.4.4", default-features = false }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
bitcoin-test-data = "0.2.0"
|
||||||
hex_lit = "0.1.1"
|
hex_lit = "0.1.1"
|
||||||
tempfile = "3.5"
|
tempfile = "3.5"
|
||||||
|
@ -572,8 +572,13 @@ fn filter_block_txs_inputs(
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
|
use crate::types::ScriptHash;
|
||||||
|
|
||||||
use super::HistoryEntry;
|
use super::HistoryEntry;
|
||||||
use bitcoin::Amount;
|
use bitcoin::{Address, Amount};
|
||||||
|
use bitcoin_test_data::blocks::mainnet_702861;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -598,4 +603,25 @@ mod tests {
|
|||||||
json!({"tx_hash": "5b75086dafeede555fc8f9a810d8b10df57c46f9f176ccc3dd8d2fa20edd685b", "height": 0, "fee": 123})
|
json!({"tx_hash": "5b75086dafeede555fc8f9a810d8b10df57c46f9f176ccc3dd8d2fa20edd685b", "height": 0, "fee": 123})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_find_outputs() {
|
||||||
|
let block = mainnet_702861().to_vec();
|
||||||
|
|
||||||
|
let addr = Address::from_str("1A9MXXG26vZVySrNNytQK1N8bX42ZuJ6Ax")
|
||||||
|
.unwrap()
|
||||||
|
.assume_checked();
|
||||||
|
let scripthash = ScriptHash::new(&addr.script_pubkey());
|
||||||
|
|
||||||
|
let result = super::filter_block_txs_outputs(block, scripthash)
|
||||||
|
.next()
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
result.txid.to_string(),
|
||||||
|
"7bcdcb44422da5a99daad47d6ba1c3d6f2e48f961a75e42c4fa75029d4b0ef49"
|
||||||
|
);
|
||||||
|
assert_eq!(result.pos, 8);
|
||||||
|
assert_eq!(result.result[0].index, 0);
|
||||||
|
assert_eq!(result.result[0].value.to_sat(), 709503);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user