Skip to content

Commit

Permalink
Fix test compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jouzo committed Feb 9, 2024
1 parent b0d7217 commit af64fe4
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 8 deletions.
11 changes: 9 additions & 2 deletions bitcoin/src/bip152.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,11 @@ mod test {
sequence: Sequence(1),
witness: Witness::new(),
}],
output: vec![TxOut { value: Amount::ONE_SAT, script_pubkey: ScriptBuf::new() }],
output: vec![TxOut {
value: Amount::ONE_SAT,
script_pubkey: ScriptBuf::new(),
unused_token_id: 0,
}],
}
}

Expand All @@ -404,7 +408,10 @@ mod test {
merkle_root: TxMerkleNode::hash(&[1]),
time: 2,
bits: CompactTarget::from_consensus(3),
nonce: 4,
deprecated_height: 0,
minted_blocks: 0,
sig: Vec::new(),
stake_modifier: [0u8; 32],
},
txdata: vec![dummy_tx(&[2]), dummy_tx(&[3]), dummy_tx(&[4])],
}
Expand Down
2 changes: 0 additions & 2 deletions bitcoin/src/blockdata/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,6 @@ mod tests {
assert_eq!(serialize(&real_decode.header.merkle_root), merkle);
assert_eq!(real_decode.header.time, 1231965655);
assert_eq!(real_decode.header.bits, CompactTarget::from_consensus(486604799));
assert_eq!(real_decode.header.nonce, 2067413810);
assert_eq!(real_decode.header.work(), work);
assert_eq!(
real_decode.header.validate_pow(real_decode.header.target()).unwrap(),
Expand Down Expand Up @@ -569,7 +568,6 @@ mod tests {
assert_eq!(real_decode.header.merkle_root, real_decode.compute_merkle_root().unwrap());
assert_eq!(real_decode.header.time, 1472004949);
assert_eq!(real_decode.header.bits, CompactTarget::from_consensus(0x1a06d450));
assert_eq!(real_decode.header.nonce, 1879759182);
assert_eq!(real_decode.header.work(), work);
assert_eq!(
real_decode.header.validate_pow(real_decode.header.target()).unwrap(),
Expand Down
3 changes: 0 additions & 3 deletions bitcoin/src/blockdata/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ mod test {

assert_eq!(gen.header.time, 1231006505);
assert_eq!(gen.header.bits, CompactTarget::from_consensus(0x1d00ffff));
assert_eq!(gen.header.nonce, 2083236893);
assert_eq!(
gen.header.block_hash().to_string(),
"000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
Expand All @@ -266,7 +265,6 @@ mod test {
);
assert_eq!(gen.header.time, 1296688602);
assert_eq!(gen.header.bits, CompactTarget::from_consensus(0x1d00ffff));
assert_eq!(gen.header.nonce, 414098458);
assert_eq!(
gen.header.block_hash().to_string(),
"000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"
Expand All @@ -284,7 +282,6 @@ mod test {
);
assert_eq!(gen.header.time, 1598918400);
assert_eq!(gen.header.bits, CompactTarget::from_consensus(0x1e0377ae));
assert_eq!(gen.header.nonce, 52613770);
assert_eq!(
gen.header.block_hash().to_string(),
"00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6"
Expand Down
6 changes: 5 additions & 1 deletion bitcoin/src/crypto/sighash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1753,7 +1753,11 @@ mod tests {
.given
.utxos_spent
.into_iter()
.map(|txo| TxOut { value: txo.value, script_pubkey: txo.script_pubkey })
.map(|txo| TxOut {
value: txo.value,
script_pubkey: txo.script_pubkey,
unused_token_id: 0,
})
.collect::<Vec<_>>();

// Test intermediary
Expand Down
18 changes: 18 additions & 0 deletions bitcoin/src/psbt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,7 @@ mod tests {
witness: Witness::default(),
}],
output: vec![TxOut {
unused_token_id: 0,
value: Amount::from_sat(output),
script_pubkey: ScriptBuf::from_hex(
"a9143545e6e33b832c47050f24d3eeb93c9c03948bc787",
Expand All @@ -1060,6 +1061,7 @@ mod tests {

inputs: vec![Input {
witness_utxo: Some(TxOut {
unused_token_id: 0,
value: Amount::from_sat(input),
script_pubkey: ScriptBuf::from_hex(
"a914339725ba21efd62ac753a9bcd067d6c7a6a39d0587",
Expand Down Expand Up @@ -1207,13 +1209,15 @@ mod tests {
}],
output: vec![
TxOut {
unused_token_id: 0,
value: Amount::from_sat(99_999_699),
script_pubkey: ScriptBuf::from_hex(
"76a914d0c59903c5bac2868760e90fd521a4665aa7652088ac",
)
.unwrap(),
},
TxOut {
unused_token_id: 0,
value: Amount::from_sat(100_000_000),
script_pubkey: ScriptBuf::from_hex(
"a9143545e6e33b832c47050f24d3eeb93c9c03948bc787",
Expand Down Expand Up @@ -1280,6 +1284,7 @@ mod tests {
)]),
}],
output: vec![TxOut {
unused_token_id: 0,
value: Amount::from_sat(190_303_501_938),
script_pubkey: ScriptBuf::from_hex(
"a914339725ba21efd62ac753a9bcd067d6c7a6a39d0587",
Expand Down Expand Up @@ -1331,6 +1336,7 @@ mod tests {
Input {
non_witness_utxo: Some(tx),
witness_utxo: Some(TxOut {
unused_token_id: 0,
value: Amount::from_sat(190_303_501_938),
script_pubkey: ScriptBuf::from_hex("a914339725ba21efd62ac753a9bcd067d6c7a6a39d0587").unwrap(),
}),
Expand Down Expand Up @@ -1466,10 +1472,12 @@ mod tests {
],
output: vec![
TxOut {
unused_token_id: 0,
value: Amount::from_sat(99_999_699),
script_pubkey: ScriptBuf::from_hex("76a914d0c59903c5bac2868760e90fd521a4665aa7652088ac").unwrap(),
},
TxOut {
unused_token_id: 0,
value: Amount::from_sat(100_000_000),
script_pubkey: ScriptBuf::from_hex("a9143545e6e33b832c47050f24d3eeb93c9c03948bc787").unwrap(),
},
Expand Down Expand Up @@ -1513,10 +1521,12 @@ mod tests {
],
output: vec![
TxOut {
unused_token_id: 0,
value: Amount::from_sat(200_000_000),
script_pubkey: ScriptBuf::from_hex("76a91485cff1097fd9e008bb34af709c62197b38978a4888ac").unwrap(),
},
TxOut {
unused_token_id: 0,
value: Amount::from_sat(190_303_501_938),
script_pubkey: ScriptBuf::from_hex("a914339725ba21efd62ac753a9bcd067d6c7a6a39d0587").unwrap(),
},
Expand Down Expand Up @@ -1798,10 +1808,12 @@ mod tests {
],
output: vec![
TxOut {
unused_token_id: 0,
value: Amount::from_sat(99_999_699),
script_pubkey: ScriptBuf::from_hex("76a914d0c59903c5bac2868760e90fd521a4665aa7652088ac").unwrap(),
},
TxOut {
unused_token_id: 0,
value: Amount::from_sat(100_000_000),
script_pubkey: ScriptBuf::from_hex("a9143545e6e33b832c47050f24d3eeb93c9c03948bc787").unwrap(),
},
Expand Down Expand Up @@ -1845,10 +1857,12 @@ mod tests {
],
output: vec![
TxOut {
unused_token_id: 0,
value: Amount::from_sat(200_000_000),
script_pubkey: ScriptBuf::from_hex("76a91485cff1097fd9e008bb34af709c62197b38978a4888ac").unwrap(),
},
TxOut {
unused_token_id: 0,
value: Amount::from_sat(190_303_501_938),
script_pubkey: ScriptBuf::from_hex("a914339725ba21efd62ac753a9bcd067d6c7a6a39d0587").unwrap(),
},
Expand Down Expand Up @@ -1966,10 +1980,12 @@ mod tests {
],
output: vec![
TxOut {
unused_token_id: 0,
value: output_0_val,
script_pubkey: ScriptBuf::new()
},
TxOut {
unused_token_id: 0,
value: output_1_val,
script_pubkey: ScriptBuf::new()
},
Expand Down Expand Up @@ -2005,10 +2021,12 @@ mod tests {
],
output: vec![
TxOut {
unused_token_id: 0,
value: prev_output_val,
script_pubkey: ScriptBuf::new()
},
TxOut {
unused_token_id: 0,
value: Amount::from_sat(190_303_501_938),
script_pubkey: ScriptBuf::new()
},
Expand Down
2 changes: 2 additions & 0 deletions bitcoin/tests/psbt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,14 @@ fn create_transaction() -> Transaction {
],
output: vec![
TxOut {
unused_token_id: 0,
value: Amount::from_str_in(output_0.amount, Denomination::Bitcoin)
.expect("failed to parse amount"),
script_pubkey: ScriptBuf::from_hex(output_0.script_pubkey)
.expect("failed to parse script"),
},
TxOut {
unused_token_id: 0,
value: Amount::from_str_in(output_1.amount, Denomination::Bitcoin)
.expect("failed to parse amount"),
script_pubkey: ScriptBuf::from_hex(output_1.script_pubkey)
Expand Down
3 changes: 3 additions & 0 deletions bitcoin/tests/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ fn serde_regression_txin() {
#[test]
fn serde_regression_txout() {
let txout = TxOut {
unused_token_id: 0,
value: Amount::from_sat(0xDEADBEEFCAFEBABE),
script_pubkey: ScriptBuf::from(vec![0u8, 1u8, 2u8]),
};
Expand Down Expand Up @@ -239,6 +240,7 @@ fn serde_regression_psbt() {
.unwrap()]),
}],
output: vec![TxOut {
unused_token_id: 0,
value: Amount::from_sat(190_303_501_938),
script_pubkey: ScriptBuf::from_hex("a914339725ba21efd62ac753a9bcd067d6c7a6a39d0587")
.unwrap(),
Expand Down Expand Up @@ -284,6 +286,7 @@ fn serde_regression_psbt() {
inputs: vec![Input {
non_witness_utxo: Some(tx),
witness_utxo: Some(TxOut {
unused_token_id: 0,
value: Amount::from_sat(190_303_501_938),
script_pubkey: ScriptBuf::from_hex("a914339725ba21efd62ac753a9bcd067d6c7a6a39d0587").unwrap(),
}),
Expand Down

0 comments on commit af64fe4

Please sign in to comment.