Manually format a bunch of vecs

In preparation for modifying some unit test data structures, manually
format the code so it is uniform.

Move elements added to a vec with `vec!` onto a new line so they all
line up and one can better see what fields go where.

Refactor only, no logic changes.
This commit is contained in:
Tobin C. Harding 2023-01-20 15:19:54 +11:00
parent 83e1c40c4d
commit 3e70c01826
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 234 additions and 208 deletions

View File

@ -908,17 +908,19 @@ mod tests {
unsigned_tx: Transaction { unsigned_tx: Transaction {
version: 2, version: 2,
lock_time: absolute::LockTime::from_consensus(1257139), lock_time: absolute::LockTime::from_consensus(1257139),
input: vec![TxIn { input: vec![
previous_output: OutPoint { TxIn {
txid: Txid::from_hex( previous_output: OutPoint {
"f61b1742ca13176464adb3cb66050c00787bb3a4eead37e985f2df1e37718126", txid: Txid::from_hex(
).unwrap(), "f61b1742ca13176464adb3cb66050c00787bb3a4eead37e985f2df1e37718126",
vout: 0, ).unwrap(),
}, vout: 0,
script_sig: ScriptBuf::new(), },
sequence: Sequence::ENABLE_LOCKTIME_NO_RBF, script_sig: ScriptBuf::new(),
witness: Witness::default(), sequence: Sequence::ENABLE_LOCKTIME_NO_RBF,
}], witness: Witness::default(),
}
],
output: vec![ output: vec![
TxOut { TxOut {
value: 99999699, value: 99999699,
@ -980,15 +982,17 @@ mod tests {
let tx = Transaction { let tx = Transaction {
version: 1, version: 1,
lock_time: absolute::LockTime::ZERO, lock_time: absolute::LockTime::ZERO,
input: vec![TxIn { input: vec![
previous_output: OutPoint { TxIn {
txid: Txid::from_hex("e567952fb6cc33857f392efa3a46c995a28f69cca4bb1b37e0204dab1ec7a389").unwrap(), previous_output: OutPoint {
vout: 1, txid: Txid::from_hex("e567952fb6cc33857f392efa3a46c995a28f69cca4bb1b37e0204dab1ec7a389").unwrap(),
}, vout: 1,
script_sig: hex_script!("160014be18d152a9b012039daf3da7de4f53349eecb985"), },
sequence: Sequence::MAX, script_sig: hex_script!("160014be18d152a9b012039daf3da7de4f53349eecb985"),
witness: Witness::from_slice(&[hex!("03d2e15674941bad4a996372cb87e1856d3652606d98562fe39c5e9e7e413f2105")]), sequence: Sequence::MAX,
}], witness: Witness::from_slice(&[hex!("03d2e15674941bad4a996372cb87e1856d3652606d98562fe39c5e9e7e413f2105")]),
}
],
output: vec![ output: vec![
TxOut { TxOut {
value: 190303501938, value: 190303501938,
@ -1032,35 +1036,39 @@ mod tests {
proprietary: proprietary.clone(), proprietary: proprietary.clone(),
unknown: unknown.clone(), unknown: unknown.clone(),
inputs: vec![Input { inputs: vec![
non_witness_utxo: Some(tx), Input {
witness_utxo: Some(TxOut { non_witness_utxo: Some(tx),
value: 190303501938, witness_utxo: Some(TxOut {
script_pubkey: hex_script!("a914339725ba21efd62ac753a9bcd067d6c7a6a39d0587"), value: 190303501938,
}), script_pubkey: hex_script!("a914339725ba21efd62ac753a9bcd067d6c7a6a39d0587"),
sighash_type: Some("SIGHASH_SINGLE|SIGHASH_ANYONECANPAY".parse::<EcdsaSighashType>().unwrap().into()), }),
redeem_script: Some(vec![0x51].into()), sighash_type: Some("SIGHASH_SINGLE|SIGHASH_ANYONECANPAY".parse::<EcdsaSighashType>().unwrap().into()),
witness_script: None, redeem_script: Some(vec![0x51].into()),
partial_sigs: vec![( witness_script: None,
"0339880dc92394b7355e3d0439fa283c31de7590812ea011c4245c0674a685e883".parse().unwrap(), partial_sigs: vec![(
"304402204f67e2afb76142d44fae58a2495d33a3419daa26cd0db8d04f3452b63289ac0f022010762a9fb67e94cc5cad9026f6dc99ff7f070f4278d30fbc7d0c869dd38c7fe701".parse().unwrap(), "0339880dc92394b7355e3d0439fa283c31de7590812ea011c4245c0674a685e883".parse().unwrap(),
)].into_iter().collect(), "304402204f67e2afb76142d44fae58a2495d33a3419daa26cd0db8d04f3452b63289ac0f022010762a9fb67e94cc5cad9026f6dc99ff7f070f4278d30fbc7d0c869dd38c7fe701".parse().unwrap(),
bip32_derivation: keypaths.clone(), )].into_iter().collect(),
final_script_witness: Some(Witness::from_slice(&[vec![1, 3], vec![5]])), bip32_derivation: keypaths.clone(),
ripemd160_preimages: vec![(ripemd160::Hash::hash(&[]), vec![1, 2])].into_iter().collect(), final_script_witness: Some(Witness::from_slice(&[vec![1, 3], vec![5]])),
sha256_preimages: vec![(sha256::Hash::hash(&[]), vec![1, 2])].into_iter().collect(), ripemd160_preimages: vec![(ripemd160::Hash::hash(&[]), vec![1, 2])].into_iter().collect(),
hash160_preimages: vec![(hash160::Hash::hash(&[]), vec![1, 2])].into_iter().collect(), sha256_preimages: vec![(sha256::Hash::hash(&[]), vec![1, 2])].into_iter().collect(),
hash256_preimages: vec![(sha256d::Hash::hash(&[]), vec![1, 2])].into_iter().collect(), hash160_preimages: vec![(hash160::Hash::hash(&[]), vec![1, 2])].into_iter().collect(),
proprietary: proprietary.clone(), hash256_preimages: vec![(sha256d::Hash::hash(&[]), vec![1, 2])].into_iter().collect(),
unknown: unknown.clone(), proprietary: proprietary.clone(),
..Default::default() unknown: unknown.clone(),
}], ..Default::default()
outputs: vec![Output { }
bip32_derivation: keypaths, ],
proprietary, outputs: vec![
unknown, Output {
..Default::default() bip32_derivation: keypaths,
}], proprietary,
unknown,
..Default::default()
}
],
}; };
let encoded = serde_json::to_string(&psbt).unwrap(); let encoded = serde_json::to_string(&psbt).unwrap();
let decoded: PartiallySignedTransaction = serde_json::from_str(&encoded).unwrap(); let decoded: PartiallySignedTransaction = serde_json::from_str(&encoded).unwrap();
@ -1166,17 +1174,19 @@ mod tests {
unsigned_tx: Transaction { unsigned_tx: Transaction {
version: 2, version: 2,
lock_time: absolute::LockTime::from_consensus(1257139), lock_time: absolute::LockTime::from_consensus(1257139),
input: vec![TxIn { input: vec![
previous_output: OutPoint { TxIn {
txid: Txid::from_hex( previous_output: OutPoint {
"f61b1742ca13176464adb3cb66050c00787bb3a4eead37e985f2df1e37718126", txid: Txid::from_hex(
).unwrap(), "f61b1742ca13176464adb3cb66050c00787bb3a4eead37e985f2df1e37718126",
vout: 0, ).unwrap(),
}, vout: 0,
script_sig: ScriptBuf::new(), },
sequence: Sequence::ENABLE_LOCKTIME_NO_RBF, script_sig: ScriptBuf::new(),
witness: Witness::default(), sequence: Sequence::ENABLE_LOCKTIME_NO_RBF,
}], witness: Witness::default(),
}
],
output: vec![ output: vec![
TxOut { TxOut {
value: 99999699, value: 99999699,
@ -1193,51 +1203,55 @@ mod tests {
proprietary: BTreeMap::new(), proprietary: BTreeMap::new(),
unknown: BTreeMap::new(), unknown: BTreeMap::new(),
inputs: vec![Input { inputs: vec![
non_witness_utxo: Some(Transaction { Input {
version: 1, non_witness_utxo: Some(Transaction {
lock_time: absolute::LockTime::ZERO, version: 1,
input: vec![TxIn { lock_time: absolute::LockTime::ZERO,
previous_output: OutPoint { input: vec![
txid: Txid::from_hex( TxIn {
"e567952fb6cc33857f392efa3a46c995a28f69cca4bb1b37e0204dab1ec7a389", previous_output: OutPoint {
).unwrap(), txid: Txid::from_hex(
vout: 1, "e567952fb6cc33857f392efa3a46c995a28f69cca4bb1b37e0204dab1ec7a389",
}, ).unwrap(),
script_sig: hex_script!("160014be18d152a9b012039daf3da7de4f53349eecb985"), vout: 1,
sequence: Sequence::MAX, },
witness: Witness::from_slice(&[ script_sig: hex_script!("160014be18d152a9b012039daf3da7de4f53349eecb985"),
hex!("304402202712be22e0270f394f568311dc7ca9a68970b8025fdd3b240229f07f8a5f3a240220018b38d7dcd314e734c9276bd6fb40f673325bc4baa144c800d2f2f02db2765c01"), sequence: Sequence::MAX,
hex!("03d2e15674941bad4a996372cb87e1856d3652606d98562fe39c5e9e7e413f2105"), witness: Witness::from_slice(&[
]), hex!("304402202712be22e0270f394f568311dc7ca9a68970b8025fdd3b240229f07f8a5f3a240220018b38d7dcd314e734c9276bd6fb40f673325bc4baa144c800d2f2f02db2765c01"),
}, hex!("03d2e15674941bad4a996372cb87e1856d3652606d98562fe39c5e9e7e413f2105"),
TxIn { ]),
previous_output: OutPoint { },
txid: Txid::from_hex( TxIn {
"b490486aec3ae671012dddb2bb08466bef37720a533a894814ff1da743aaf886", previous_output: OutPoint {
).unwrap(), txid: Txid::from_hex(
vout: 1, "b490486aec3ae671012dddb2bb08466bef37720a533a894814ff1da743aaf886",
}, ).unwrap(),
script_sig: hex_script!("160014fe3e9ef1a745e974d902c4355943abcb34bd5353"), vout: 1,
sequence: Sequence::MAX, },
witness: Witness::from_slice(&[ script_sig: hex_script!("160014fe3e9ef1a745e974d902c4355943abcb34bd5353"),
hex!("3045022100d12b852d85dcd961d2f5f4ab660654df6eedcc794c0c33ce5cc309ffb5fce58d022067338a8e0e1725c197fb1a88af59f51e44e4255b20167c8684031c05d1f2592a01"), sequence: Sequence::MAX,
hex!("0223b72beef0965d10be0778efecd61fcac6f79a4ea169393380734464f84f2ab3"), witness: Witness::from_slice(&[
]), hex!("3045022100d12b852d85dcd961d2f5f4ab660654df6eedcc794c0c33ce5cc309ffb5fce58d022067338a8e0e1725c197fb1a88af59f51e44e4255b20167c8684031c05d1f2592a01"),
}], hex!("0223b72beef0965d10be0778efecd61fcac6f79a4ea169393380734464f84f2ab3"),
output: vec![ ]),
TxOut { }
value: 200000000, ],
script_pubkey: hex_script!("76a91485cff1097fd9e008bb34af709c62197b38978a4888ac"), output: vec![
}, TxOut {
TxOut { value: 200000000,
value: 190303501938, script_pubkey: hex_script!("76a91485cff1097fd9e008bb34af709c62197b38978a4888ac"),
script_pubkey: hex_script!("a914339725ba21efd62ac753a9bcd067d6c7a6a39d0587"), },
}, TxOut {
], value: 190303501938,
}), script_pubkey: hex_script!("a914339725ba21efd62ac753a9bcd067d6c7a6a39d0587"),
..Default::default() },
},], ],
}),
..Default::default()
},
],
outputs: vec![ outputs: vec![
Output { Output {
..Default::default() ..Default::default()
@ -1486,17 +1500,19 @@ mod tests {
unsigned_tx: Transaction { unsigned_tx: Transaction {
version: 2, version: 2,
lock_time: absolute::LockTime::from_consensus(1257139), lock_time: absolute::LockTime::from_consensus(1257139),
input: vec![TxIn { input: vec![
previous_output: OutPoint { TxIn {
txid: Txid::from_hex( previous_output: OutPoint {
"f61b1742ca13176464adb3cb66050c00787bb3a4eead37e985f2df1e37718126", txid: Txid::from_hex(
).unwrap(), "f61b1742ca13176464adb3cb66050c00787bb3a4eead37e985f2df1e37718126",
vout: 0, ).unwrap(),
}, vout: 0,
script_sig: ScriptBuf::new(), },
sequence: Sequence::ENABLE_LOCKTIME_NO_RBF, script_sig: ScriptBuf::new(),
witness: Witness::default(), sequence: Sequence::ENABLE_LOCKTIME_NO_RBF,
}], witness: Witness::default(),
}
],
output: vec![ output: vec![
TxOut { TxOut {
value: 99999699, value: 99999699,
@ -1513,51 +1529,55 @@ mod tests {
proprietary: Default::default(), proprietary: Default::default(),
unknown: BTreeMap::new(), unknown: BTreeMap::new(),
inputs: vec![Input { inputs: vec![
non_witness_utxo: Some(Transaction { Input {
version: 1, non_witness_utxo: Some(Transaction {
lock_time: absolute::LockTime::ZERO, version: 1,
input: vec![TxIn { lock_time: absolute::LockTime::ZERO,
previous_output: OutPoint { input: vec![
txid: Txid::from_hex( TxIn {
"e567952fb6cc33857f392efa3a46c995a28f69cca4bb1b37e0204dab1ec7a389", previous_output: OutPoint {
).unwrap(), txid: Txid::from_hex(
vout: 1, "e567952fb6cc33857f392efa3a46c995a28f69cca4bb1b37e0204dab1ec7a389",
}, ).unwrap(),
script_sig: hex_script!("160014be18d152a9b012039daf3da7de4f53349eecb985"), vout: 1,
sequence: Sequence::MAX, },
witness: Witness::from_slice(&[ script_sig: hex_script!("160014be18d152a9b012039daf3da7de4f53349eecb985"),
hex!("304402202712be22e0270f394f568311dc7ca9a68970b8025fdd3b240229f07f8a5f3a240220018b38d7dcd314e734c9276bd6fb40f673325bc4baa144c800d2f2f02db2765c01"), sequence: Sequence::MAX,
hex!("03d2e15674941bad4a996372cb87e1856d3652606d98562fe39c5e9e7e413f2105"), witness: Witness::from_slice(&[
]), hex!("304402202712be22e0270f394f568311dc7ca9a68970b8025fdd3b240229f07f8a5f3a240220018b38d7dcd314e734c9276bd6fb40f673325bc4baa144c800d2f2f02db2765c01"),
}, hex!("03d2e15674941bad4a996372cb87e1856d3652606d98562fe39c5e9e7e413f2105"),
TxIn { ]),
previous_output: OutPoint { },
txid: Txid::from_hex( TxIn {
"b490486aec3ae671012dddb2bb08466bef37720a533a894814ff1da743aaf886", previous_output: OutPoint {
).unwrap(), txid: Txid::from_hex(
vout: 1, "b490486aec3ae671012dddb2bb08466bef37720a533a894814ff1da743aaf886",
}, ).unwrap(),
script_sig: hex_script!("160014fe3e9ef1a745e974d902c4355943abcb34bd5353"), vout: 1,
sequence: Sequence::MAX, },
witness: Witness::from_slice(&[ script_sig: hex_script!("160014fe3e9ef1a745e974d902c4355943abcb34bd5353"),
hex!("3045022100d12b852d85dcd961d2f5f4ab660654df6eedcc794c0c33ce5cc309ffb5fce58d022067338a8e0e1725c197fb1a88af59f51e44e4255b20167c8684031c05d1f2592a01"), sequence: Sequence::MAX,
hex!("0223b72beef0965d10be0778efecd61fcac6f79a4ea169393380734464f84f2ab3"), witness: Witness::from_slice(&[
]), hex!("3045022100d12b852d85dcd961d2f5f4ab660654df6eedcc794c0c33ce5cc309ffb5fce58d022067338a8e0e1725c197fb1a88af59f51e44e4255b20167c8684031c05d1f2592a01"),
}], hex!("0223b72beef0965d10be0778efecd61fcac6f79a4ea169393380734464f84f2ab3"),
output: vec![ ]),
TxOut { }
value: 200000000, ],
script_pubkey: hex_script!("76a91485cff1097fd9e008bb34af709c62197b38978a4888ac"), output: vec![
}, TxOut {
TxOut { value: 200000000,
value: 190303501938, script_pubkey: hex_script!("76a91485cff1097fd9e008bb34af709c62197b38978a4888ac"),
script_pubkey: hex_script!("a914339725ba21efd62ac753a9bcd067d6c7a6a39d0587"), },
}, TxOut {
], value: 190303501938,
}), script_pubkey: hex_script!("a914339725ba21efd62ac753a9bcd067d6c7a6a39d0587"),
..Default::default() },
},], ],
}),
..Default::default()
},
],
outputs: vec![ outputs: vec![
Output { Output {
..Default::default() ..Default::default()
@ -1656,16 +1676,18 @@ mod tests {
unsigned_tx: Transaction { unsigned_tx: Transaction {
version: 2, version: 2,
lock_time: absolute::LockTime::from_consensus(1257139), lock_time: absolute::LockTime::from_consensus(1257139),
input: vec![TxIn { input: vec![
previous_output: OutPoint { TxIn {
txid: Txid::from_hex( previous_output: OutPoint {
"f61b1742ca13176464adb3cb66050c00787bb3a4eead37e985f2df1e37718126", txid: Txid::from_hex(
).unwrap(), "f61b1742ca13176464adb3cb66050c00787bb3a4eead37e985f2df1e37718126",
vout: 0, ).unwrap(),
}, vout: 0,
sequence: Sequence::ENABLE_LOCKTIME_NO_RBF, },
..Default::default() sequence: Sequence::ENABLE_LOCKTIME_NO_RBF,
}], ..Default::default()
}
],
output: vec![ output: vec![
TxOut { TxOut {
value: output_0_val, value: output_0_val,
@ -1682,43 +1704,47 @@ mod tests {
proprietary: BTreeMap::new(), proprietary: BTreeMap::new(),
unknown: BTreeMap::new(), unknown: BTreeMap::new(),
inputs: vec![Input { inputs: vec![
non_witness_utxo: Some(Transaction { Input {
version: 1, non_witness_utxo: Some(Transaction {
lock_time: absolute::LockTime::ZERO, version: 1,
input: vec![TxIn { lock_time: absolute::LockTime::ZERO,
previous_output: OutPoint { input: vec![
txid: Txid::from_hex( TxIn {
"e567952fb6cc33857f392efa3a46c995a28f69cca4bb1b37e0204dab1ec7a389", previous_output: OutPoint {
).unwrap(), txid: Txid::from_hex(
vout: 1, "e567952fb6cc33857f392efa3a46c995a28f69cca4bb1b37e0204dab1ec7a389",
}, ).unwrap(),
sequence: Sequence::MAX, vout: 1,
..Default::default() },
}, sequence: Sequence::MAX,
TxIn { ..Default::default()
previous_output: OutPoint { },
txid: Txid::from_hex( TxIn {
"b490486aec3ae671012dddb2bb08466bef37720a533a894814ff1da743aaf886", previous_output: OutPoint {
).unwrap(), txid: Txid::from_hex(
vout: 1, "b490486aec3ae671012dddb2bb08466bef37720a533a894814ff1da743aaf886",
}, ).unwrap(),
sequence: Sequence::MAX, vout: 1,
..Default::default() },
}], sequence: Sequence::MAX,
output: vec![ ..Default::default()
TxOut { }
value: prev_output_val, ],
..Default::default() output: vec![
}, TxOut {
TxOut { value: prev_output_val,
value: 190303501938, ..Default::default()
..Default::default() },
}, TxOut {
], value: 190303501938,
}), ..Default::default()
..Default::default() },
},], ],
}),
..Default::default()
},
],
outputs: vec![ outputs: vec![
Output { Output {
..Default::default() ..Default::default()