Skip to content

Commit

Permalink
Do not mutate local variable
Browse files Browse the repository at this point in the history
Clippy emits:

 warning: field assignment outside of initializer for an instance
 created with Default::default()

As suggested use `..Default::default()` instead of mutating.
  • Loading branch information
tcharding committed May 16, 2024
1 parent e361cfc commit 7ed6680
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
22 changes: 13 additions & 9 deletions bitcoind-tests/tests/test_cpp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,14 @@ pub fn test_from_cpp_ms(cl: &Client, testdata: &TestData) {
};
// figure out the outpoint from the txid
let (outpoint, witness_utxo) = get_vout(&cl, txid, btc(1.0));
let mut txin = TxIn::default();
txin.previous_output = outpoint;
// set the sequence to a non-final number for the locktime transactions to be
// processed correctly.
// We waited 50 blocks, keep 49 for safety
txin.sequence = Sequence::from_height(49);
let txin = TxIn {
previous_output: outpoint,
// set the sequence to a non-final number for the locktime transactions to be
// processed correctly.
// We waited 50 blocks, keep 49 for safety
sequence: Sequence::from_height(49),
..Default::default()
};
psbt.unsigned_tx.input.push(txin);
// Get a new script pubkey from the node so that
// the node wallet tracks the receiving transaction
Expand All @@ -138,9 +140,11 @@ pub fn test_from_cpp_ms(cl: &Client, testdata: &TestData) {
value: Amount::from_sat(99_999_000),
script_pubkey: addr.script_pubkey(),
});
let mut input = psbt::Input::default();
input.witness_utxo = Some(witness_utxo);
input.witness_script = Some(desc.explicit_script().unwrap());
let input = psbt::Input {
witness_utxo: Some(witness_utxo),
witness_script: Some(desc.explicit_script().unwrap()),
..Default::default()
};
psbt.inputs.push(input);
psbt.update_input_with_descriptor(0, &desc).unwrap();
psbt.outputs.push(psbt::Output::default());
Expand Down
14 changes: 8 additions & 6 deletions bitcoind-tests/tests/test_desc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,14 @@ pub fn test_desc_satisfy(
};
// figure out the outpoint from the txid
let (outpoint, witness_utxo) = get_vout(&cl, txid, btc(1.0), derived_desc.script_pubkey());
let mut txin = TxIn::default();
txin.previous_output = outpoint;
// set the sequence to a non-final number for the locktime transactions to be
// processed correctly.
// We waited 2 blocks, keep 1 for safety
txin.sequence = Sequence::from_height(1);
let txin = TxIn {
previous_output: outpoint,
// set the sequence to a non-final number for the locktime transactions to be
// processed correctly.
// We waited 2 blocks, keep 1 for safety
sequence: Sequence::from_height(1),
..Default::default()
};
psbt.unsigned_tx.input.push(txin);
// Get a new script pubkey from the node so that
// the node wallet tracks the receiving transaction
Expand Down

0 comments on commit 7ed6680

Please sign in to comment.