Skip to content

Commit b1eb82b

Browse files
committed
Merge #261: Fix clippy lints in integration_test
449f319 Add let _: () = ... to rpc calls that return null (Jamil Lambert, PhD) 1810527 Simplify assert on map key (Jamil Lambert, PhD) acd9332 Allow inconsistent digit grouping (Jamil Lambert, PhD) b5777a7 Refactor for loop declaration (Jamil Lambert, PhD) aabdaa3 Pass value instead of reference (Jamil Lambert, PhD) 71824cd change == false to ! (Jamil Lambert, PhD) fd8fa74 Remove redundant as u32 (Jamil Lambert, PhD) Pull request description: A new script to lint the integration tests is being added in #258. Run the script and fix all the lint errors. ACKs for top commit: tcharding: ACK 449f319 Tree-SHA512: 65f3429d227b05e4e54e252afb8b406100e743c1048fa05b86455d7020815b4966b3b1a2b291fb0c2064022b01dc90aed9a6f054a78b1840c81865bf42776adb
2 parents b7bb07f + 449f319 commit b1eb82b

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

integration_test/tests/mining.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ fn submit_empty_block(node: &Node, bt: &mtype::GetBlockTemplate) {
134134
version: block::Version::default(),
135135
prev_blockhash: bt.previous_block_hash,
136136
merkle_root: TxMerkleNode::all_zeros(),
137-
time: Ord::max(bt.min_time, std::time::UNIX_EPOCH.elapsed().expect("elapsed").as_secs() as u32) as u32,
137+
time: Ord::max(bt.min_time, std::time::UNIX_EPOCH.elapsed().expect("elapsed").as_secs() as u32),
138138
bits: bt.bits,
139139
nonce: 0,
140140
},
@@ -150,7 +150,7 @@ fn submit_empty_block(node: &Node, bt: &mtype::GetBlockTemplate) {
150150
}
151151
}
152152

153-
let _ = node.client.submit_block(&block).expect("submitblock");
153+
let _: () = node.client.submit_block(&block).expect("submitblock");
154154
}
155155

156156
// FIXME: Submitting this block returns 'inconclusive'.
@@ -208,7 +208,7 @@ fn mining__submit_block_with_dummy_coinbase(node: &Node, bt: &mtype::GetBlockTem
208208
}
209209
}
210210

211-
let _ = node.client.submit_block(&block).expect("submitblock");
211+
let _: () = node.client.submit_block(&block).expect("submitblock");
212212
}
213213

214214
#[cfg(not(feature = "v17"))]

