Remove test_ prefix from unit tests
There is a loose convention in Rust to not use `test_` prefix. The reason being that `cargo test` outputs 'test <test name>' using the prefix makes the output stutter. This patch smells a bit like code-churn but having the prefix in some places and not others is confusing to new contributors and is leading me to explain this many times now. Lets just fix it. Remove the prefix unless doing so breaks the code.
This commit is contained in:
parent
21d435cf84
commit
85e04315d5
|
@ -258,7 +258,7 @@ mod tests {
|
|||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_base58_encode() {
|
||||
fn base58_encode() {
|
||||
// Basics
|
||||
assert_eq!(&encode(&[0][..]), "1");
|
||||
assert_eq!(&encode(&[1][..]), "2");
|
||||
|
@ -287,7 +287,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_base58_decode() {
|
||||
fn base58_decode() {
|
||||
// Basics
|
||||
assert_eq!(decode("1").ok(), Some(vec![0u8]));
|
||||
assert_eq!(decode("2").ok(), Some(vec![1u8]));
|
||||
|
@ -308,7 +308,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_base58_roundtrip() {
|
||||
fn base58_roundtrip() {
|
||||
let s = "xprv9wTYmMFdV23N2TdNG573QoEsfRrWKQgWeibmLntzniatZvR9BmLnvSxqu53Kw1UmYPxLgboyZQaXwTCg8MSY3H2EU4pWcQDnRnrVA1xe8fs";
|
||||
let v: Vec<u8> = decode_check(s).unwrap();
|
||||
assert_eq!(encode_check(&v[..]), s);
|
||||
|
|
|
@ -941,7 +941,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_p2pkh_address_58() {
|
||||
fn p2pkh_address_58() {
|
||||
let hash = "162c5ea71c0b23f5b9022ef047c4a86470a5b070".parse::<PubkeyHash>().unwrap();
|
||||
let addr = Address::p2pkh(hash, NetworkKind::Main);
|
||||
|
||||
|
@ -955,7 +955,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_p2pkh_from_key() {
|
||||
fn p2pkh_from_key() {
|
||||
let key = "048d5141948c1702e8c95f438815794b87f706a8d4cd2bffad1dc1570971032c9b6042a0431ded2478b5c9cf2d81c124a5e57347a3c63ef0e7716cf54d613ba183".parse::<PublicKey>().unwrap();
|
||||
let addr = Address::p2pkh(key, NetworkKind::Main);
|
||||
assert_eq!(&addr.to_string(), "1QJVDzdqb1VpbDK7uDeyVXy9mR27CJiyhY");
|
||||
|
@ -970,7 +970,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_p2sh_address_58() {
|
||||
fn p2sh_address_58() {
|
||||
let hash = "162c5ea71c0b23f5b9022ef047c4a86470a5b070".parse::<ScriptHash>().unwrap();
|
||||
let addr = Address::p2sh_from_hash(hash, NetworkKind::Main);
|
||||
|
||||
|
@ -984,7 +984,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_p2sh_parse() {
|
||||
fn p2sh_parse() {
|
||||
let script = ScriptBuf::from_hex("552103a765fc35b3f210b95223846b36ef62a4e53e34e2925270c2c7906b92c9f718eb2103c327511374246759ec8d0b89fa6c6b23b33e11f92c5bc155409d86de0c79180121038cae7406af1f12f4786d820a1466eec7bc5785a1b5e4a387eca6d797753ef6db2103252bfb9dcaab0cd00353f2ac328954d791270203d66c2be8b430f115f451b8a12103e79412d42372c55dd336f2eb6eb639ef9d74a22041ba79382c74da2338fe58ad21035049459a4ebc00e876a9eef02e72a3e70202d3d1f591fc0dd542f93f642021f82102016f682920d9723c61b27f562eb530c926c00106004798b6471e8c52c60ee02057ae").unwrap();
|
||||
let addr = Address::p2sh(&script, NetworkKind::Test).unwrap();
|
||||
assert_eq!(&addr.to_string(), "2N3zXjbwdTcPsJiy8sUK9FhWJhqQCxA8Jjr");
|
||||
|
@ -993,7 +993,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_p2sh_parse_for_large_script() {
|
||||
fn p2sh_parse_for_large_script() {
|
||||
let script = ScriptBuf::from_hex("552103a765fc35b3f210b95223846b36ef62a4e53e34e2925270c2c7906b92c9f718eb2103c327511374246759ec8d0b89fa6c6b23b33e11f92c5bc155409d86de0c79180121038cae7406af1f12f4786d820a1466eec7bc5785a1b5e4a387eca6d797753ef6db2103252bfb9dcaab0cd00353f2ac328954d791270203d66c2be8b430f115f451b8a12103e79412d42372c55dd336f2eb6eb639ef9d74a22041ba79382c74da2338fe58ad21035049459a4ebc00e876a9eef02e72a3e70202d3d1f591fc0dd542f93f642021f82102016f682920d9723c61b27f562eb530c926c00106004798b6471e8c52c60ee02057ae12123122313123123ac1231231231231313123131231231231313212313213123123552103a765fc35b3f210b95223846b36ef62a4e53e34e2925270c2c7906b92c9f718eb2103c327511374246759ec8d0b89fa6c6b23b33e11f92c5bc155409d86de0c79180121038cae7406af1f12f4786d820a1466eec7bc5785a1b5e4a387eca6d797753ef6db2103252bfb9dcaab0cd00353f2ac328954d791270203d66c2be8b430f115f451b8a12103e79412d42372c55dd336f2eb6eb639ef9d74a22041ba79382c74da2338fe58ad21035049459a4ebc00e876a9eef02e72a3e70202d3d1f591fc0dd542f93f642021f82102016f682920d9723c61b27f562eb530c926c00106004798b6471e8c52c60ee02057ae12123122313123123ac1231231231231313123131231231231313212313213123123552103a765fc35b3f210b95223846b36ef62a4e53e34e2925270c2c7906b92c9f718eb2103c327511374246759ec8d0b89fa6c6b23b33e11f92c5bc155409d86de0c79180121038cae7406af1f12f4786d820a1466eec7bc5785a1b5e4a387eca6d797753ef6db2103252bfb9dcaab0cd00353f2ac328954d791270203d66c2be8b430f115f451b8a12103e79412d42372c55dd336f2eb6eb639ef9d74a22041ba79382c74da2338fe58ad21035049459a4ebc00e876a9eef02e72a3e70202d3d1f591fc0dd542f93f642021f82102016f682920d9723c61b27f562eb530c926c00106004798b6471e8c52c60ee02057ae12123122313123123ac1231231231231313123131231231231313212313213123123").unwrap();
|
||||
assert_eq!(
|
||||
Address::p2sh(&script, NetworkKind::Test),
|
||||
|
@ -1002,7 +1002,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_p2wpkh() {
|
||||
fn p2wpkh() {
|
||||
// stolen from Bitcoin transaction: b3c8c2b6cfc335abbcb2c7823a8453f55d64b2b5125a9a61e8737230cdb8ce20
|
||||
let key = "033bc8c83c52df5712229a2f72206d90192366c36428cb0c12b6af98324d97bfbc"
|
||||
.parse::<CompressedPublicKey>()
|
||||
|
@ -1014,7 +1014,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_p2wsh() {
|
||||
fn p2wsh() {
|
||||
// stolen from Bitcoin transaction 5df912fda4becb1c29e928bec8d64d93e9ba8efa9b5b405bd683c86fd2c65667
|
||||
let script = ScriptBuf::from_hex("52210375e00eb72e29da82b89367947f29ef34afb75e8654f6ea368e0acdfd92976b7c2103a1b26313f430c4b15bb1fdce663207659d8cac749a0e53d70eff01874496feff2103c96d495bfdd5ba4145e3e046fee45e84a8a48ad05bd8dbb395c011a32cf9f88053ae").unwrap();
|
||||
let addr = Address::p2wsh(&script, KnownHrp::Mainnet).expect("script is valid");
|
||||
|
@ -1027,7 +1027,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_p2shwpkh() {
|
||||
fn p2shwpkh() {
|
||||
// stolen from Bitcoin transaction: ad3fd9c6b52e752ba21425435ff3dd361d6ac271531fc1d2144843a9f550ad01
|
||||
let key = "026c468be64d22761c30cd2f12cbc7de255d592d7904b1bab07236897cc4c2e766"
|
||||
.parse::<CompressedPublicKey>()
|
||||
|
@ -1039,7 +1039,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_p2shwsh() {
|
||||
fn p2shwsh() {
|
||||
// stolen from Bitcoin transaction f9ee2be4df05041d0e0a35d7caa3157495ca4f93b233234c9967b6901dacf7a9
|
||||
let script = ScriptBuf::from_hex("522103e5529d8eaa3d559903adb2e881eb06c86ac2574ffa503c45f4e942e2a693b33e2102e5f10fcdcdbab211e0af6a481f5532536ec61a5fdbf7183770cf8680fe729d8152ae").unwrap();
|
||||
let addr = Address::p2shwsh(&script, NetworkKind::Main).expect("script is valid");
|
||||
|
@ -1049,7 +1049,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_non_existent_segwit_version() {
|
||||
fn non_existent_segwit_version() {
|
||||
// 40-byte program
|
||||
let program = hex!(
|
||||
"654f6ea368e0acdfd92976b7c2103a1b26313f430654f6ea368e0acdfd92976b7c2103a1b26313f4"
|
||||
|
@ -1061,7 +1061,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_address_debug() {
|
||||
fn address_debug() {
|
||||
// This is not really testing output of Debug but the ability and proper functioning
|
||||
// of Debug derivation on structs generic in NetworkValidation.
|
||||
#[derive(Debug)]
|
||||
|
@ -1085,7 +1085,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_address_type() {
|
||||
fn address_type() {
|
||||
let addresses = [
|
||||
("1QJVDzdqb1VpbDK7uDeyVXy9mR27CJiyhY", Some(AddressType::P2pkh)),
|
||||
("33iFwdLuRpW1uK1RTRqsoi8rR4NpDzk66k", Some(AddressType::P2sh)),
|
||||
|
@ -1116,7 +1116,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
#[cfg(feature = "serde")]
|
||||
fn test_json_serialize() {
|
||||
fn json_serialize() {
|
||||
use serde_json;
|
||||
|
||||
let addr =
|
||||
|
@ -1198,7 +1198,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_qr_string() {
|
||||
fn qr_string() {
|
||||
for el in
|
||||
["132F25rTsvBdp9JzLLBHP5mvGY66i1xdiM", "33iFwdLuRpW1uK1RTRqsoi8rR4NpDzk66k"].iter()
|
||||
{
|
||||
|
@ -1238,7 +1238,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_related_to_pubkey_p2wpkh() {
|
||||
fn is_related_to_pubkey_p2wpkh() {
|
||||
let address_string = "bc1qhvd6suvqzjcu9pxjhrwhtrlj85ny3n2mqql5w4";
|
||||
let address = address_string
|
||||
.parse::<Address<_>>()
|
||||
|
@ -1259,7 +1259,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_related_to_pubkey_p2shwpkh() {
|
||||
fn is_related_to_pubkey_p2shwpkh() {
|
||||
let address_string = "3EZQk4F8GURH5sqVMLTFisD17yNeKa7Dfs";
|
||||
let address = address_string
|
||||
.parse::<Address<_>>()
|
||||
|
@ -1280,7 +1280,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_related_to_pubkey_p2pkh() {
|
||||
fn is_related_to_pubkey_p2pkh() {
|
||||
let address_string = "1J4LVanjHMu3JkXbVrahNuQCTGCRRgfWWx";
|
||||
let address = address_string
|
||||
.parse::<Address<_>>()
|
||||
|
@ -1301,7 +1301,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_related_to_pubkey_p2pkh_uncompressed_key() {
|
||||
fn is_related_to_pubkey_p2pkh_uncompressed_key() {
|
||||
let address_string = "msvS7KzhReCDpQEJaV2hmGNvuQqVUDuC6p";
|
||||
let address = address_string
|
||||
.parse::<Address<_>>()
|
||||
|
@ -1322,7 +1322,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_related_to_pubkey_p2tr() {
|
||||
fn is_related_to_pubkey_p2tr() {
|
||||
let pubkey_string = "0347ff3dacd07a1f43805ec6808e801505a6e18245178609972a68afbc2777ff2b";
|
||||
let pubkey = pubkey_string.parse::<PublicKey>().expect("pubkey");
|
||||
let xonly_pubkey = XOnlyPublicKey::from(pubkey.inner);
|
||||
|
@ -1348,7 +1348,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_is_related_to_xonly_pubkey() {
|
||||
fn is_related_to_xonly_pubkey() {
|
||||
let pubkey_string = "0347ff3dacd07a1f43805ec6808e801505a6e18245178609972a68afbc2777ff2b";
|
||||
let pubkey = pubkey_string.parse::<PublicKey>().expect("pubkey");
|
||||
let xonly_pubkey = XOnlyPublicKey::from(pubkey.inner);
|
||||
|
@ -1369,7 +1369,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_fail_address_from_script() {
|
||||
fn fail_address_from_script() {
|
||||
use crate::witness_program;
|
||||
|
||||
let bad_p2wpkh = ScriptBuf::from_hex("0014dbc5b0a8f9d4353b4b54c3db48846bb15abfec").unwrap();
|
||||
|
@ -1403,7 +1403,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_matches_script_pubkey() {
|
||||
fn matches_script_pubkey() {
|
||||
let addresses = [
|
||||
"1QJVDzdqb1VpbDK7uDeyVXy9mR27CJiyhY",
|
||||
"1J4LVanjHMu3JkXbVrahNuQCTGCRRgfWWx",
|
||||
|
|
|
@ -443,7 +443,7 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_header_and_short_ids_from_block() {
|
||||
fn header_and_short_ids_from_block() {
|
||||
let block = dummy_block();
|
||||
|
||||
let compact = HeaderAndShortIds::from_block(&block, 42, 2, &[]).unwrap();
|
||||
|
@ -463,7 +463,7 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_compact_block_vector() {
|
||||
fn compact_block_vector() {
|
||||
// Tested with Elements implementation of compact blocks.
|
||||
let raw_block = Vec::<u8>::from_hex("000000206c750a364035aefd5f81508a08769975116d9195312ee4520dceac39e1fdc62c4dc67473b8e354358c1e610afeaff7410858bd45df43e2940f8a62bd3d5e3ac943c2975cffff7f200000000002020000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff04016b0101ffffffff020006062a0100000001510000000000000000266a24aa21a9ed4a3d9f3343dafcc0d6f6d4310f2ee5ce273ed34edca6c75db3a73e7f368734200120000000000000000000000000000000000000000000000000000000000000000000000000020000000001021fc20ba2bd745507b8e00679e3b362558f9457db374ca28ffa5243f4c23a4d5f00000000171600147c9dea14ffbcaec4b575e03f05ceb7a81cd3fcbffdffffff915d689be87b43337f42e26033df59807b768223368f189a023d0242d837768900000000171600147c9dea14ffbcaec4b575e03f05ceb7a81cd3fcbffdffffff0200cdf5050000000017a9146803c72d9154a6a20f404bed6d3dcee07986235a8700e1f5050000000017a9144e6a4c7cb5b5562904843bdf816342f4db9f5797870247304402205e9bf6e70eb0e4b495bf483fd8e6e02da64900f290ef8aaa64bb32600d973c450220670896f5d0e5f33473e5f399ab680cc1d25c2d2afd15abd722f04978f28be887012103e4e4d9312b2261af508b367d8ba9be4f01b61d6d6e78bec499845b4f410bcf2702473044022045ac80596a6ac9c8c572f94708709adaf106677221122e08daf8b9741a04f66a022003ccd52a3b78f8fd08058fc04fc0cffa5f4c196c84eae9e37e2a85babe731b57012103e4e4d9312b2261af508b367d8ba9be4f01b61d6d6e78bec499845b4f410bcf276a000000").unwrap();
|
||||
let raw_compact = Vec::<u8>::from_hex("000000206c750a364035aefd5f81508a08769975116d9195312ee4520dceac39e1fdc62c4dc67473b8e354358c1e610afeaff7410858bd45df43e2940f8a62bd3d5e3ac943c2975cffff7f2000000000a4df3c3744da89fa010a6979e971450100020000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff04016b0101ffffffff020006062a0100000001510000000000000000266a24aa21a9ed4a3d9f3343dafcc0d6f6d4310f2ee5ce273ed34edca6c75db3a73e7f368734200120000000000000000000000000000000000000000000000000000000000000000000000000").unwrap();
|
||||
|
@ -478,7 +478,7 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_getblocktx_differential_encoding_de_and_serialization() {
|
||||
fn getblocktx_differential_encoding_de_and_serialization() {
|
||||
let testcases = vec![
|
||||
// differentially encoded VarInts, indicies
|
||||
(vec![4, 0, 5, 1, 10], vec![0, 6, 8, 19]),
|
||||
|
@ -523,7 +523,7 @@ mod test {
|
|||
#[test]
|
||||
#[cfg(debug_assertions)]
|
||||
#[should_panic] // 'attempt to add with overflow' in consensus_encode()
|
||||
fn test_getblocktx_panic_when_encoding_u64_max() {
|
||||
fn getblocktx_panic_when_encoding_u64_max() {
|
||||
serialize(&BlockTransactionsRequest {
|
||||
block_hash: BlockHash::from_byte_array([0; 32]),
|
||||
indexes: vec![u64::MAX],
|
||||
|
|
|
@ -582,7 +582,7 @@ mod test {
|
|||
use crate::ScriptBuf;
|
||||
|
||||
#[test]
|
||||
fn test_blockfilters() {
|
||||
fn blockfilters() {
|
||||
// test vectors from: https://github.com/jimpo/bitcoin/blob/c7efb652f3543b001b4dd22186a354605b14f47e/src/test/data/blockfilters.json
|
||||
let data = include_str!("../tests/data/blockfilters.json");
|
||||
|
||||
|
@ -649,7 +649,7 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_filter() {
|
||||
fn filter() {
|
||||
let mut patterns = BTreeSet::new();
|
||||
|
||||
patterns.insert(hex!("000000"));
|
||||
|
@ -718,7 +718,7 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_bit_stream() {
|
||||
fn bit_stream() {
|
||||
let mut out = Vec::new();
|
||||
{
|
||||
let mut writer = BitStreamWriter::new(&mut out);
|
||||
|
|
|
@ -974,7 +974,7 @@ mod tests {
|
|||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_parse_derivation_path() {
|
||||
fn parse_derivation_path() {
|
||||
assert_eq!("n/0'/0".parse::<DerivationPath>(), Err(Error::InvalidChildNumberFormat));
|
||||
assert_eq!("4/m/5".parse::<DerivationPath>(), Err(Error::InvalidChildNumberFormat));
|
||||
assert_eq!("//3/0'".parse::<DerivationPath>(), Err(Error::InvalidChildNumberFormat));
|
||||
|
@ -1036,7 +1036,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_derivation_path_conversion_index() {
|
||||
fn derivation_path_conversion_index() {
|
||||
let path = "0h/1/2'".parse::<DerivationPath>().unwrap();
|
||||
let numbers: Vec<ChildNumber> = path.clone().into();
|
||||
let path2: DerivationPath = numbers.into();
|
||||
|
@ -1096,7 +1096,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_increment() {
|
||||
fn increment() {
|
||||
let idx = 9345497; // randomly generated, I promise
|
||||
let cn = ChildNumber::from_normal_idx(idx).unwrap();
|
||||
assert_eq!(cn.increment().ok(), Some(ChildNumber::from_normal_idx(idx + 1).unwrap()));
|
||||
|
@ -1139,7 +1139,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_vector_1() {
|
||||
fn vector_1() {
|
||||
let secp = Secp256k1::new();
|
||||
let seed = hex!("000102030405060708090a0b0c0d0e0f");
|
||||
|
||||
|
@ -1175,7 +1175,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_vector_2() {
|
||||
fn vector_2() {
|
||||
let secp = Secp256k1::new();
|
||||
let seed = hex!("fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542");
|
||||
|
||||
|
@ -1211,7 +1211,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_vector_3() {
|
||||
fn vector_3() {
|
||||
let secp = Secp256k1::new();
|
||||
let seed = hex!("4b381541583be4423346c643850da4b320e46a87ae3d2a4e6da11eba819cd4acba45d239319ac14f863b8d5ab5a0d0c64d2e8a1e7d1457df2e5a3c51c73235be");
|
||||
|
||||
|
|
|
@ -508,7 +508,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_coinbase_and_bip34() {
|
||||
fn coinbase_and_bip34() {
|
||||
// testnet block 100,000
|
||||
const BLOCK_HEX: &str = "0200000035ab154183570282ce9afc0b494c9fc6a3cfea05aa8c1add2ecc56490000000038ba3d78e4500a5a7570dbe61960398add4410d278b21cd9708e6d9743f374d544fc055227f1001c29c1ea3b0101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff3703a08601000427f1001c046a510100522cfabe6d6d0000000000000000000068692066726f6d20706f6f6c7365727665726aac1eeeed88ffffffff0100f2052a010000001976a914912e2b234f941f30b18afbb4fa46171214bf66c888ac00000000";
|
||||
let block: Block = deserialize(&hex!(BLOCK_HEX)).unwrap();
|
||||
|
|
|
@ -591,7 +591,7 @@ macro_rules! unwrap_all {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_iterator() {
|
||||
fn iterator() {
|
||||
let zero = ScriptBuf::from_hex("00").unwrap();
|
||||
let zeropush = ScriptBuf::from_hex("0100").unwrap();
|
||||
|
||||
|
@ -669,7 +669,7 @@ fn script_ord() {
|
|||
|
||||
#[test]
|
||||
#[cfg(feature = "bitcoinconsensus")]
|
||||
fn test_bitcoinconsensus() {
|
||||
fn bitcoinconsensus() {
|
||||
use crate::consensus_validation::ScriptExt as _;
|
||||
|
||||
// a random SegWit transaction from the blockchain using native SegWit
|
||||
|
@ -707,7 +707,7 @@ fn default_dust_value() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_script_get_sigop_count() {
|
||||
fn script_get_sigop_count() {
|
||||
assert_eq!(
|
||||
Builder::new()
|
||||
.push_opcode(OP_DUP)
|
||||
|
@ -784,7 +784,7 @@ fn test_script_get_sigop_count() {
|
|||
|
||||
#[test]
|
||||
#[cfg(feature = "serde")]
|
||||
fn test_script_serde_human_and_not() {
|
||||
fn script_serde_human_and_not() {
|
||||
let script = ScriptBuf::from(vec![0u8, 1u8, 2u8]);
|
||||
|
||||
// Serialize
|
||||
|
@ -799,7 +799,7 @@ fn test_script_serde_human_and_not() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_instructions_are_fused() {
|
||||
fn instructions_are_fused() {
|
||||
let script = ScriptBuf::new();
|
||||
let mut instructions = script.instructions();
|
||||
assert!(instructions.next().is_none());
|
||||
|
|
|
@ -246,7 +246,7 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_push_ecdsa_sig() {
|
||||
fn push_ecdsa_sig() {
|
||||
// The very first signature in block 734,958
|
||||
let sig_bytes =
|
||||
hex!("304402207c800d698f4b0298c5aac830b822f011bb02df41eb114ade9a6702f364d5e39c0220366900d2a60cab903e77ef7dd415d46509b1f78ac78906e3296f495aa1b1b541");
|
||||
|
@ -286,7 +286,7 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_tapscript() {
|
||||
fn get_tapscript() {
|
||||
let tapscript = hex!("deadbeef");
|
||||
let control_block = hex!("02");
|
||||
// annex starting with 0x50 causes the branching logic.
|
||||
|
@ -307,7 +307,7 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_tapscript_from_keypath() {
|
||||
fn get_tapscript_from_keypath() {
|
||||
let signature = hex!("deadbeef");
|
||||
// annex starting with 0x50 causes the branching logic.
|
||||
let annex = hex!("50");
|
||||
|
@ -327,7 +327,7 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_control_block() {
|
||||
fn get_control_block() {
|
||||
let tapscript = hex!("deadbeef");
|
||||
let control_block = hex!("02");
|
||||
// annex starting with 0x50 causes the branching logic.
|
||||
|
@ -348,7 +348,7 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_annex() {
|
||||
fn get_annex() {
|
||||
let tapscript = hex!("deadbeef");
|
||||
let control_block = hex!("02");
|
||||
// annex starting with 0x50 causes the branching logic.
|
||||
|
@ -387,7 +387,7 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_tx() {
|
||||
fn tx() {
|
||||
const S: &str = "02000000000102b44f26b275b8ad7b81146ba3dbecd081f9c1ea0dc05b97516f56045cfcd3df030100000000ffffffff1cb4749ae827c0b75f3d0a31e63efc8c71b47b5e3634a4c698cd53661cab09170100000000ffffffff020b3a0500000000001976a9143ea74de92762212c96f4dd66c4d72a4deb20b75788ac630500000000000016001493a8dfd1f0b6a600ab01df52b138cda0b82bb7080248304502210084622878c94f4c356ce49c8e33a063ec90f6ee9c0208540888cfab056cd1fca9022014e8dbfdfa46d318c6887afd92dcfa54510e057565e091d64d2ee3a66488f82c0121026e181ffb98ebfe5a64c983073398ea4bcd1548e7b971b4c175346a25a1c12e950247304402203ef00489a0d549114977df2820fab02df75bebb374f5eee9e615107121658cfa02204751f2d1784f8e841bff6d3bcf2396af2f1a5537c0e4397224873fbd3bfbe9cf012102ae6aa498ce2dd204e9180e71b4fb1260fe3d1a95c8025b34e56a9adf5f278af200000000";
|
||||
let tx_bytes = hex!(S);
|
||||
let tx: Transaction = deserialize(&tx_bytes).unwrap();
|
||||
|
|
|
@ -1157,7 +1157,7 @@ mod tests {
|
|||
use crate::address::Address;
|
||||
|
||||
#[test]
|
||||
fn test_key_derivation() {
|
||||
fn key_derivation() {
|
||||
// testnet compressed
|
||||
let sk =
|
||||
PrivateKey::from_wif("cVt4o7BGAig1UXywgGSmARhxMdzP5qvQsxKkSsc1XEkw3tDTQFpy").unwrap();
|
||||
|
@ -1204,7 +1204,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_pubkey_hash() {
|
||||
fn pubkey_hash() {
|
||||
let pk = "032e58afe51f9ed8ad3cc7897f634d881fdbe49a81564629ded8156bebd2ffd1af"
|
||||
.parse::<PublicKey>()
|
||||
.unwrap();
|
||||
|
@ -1215,7 +1215,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_wpubkey_hash() {
|
||||
fn wpubkey_hash() {
|
||||
let pk = "032e58afe51f9ed8ad3cc7897f634d881fdbe49a81564629ded8156bebd2ffd1af"
|
||||
.parse::<PublicKey>()
|
||||
.unwrap();
|
||||
|
@ -1229,7 +1229,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
#[cfg(feature = "serde")]
|
||||
fn test_key_serde() {
|
||||
fn skey_serde() {
|
||||
use serde_test::{assert_tokens, Configure, Token};
|
||||
|
||||
static KEY_WIF: &str = "cVt4o7BGAig1UXywgGSmARhxMdzP5qvQsxKkSsc1XEkw3tDTQFpy";
|
||||
|
|
|
@ -1586,7 +1586,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_tap_sighash_hash() {
|
||||
fn tap_sighash_hash() {
|
||||
let bytes = hex!("00011b96877db45ffa23b307e9f0ac87b80ef9a80b4c5f0db3fbe734422453e83cc5576f3d542c5d4898fb2b696c15d43332534a7c1d1255fda38993545882df92c3e353ff6d36fbfadc4d168452afd8467f02fe53d71714fcea5dfe2ea759bd00185c4cb02bc76d42620393ca358a1a713f4997f9fc222911890afb3fe56c6a19b202df7bffdcfad08003821294279043746631b00e2dc5e52a111e213bbfe6ef09a19428d418dab0d50000000000");
|
||||
let expected = hex!("04e808aad07a40b3767a1442fead79af6ef7e7c9316d82dec409bb31e77699b0");
|
||||
let mut enc = sha256t::Hash::<TapSighashTag>::engine();
|
||||
|
@ -1596,7 +1596,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_sighashes_keyspending() {
|
||||
fn sighashes_keyspending() {
|
||||
// following test case has been taken from Bitcoin Core test framework
|
||||
|
||||
test_taproot_sighash(
|
||||
|
@ -1657,7 +1657,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_sighashes_with_annex() {
|
||||
fn sighashes_with_annex() {
|
||||
test_taproot_sighash(
|
||||
"0200000001df8123752e8f37d132c4e9f1ff7e4f9b986ade9211267e9ebd5fd22a5e718dec6d01000000ce4023b903cb7b23000000000017a914a18b36ea7a094db2f4940fc09edf154e86de7bd787580200000000000017a914afd0d512a2c5c2b40e25669e9cc460303c325b8b87580200000000000017a914a18b36ea7a094db2f4940fc09edf154e86de7bd787f6020000",
|
||||
"01ea49260000000000225120ab5e9800806bf18cb246edcf5fe63441208fe955a4b5a35bbff65f5db622a010",
|
||||
|
@ -1671,7 +1671,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_sighashes_with_script_path() {
|
||||
fn sighashes_with_script_path() {
|
||||
test_taproot_sighash(
|
||||
"020000000189fc651483f9296b906455dd939813bf086b1bbe7c77635e157c8e14ae29062195010000004445b5c7044561320000000000160014331414dbdada7fb578f700f38fb69995fc9b5ab958020000000000001976a914268db0a8104cc6d8afd91233cc8b3d1ace8ac3ef88ac580200000000000017a914ec00dcb368d6a693e11986d265f659d2f59e8be2875802000000000000160014c715799a49a0bae3956df9c17cb4440a673ac0df6f010000",
|
||||
"011bec34000000000022512028055142ea437db73382e991861446040b61dd2185c4891d7daf6893d79f7182",
|
||||
|
@ -1685,7 +1685,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_sighashes_with_script_path_raw_hash() {
|
||||
fn sighashes_with_script_path_raw_hash() {
|
||||
test_taproot_sighash(
|
||||
"020000000189fc651483f9296b906455dd939813bf086b1bbe7c77635e157c8e14ae29062195010000004445b5c7044561320000000000160014331414dbdada7fb578f700f38fb69995fc9b5ab958020000000000001976a914268db0a8104cc6d8afd91233cc8b3d1ace8ac3ef88ac580200000000000017a914ec00dcb368d6a693e11986d265f659d2f59e8be2875802000000000000160014c715799a49a0bae3956df9c17cb4440a673ac0df6f010000",
|
||||
"011bec34000000000022512028055142ea437db73382e991861446040b61dd2185c4891d7daf6893d79f7182",
|
||||
|
@ -1699,7 +1699,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_sighashes_with_annex_and_script() {
|
||||
fn sighashes_with_annex_and_script() {
|
||||
test_taproot_sighash(
|
||||
"020000000132fb72cb8fba496755f027a9743e2d698c831fdb8304e4d1a346ac92cbf51acba50100000026bdc7df044aad34000000000017a9144fa2554ed6174586854fa3bc01de58dcf33567d0875802000000000000160014950367e1e62cdf240b35b883fc2f5e39f0eb9ab95802000000000000160014950367e1e62cdf240b35b883fc2f5e39f0eb9ab958020000000000001600141b31217d48ccc8760dcc0710fade5866d628e733a02d5122",
|
||||
"011458360000000000225120a7baec3fb9f84614e3899fcc010c638f80f13539344120e1f4d8b68a9a011a13",
|
||||
|
@ -1714,7 +1714,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
#[rustfmt::skip] // Allow long function call `taproot_signature_hash`.
|
||||
fn test_sighash_errors() {
|
||||
fn sighash_errors() {
|
||||
use crate::transaction::{IndexOutOfBoundsError, InputsIndexError};
|
||||
|
||||
let dumb_tx = Transaction {
|
||||
|
@ -1773,7 +1773,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_annex_errors() {
|
||||
fn annex_errors() {
|
||||
assert_eq!(Annex::new(&[]), Err(AnnexError::Empty));
|
||||
assert_eq!(Annex::new(&[0x51]), Err(AnnexError::IncorrectPrefix(0x51)));
|
||||
assert_eq!(Annex::new(&[0x51, 0x50]), Err(AnnexError::IncorrectPrefix(0x51)));
|
||||
|
|
|
@ -363,7 +363,7 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_socket_addr() {
|
||||
fn socket_addr() {
|
||||
let s4 = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(111, 222, 123, 4)), 5555);
|
||||
let a4 = Address::new(&s4, ServiceFlags::NETWORK | ServiceFlags::WITNESS);
|
||||
assert_eq!(a4.socket_addr().unwrap(), s4);
|
||||
|
|
|
@ -1461,7 +1461,7 @@ mod tests {
|
|||
|
||||
#[cfg(feature = "serde")]
|
||||
#[test]
|
||||
fn test_serde_psbt() {
|
||||
fn serde_psbt() {
|
||||
//! Create a full PSBT value with various fields filled and make sure it can be JSONized.
|
||||
use hashes::sha256d;
|
||||
|
||||
|
@ -2118,7 +2118,7 @@ mod tests {
|
|||
|
||||
// https://github.com/rust-bitcoin/rust-bitcoin/issues/3628
|
||||
#[test]
|
||||
fn test_combine_psbt_fuzz_3628() {
|
||||
fn combine_psbt_fuzz_3628() {
|
||||
let mut psbt1 = hex_psbt(include_str!("../../tests/data/psbt_fuzz1.hex")).unwrap();
|
||||
let psbt2 = hex_psbt(include_str!("../../tests/data/psbt_fuzz2.hex")).unwrap();
|
||||
|
||||
|
@ -2154,7 +2154,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_fee() {
|
||||
fn fee() {
|
||||
let output_0_val = Amount::from_sat(99_999_699);
|
||||
let output_1_val = Amount::from_sat(100_000_000);
|
||||
let prev_output_val = Amount::from_sat(200_000_000);
|
||||
|
|
|
@ -240,7 +240,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
#[cfg(all(feature = "secp-recovery", feature = "base64", feature = "rand-std"))]
|
||||
fn test_message_signature() {
|
||||
fn message_signature() {
|
||||
use secp256k1;
|
||||
|
||||
use crate::{Address, AddressType, Network, NetworkKind};
|
||||
|
@ -286,7 +286,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
#[cfg(all(feature = "secp-recovery", feature = "base64"))]
|
||||
fn test_incorrect_message_signature() {
|
||||
fn incorrect_message_signature() {
|
||||
use base64::prelude::{Engine as _, BASE64_STANDARD};
|
||||
use secp256k1;
|
||||
|
||||
|
|
|
@ -1572,7 +1572,7 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_midstates() {
|
||||
fn midstates() {
|
||||
use sha256t::Hash;
|
||||
// test that engine creation roundtrips
|
||||
assert_eq!(tag_engine("TapLeaf").midstate(), TapLeafTag::engine().midstate());
|
||||
|
@ -1593,7 +1593,7 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_vectors_core() {
|
||||
fn vectors_core() {
|
||||
//! Test vectors taken from Core
|
||||
use sha256t::Hash;
|
||||
|
||||
|
@ -1840,7 +1840,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
#[cfg(feature = "serde")]
|
||||
fn test_leaf_version_serde() {
|
||||
fn leaf_version_serde() {
|
||||
let leaf_version = LeafVersion::TapScript;
|
||||
// use serde_test to test serialization and deserialization
|
||||
assert_tokens(&leaf_version, &[Token::U8(192)]);
|
||||
|
@ -1852,7 +1852,7 @@ mod test {
|
|||
|
||||
#[test]
|
||||
#[cfg(feature = "serde")]
|
||||
fn test_merkle_branch_serde() {
|
||||
fn merkle_branch_serde() {
|
||||
let hash1 = TapNodeHash::from_byte_array(
|
||||
"03ba2a4dcd914fed29a1c630c7e811271b081a0e2f2f52cf1c197583dfd46c1b"
|
||||
.parse::<sha256t::Hash<TapBranchTag>>()
|
||||
|
|
|
@ -333,7 +333,7 @@ mod tests {
|
|||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_chacha_block() {
|
||||
fn chacha_block() {
|
||||
let mut state = State {
|
||||
matrix: [
|
||||
U32x4([0x61707865, 0x3320646e, 0x79622d32, 0x6b206574]),
|
||||
|
@ -357,7 +357,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_prepare_state() {
|
||||
fn prepare_state() {
|
||||
let key =
|
||||
Key(Vec::from_hex("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")
|
||||
.unwrap()
|
||||
|
@ -374,7 +374,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_small_plaintext() {
|
||||
fn small_plaintext() {
|
||||
let key =
|
||||
Key(Vec::from_hex("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")
|
||||
.unwrap()
|
||||
|
@ -391,7 +391,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_modulo_64() {
|
||||
fn modulo_64() {
|
||||
let key =
|
||||
Key(Vec::from_hex("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")
|
||||
.unwrap()
|
||||
|
@ -408,7 +408,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_rfc_standard() {
|
||||
fn rfc_standard() {
|
||||
let key =
|
||||
Key(Vec::from_hex("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")
|
||||
.unwrap()
|
||||
|
@ -428,7 +428,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_new_from_block() {
|
||||
fn new_from_block() {
|
||||
let key =
|
||||
Key(Vec::from_hex("000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f")
|
||||
.unwrap()
|
||||
|
|
|
@ -165,7 +165,7 @@ mod tests {
|
|||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_rfc7539() {
|
||||
fn rfc7539() {
|
||||
let mut message = *b"Ladies and Gentlemen of the class of '99: If I could offer you only one tip for the future, sunscreen would be it.";
|
||||
let aad = Vec::from_hex("50515253c0c1c2c3c4c5c6c7").unwrap();
|
||||
let key = Key::new(
|
||||
|
|
|
@ -230,7 +230,7 @@ mod tests {
|
|||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_rfc7539() {
|
||||
fn rfc7539() {
|
||||
let key = Vec::from_hex("85d6be7857556d337f4452fe42d506a80103808afb0db2fd4abff6af4149f51b")
|
||||
.unwrap()
|
||||
.as_slice()
|
||||
|
|
|
@ -114,7 +114,7 @@ mod tests {
|
|||
use crate::sha256;
|
||||
|
||||
#[test]
|
||||
fn test_rfc5869_basic() {
|
||||
fn rfc5869_basic() {
|
||||
let salt = Vec::from_hex("000102030405060708090a0b0c").unwrap();
|
||||
let ikm = Vec::from_hex("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b").unwrap();
|
||||
let info = Vec::from_hex("f0f1f2f3f4f5f6f7f8f9").unwrap();
|
||||
|
@ -130,7 +130,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_rfc5869_longer_inputs_outputs() {
|
||||
fn rfc5869_longer_inputs_outputs() {
|
||||
let salt = Vec::from_hex(
|
||||
"606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7a8a9aaabacadaeaf"
|
||||
).unwrap();
|
||||
|
@ -152,7 +152,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_too_long_okm() {
|
||||
fn too_long_okm() {
|
||||
let salt = Vec::from_hex("000102030405060708090a0b0c").unwrap();
|
||||
let ikm = Vec::from_hex("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b").unwrap();
|
||||
let info = Vec::from_hex("f0f1f2f3f4f5f6f7f8f9").unwrap();
|
||||
|
@ -165,7 +165,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_short_okm() {
|
||||
fn short_okm() {
|
||||
let salt = Vec::from_hex("000102030405060708090a0b0c").unwrap();
|
||||
let ikm = Vec::from_hex("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b").unwrap();
|
||||
let info = Vec::from_hex("f0f1f2f3f4f5f6f7f8f9").unwrap();
|
||||
|
@ -178,7 +178,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_alloc_wrapper() {
|
||||
fn alloc_wrapper() {
|
||||
let salt = Vec::from_hex("000102030405060708090a0b0c").unwrap();
|
||||
let ikm = Vec::from_hex("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b").unwrap();
|
||||
let info = Vec::from_hex("f0f1f2f3f4f5f6f7f8f9").unwrap();
|
||||
|
|
|
@ -242,7 +242,7 @@ mod tests {
|
|||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_siphash_2_4() {
|
||||
fn siphash_2_4() {
|
||||
#[rustfmt::skip]
|
||||
let vecs: [[u8; 8]; 64] = [
|
||||
[0x31, 0x0e, 0x0e, 0xdd, 0x47, 0xdb, 0x6f, 0x72],
|
||||
|
|
|
@ -348,27 +348,27 @@ mod tests {
|
|||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_version_is_not_signalling_with_invalid_bit() {
|
||||
fn version_is_not_signalling_with_invalid_bit() {
|
||||
let arbitrary_version = Version::from_consensus(1234567890);
|
||||
// The max bit number to signal is 28.
|
||||
assert!(!Version::is_signalling_soft_fork(&arbitrary_version, 29));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_version_is_not_signalling_when_use_version_bit_not_set() {
|
||||
fn version_is_not_signalling_when_use_version_bit_not_set() {
|
||||
let version = Version::from_consensus(0b01000000000000000000000000000000);
|
||||
// Top three bits must be 001 to signal.
|
||||
assert!(!Version::is_signalling_soft_fork(&version, 1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_version_is_signalling() {
|
||||
fn version_is_signalling() {
|
||||
let version = Version::from_consensus(0b00100000000000000000000000000010);
|
||||
assert!(Version::is_signalling_soft_fork(&version, 1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_version_is_not_signalling() {
|
||||
fn version_is_not_signalling() {
|
||||
let version = Version::from_consensus(0b00100000000000000000000000000010);
|
||||
assert!(!Version::is_signalling_soft_fork(&version, 0));
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ fn from_int_btc() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_amount_try_from_signed_amount() {
|
||||
fn amount_try_from_signed_amount() {
|
||||
let sa_positive = SignedAmount::from_sat_unchecked(123);
|
||||
let ua_positive = Amount::try_from(sa_positive).unwrap();
|
||||
assert_eq!(ua_positive, Amount::from_sat_unchecked(123));
|
||||
|
@ -103,7 +103,7 @@ fn mul_div() {
|
|||
|
||||
#[cfg(feature = "std")]
|
||||
#[test]
|
||||
fn test_overflows() {
|
||||
fn overflows() {
|
||||
// panic on overflow
|
||||
let result = panic::catch_unwind(|| Amount::MAX + Amount::from_sat_unchecked(1));
|
||||
assert!(result.is_err());
|
||||
|
@ -461,7 +461,7 @@ check_format_non_negative_show_denom! {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_unsigned_signed_conversion() {
|
||||
fn unsigned_signed_conversion() {
|
||||
let sa = SignedAmount::from_sat;
|
||||
let ua = Amount::from_sat;
|
||||
let max_sats: u64 = Amount::MAX.to_sat();
|
||||
|
|
|
@ -231,14 +231,14 @@ fn api_all_non_error_types_have_non_empty_debug() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn test_send() {
|
||||
fn send() {
|
||||
fn assert_send<T: Send>() {}
|
||||
assert_send::<Types>();
|
||||
assert_send::<Errors>();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_sync() {
|
||||
fn sync() {
|
||||
fn assert_sync<T: Sync>() {}
|
||||
assert_sync::<Types>();
|
||||
assert_sync::<Errors>();
|
||||
|
|
Loading…
Reference in New Issue