integration_test/tests/network.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ fn network__set_ban() {
146146
fn network__set_network_active() {
147147
let node = Node::with_wallet(Wallet::None, &[]);
148148
let json: SetNetworkActive = node.client.set_network_active(false).expect("setnetworkactive false");
149-
assert!(json.0 == false);
149+
assert!(!json.0);
150150

151151
let json: SetNetworkActive = node.client.set_network_active(true).expect("setnetworkactive true");
152-
assert!(json.0 == true);
152+
assert!(json.0);
153153
}

integration_test/tests/raw_transactions.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ fn arbitrary_p2pkh_script() -> ScriptBuf {
221221
script::Builder::new()
222222
.push_opcode(OP_DUP)
223223
.push_opcode(OP_HASH160)
224-
.push_slice(&pubkey_hash)
224+
.push_slice(pubkey_hash)
225225
.push_opcode(OP_EQUALVERIFY)
226226
.push_opcode(OP_CHECKSIG)
227227
.into_script()
@@ -238,9 +238,9 @@ fn arbitrary_multisig_script() -> ScriptBuf {
238238
script::Builder::new()
239239
.push_opcode(OP_PUSHNUM_1)
240240
.push_opcode(OP_PUSHBYTES_33)
241-
.push_slice(&pk1)
241+
.push_slice(pk1)
242242
.push_opcode(OP_PUSHBYTES_33)
243-
.push_slice(&pk2)
243+
.push_slice(pk2)
244244
.push_opcode(OP_PUSHNUM_2)
245245
.push_opcode(OP_CHECKMULTISIG)
246246
.into_script()
@@ -388,7 +388,7 @@ fn raw_transactions__submit_package__modelled() {
388388
.expect("failed to submit package")
389389
.into_model()
390390
.expect("failed to submit package");
391-
for (_, tx_result) in &res.tx_results {
391+
for tx_result in res.tx_results.values() {
392392
assert!(tx_result.error.is_some());
393393
}
394394
assert!(res.replaced_transactions.is_empty());
@@ -416,7 +416,7 @@ fn raw_transactions__submit_package__modelled() {
416416
.expect("failed to submit package")
417417
.into_model()
418418
.expect("failed to submit package");
419-
for (_, tx_result) in &res.tx_results {
419+
for tx_result in res.tx_results.values() {
420420
assert!(tx_result.error.is_some());
421421
}
422422
assert!(res.replaced_transactions.is_empty());
@@ -546,6 +546,7 @@ fn create_sign_with_key_send(node: &Node) {
546546
// - fund_raw_transaction
547547
// - sign_raw_transaction_with_wallet (sign_raw_transaction was deprecated in v0.17).
548548
// - send_raw_transaction
549+
#[allow(clippy::inconsistent_digit_grouping)] // Sats to btc is a common use case.
549550
fn create_fund_sign_send(node: &Node) {
550551
let (_addr, _tx, txid, _tx_out, vout) = create_utxo(node);
551552

@@ -581,7 +582,7 @@ fn create_fund_sign_send(node: &Node) {
581582

582583
// Creates a transaction using client to do RPC call `create_raw_transaction`.
583584
fn create_a_raw_transaction(node: &Node) -> Transaction {
584-
let (_addr, _tx, txid, tx_out, vout) = create_utxo(&node);
585+
let (_addr, _tx, txid, tx_out, vout) = create_utxo(node);
585586

586587
// Assumes tx_out has a million sats in it.
587588
let spend_amount = Amount::from_sat(100_000);

integration_test/tests/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn util__derive_addresses__modelled() {
3838
// Use a valid, deterministic public key from the pubkey_sort test vectors and the checksum for it.
3939
let descriptor = "pkh(02ff12471208c14bd580709cb2358d98975247d8765f92bc25eab3b2763ed605f8)#sf4k0g3u";
4040

41-
let json: DeriveAddresses = node.client.derive_addresses(&descriptor).expect("deriveaddresses");
41+
let json: DeriveAddresses = node.client.derive_addresses(descriptor).expect("deriveaddresses");
4242
let res: Result<mtype::DeriveAddresses, _> = json.into_model();
4343
let _ = res.expect("DeriveAddresses into model");
4444
}
@@ -75,7 +75,7 @@ fn util__sign_message_with_priv_key__modelled() {
7575
// Derive the address from the private key
7676
let secp = bitcoin::secp256k1::Secp256k1::new();
7777
let pubkey = privkey.public_key(&secp);
78-
let addr = bitcoin::Address::p2pkh(&pubkey, privkey.network);
78+
let addr = bitcoin::Address::p2pkh(pubkey, privkey.network);
7979

8080
// Sign the message with the private key
8181
let json: SignMessageWithPrivKey = node

integration_test/tests/wallet.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ fn wallet__get_addresses_by_label__modelled() {
170170

171171
// sanity checks.
172172
assert!(!map.0.is_empty());
173-
assert!(map.0.get(&addr).is_some());
173+
assert!(map.0.contains_key(&addr));
174174
}
175175

176176
#[test]
@@ -305,7 +305,7 @@ fn wallet__import_address() {
305305
// Derive the address from the private key
306306
let secp = bitcoin::secp256k1::Secp256k1::new();
307307
let pubkey = privkey.public_key(&secp);
308-
let addr = bitcoin::Address::p2pkh(&pubkey, privkey.network);
308+
let addr = bitcoin::Address::p2pkh(pubkey, privkey.network);
309309

310310
let _: () = node.client.import_address(&addr).expect("importaddress");
311311
}

0 commit comments

Comments
 (0)