Skip to content

Commit 3565c7f

Browse files
committed
Merge #356: Update just fmt to format test and verify
e608af9 Run the formatter in verify (Jamil Lambert, PhD) e678deb Run the formatter in integration_test (Jamil Lambert, PhD) 7d2510c Update justfile to format tests and verify (Jamil Lambert, PhD) Pull request description: Running `just fmt` only formats modules in the workspace, and not `integration_test` and `verify`. - Add a line for both of these modules so that they are formatted when running `just fmt`. - Format `integration_test`. - Format `verfiy`. ACKs for top commit: tcharding: ACK e608af9 Tree-SHA512: ea753ec984e1aa406ac899bfa48e11860cc34af9e87ac48e6504260632643aa877ded2f39c9ec48191ce2b632438b01ee4ab9ea5e586cb920783e46fefab3ba4
2 parents 35f3714 + e608af9 commit 3565c7f

26 files changed

+600
-308
lines changed

integration_test/tests/blockchain.rs

Lines changed: 38 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
55
#![allow(non_snake_case)] // Test names intentionally use double underscore.
66

7-
use bitcoin::hex;
87
use bitcoin::consensus::encode;
8+
use bitcoin::hex;
99
use integration_test::{Node, NodeExt as _, Wallet};
1010
use node::client::client_sync;
11-
use node::vtype::*; // All the version specific types.
12-
use node::mtype;
13-
use node::{Input, Output};
11+
use node::vtype::*; // All the version specific types.
12+
use node::{mtype, Input, Output};
1413

1514
#[test]
1615
#[cfg(not(feature = "v25_and_below"))]
@@ -50,11 +49,13 @@ fn blockchain__get_block__modelled() {
5049
let node = Node::with_wallet(Wallet::None, &[]);
5150
let block_hash = node.client.best_block_hash().expect("best_block_hash failed");
5251

53-
let json: GetBlockVerboseZero = node.client.get_block_verbose_zero(block_hash).expect("getblock verbose=0");
52+
let json: GetBlockVerboseZero =
53+
node.client.get_block_verbose_zero(block_hash).expect("getblock verbose=0");
5454
let model: Result<mtype::GetBlockVerboseZero, encode::FromHexError> = json.into_model();
5555
model.unwrap();
5656

57-
let json: GetBlockVerboseOne = node.client.get_block_verbose_one(block_hash).expect("getblock verbose=1");
57+
let json: GetBlockVerboseOne =
58+
node.client.get_block_verbose_one(block_hash).expect("getblock verbose=1");
5859
let model: Result<mtype::GetBlockVerboseOne, GetBlockVerboseOneError> = json.into_model();
5960
model.unwrap();
6061

@@ -143,7 +144,8 @@ fn blockchain__get_block_header__modelled() {
143144
model.unwrap();
144145

145146
// verbose = true
146-
let json:GetBlockHeaderVerbose = node.client.get_block_header_verbose(&block_hash).expect("getblockheader");
147+
let json: GetBlockHeaderVerbose =
148+
node.client.get_block_header_verbose(&block_hash).expect("getblockheader");
147149
let model: Result<mtype::GetBlockHeaderVerbose, GetBlockHeaderVerboseError> = json.into_model();
148150
model.unwrap();
149151
}
@@ -169,7 +171,8 @@ fn getblockstats() {
169171

170172
// No need for explicit types, used explicitly in test below.
171173
let block_hash = node.client.best_block_hash().expect("best_block_hash failed");
172-
let json: GetBlockStats = node.client.get_block_stats_by_block_hash(&block_hash).expect("getblockstats");
174+
let json: GetBlockStats =
175+
node.client.get_block_stats_by_block_hash(&block_hash).expect("getblockstats");
173176
let model: Result<mtype::GetBlockStats, GetBlockStatsError> = json.into_model();
174177
model.unwrap();
175178
}
@@ -185,7 +188,8 @@ fn getblockstats_txindex() {
185188

186189
// Get block stats by block hash.
187190
let block_hash = node.client.best_block_hash().expect("best_block_hash failed");
188-
let json: GetBlockStats = node.client.get_block_stats_by_block_hash(&block_hash).expect("getblockstats");
191+
let json: GetBlockStats =
192+
node.client.get_block_stats_by_block_hash(&block_hash).expect("getblockstats");
189193
let model: Result<mtype::GetBlockStats, GetBlockStatsError> = json.into_model();
190194
model.unwrap();
191195
}
@@ -228,7 +232,8 @@ fn blockchain__get_deployment_info__modelled() {
228232
let node = Node::with_wallet(Wallet::None, &[]);
229233
let block_hash = node.client.best_block_hash().expect("best_block_hash failed");
230234

231-
let json: GetDeploymentInfo = node.client.get_deployment_info(&block_hash).expect("getdeploymentinfo");
235+
let json: GetDeploymentInfo =
236+
node.client.get_deployment_info(&block_hash).expect("getdeploymentinfo");
232237
let model: Result<mtype::GetDeploymentInfo, GetDeploymentInfoError> = json.into_model();
233238
model.unwrap();
234239
}
@@ -238,7 +243,8 @@ fn blockchain__get_deployment_info__modelled() {
238243
fn blockchain__get_descriptor_activity__modelled() {
239244
let node = Node::with_wallet(Wallet::None, &["-coinstatsindex=1", "-txindex=1"]);
240245

241-
let json: GetDescriptorActivity = node.client.get_descriptor_activity().expect("getdescriptoractivity");
246+
let json: GetDescriptorActivity =
247+
node.client.get_descriptor_activity().expect("getdescriptoractivity");
242248
let model: Result<mtype::GetDescriptorActivity, GetDescriptorActivityError> = json.into_model();
243249
model.unwrap();
244250
}
@@ -273,10 +279,8 @@ fn blockchain__get_mempool_ancestors_verbose__modelled() {
273279
let (_address, parent_txid) = node.create_mempool_transaction();
274280
let child_txid = create_child_spending_parent(&node, parent_txid);
275281

276-
let json: GetMempoolAncestorsVerbose = node
277-
.client
278-
.get_mempool_ancestors_verbose(child_txid)
279-
.expect("getmempoolancestors verbose");
282+
let json: GetMempoolAncestorsVerbose =
283+
node.client.get_mempool_ancestors_verbose(child_txid).expect("getmempoolancestors verbose");
280284
let model: Result<mtype::GetMempoolAncestorsVerbose, MapMempoolEntryError> = json.into_model();
281285
let ancestors = model.unwrap();
282286

@@ -309,7 +313,8 @@ fn blockchain__get_mempool_descendants_verbose__modelled() {
309313
.client
310314
.get_mempool_descendants_verbose(parent_txid)
311315
.expect("getmempooldescendants verbose");
312-
let model: Result<mtype::GetMempoolDescendantsVerbose, MapMempoolEntryError> = json.into_model();
316+
let model: Result<mtype::GetMempoolDescendantsVerbose, MapMempoolEntryError> =
317+
json.into_model();
313318
let descendants = model.unwrap();
314319

315320
assert!(descendants.0.contains_key(&child_txid));
@@ -406,17 +411,12 @@ fn blockchain__get_tx_spending_prevout__modelled() {
406411
let (_address2, txid_2) = node.create_mempool_transaction();
407412

408413
let inputs = vec![
409-
bitcoin::OutPoint {
410-
txid: txid_1,
411-
vout: 0,
412-
},
413-
bitcoin::OutPoint {
414-
txid: txid_2,
415-
vout: 0,
416-
},
414+
bitcoin::OutPoint { txid: txid_1, vout: 0 },
415+
bitcoin::OutPoint { txid: txid_2, vout: 0 },
417416
];
418417

419-
let json: GetTxSpendingPrevout = node.client.get_tx_spending_prevout(&inputs).expect("gettxspendingprevout");
418+
let json: GetTxSpendingPrevout =
419+
node.client.get_tx_spending_prevout(&inputs).expect("gettxspendingprevout");
420420
let model: Result<mtype::GetTxSpendingPrevout, GetTxSpendingPrevoutError> = json.into_model();
421421
let spending_prevout = model.unwrap();
422422

@@ -454,8 +454,15 @@ fn blockchain__prune_blockchain() {
454454
let node = Node::with_wallet(Wallet::Default, &["-prune=550"]);
455455
let address = node.client.new_address().expect("Failed to get new address");
456456

457-
let gen_result = node.client.generate_to_address(NBLOCKS, &address).expect("generate_to_address RPC call failed");
458-
assert_eq!(gen_result.0.len(), NBLOCKS, "generate_to_address did not return the expected number of block hashes");
457+
let gen_result = node
458+
.client
459+
.generate_to_address(NBLOCKS, &address)
460+
.expect("generate_to_address RPC call failed");
461+
assert_eq!(
462+
gen_result.0.len(),
463+
NBLOCKS,
464+
"generate_to_address did not return the expected number of block hashes"
465+
);
459466

460467
let target_height: u64 = 500;
461468

@@ -487,7 +494,8 @@ fn blockchain__scan_blocks_modelled() {
487494
// Arbitrary scan descriptor
488495
let scan_desc = "pkh(022afc20bf379bc96a2f4e9e63ffceb8652b2b6a097f63fbee6ecec2a49a48010e)";
489496

490-
let json: ScanBlocksStart = node.client.scan_blocks_start(&[scan_desc]).expect("scanblocks start");
497+
let json: ScanBlocksStart =
498+
node.client.scan_blocks_start(&[scan_desc]).expect("scanblocks start");
491499
let model: Result<mtype::ScanBlocksStart, ScanBlocksStartError> = json.into_model();
492500
model.unwrap();
493501

@@ -552,7 +560,8 @@ fn create_child_spending_parent(node: &Node, parent_txid: bitcoin::Txid) -> bitc
552560
.client
553561
.sign_raw_transaction_with_wallet(&funded_tx)
554562
.expect("signrawtransactionwithwallet");
555-
let sign_raw_transaction = signed.into_model().expect("SignRawTransactionWithWallet into model");
563+
let sign_raw_transaction =
564+
signed.into_model().expect("SignRawTransactionWithWallet into model");
556565
let child_txid = sign_raw_transaction.tx.compute_txid();
557566
let _ = node.client.send_raw_transaction(&sign_raw_transaction.tx).expect("sendrawtransaction");
558567

integration_test/tests/control.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#![allow(non_snake_case)] // Test names intentionally use double underscore.
66

77
use integration_test::{Node, NodeExt as _, Wallet};
8-
use node::vtype::*; // All the version specific types.
8+
use node::vtype::*; // All the version specific types.
99

1010
#[test]
1111
fn control__get_memory_info() {

integration_test/tests/generating.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
use bitcoin::hex;
88
use integration_test::{Node, NodeExt as _, Wallet};
9-
use node::vtype::*; // All the version specific types.
109
use node::mtype;
10+
use node::vtype::*; // All the version specific types.
1111

1212
#[test]
1313
#[cfg(not(feature = "v20_and_below"))]
@@ -29,15 +29,21 @@ fn generating__generate_block__modelled() {
2929
#[cfg(feature = "v24_and_below")]
3030
{
3131
// No `submit` argument
32-
json = node.client.generate_block(&mining_addr.to_string(), &transactions).expect("generateblock");
32+
json = node
33+
.client
34+
.generate_block(&mining_addr.to_string(), &transactions)
35+
.expect("generateblock");
3336
let model: Result<mtype::GenerateBlock, hex::HexToArrayError> = json.into_model();
3437
model.unwrap();
3538
}
3639

3740
#[cfg(not(feature = "v24_and_below"))]
3841
{
3942
// Check with `submit = false` so that `hex` is returned. v25 and later only.
40-
json = node.client.generate_block(&mining_addr.to_string(), &transactions, false).expect("generateblock");
43+
json = node
44+
.client
45+
.generate_block(&mining_addr.to_string(), &transactions, false)
46+
.expect("generateblock");
4147
let model: Result<mtype::GenerateBlock, GenerateBlockError> = json.into_model();
4248
model.unwrap();
4349
}
@@ -62,9 +68,10 @@ fn generating__generate_to_address__modelled() {
6268
let node = Node::with_wallet(Wallet::Default, &[]);
6369
let address = node.client.new_address().expect("failed to get new address");
6470

65-
let json: GenerateToAddress = node.client.generate_to_address(NBLOCKS, &address).expect("generatetoaddress");
71+
let json: GenerateToAddress =
72+
node.client.generate_to_address(NBLOCKS, &address).expect("generatetoaddress");
6673

67-
let model: Result<mtype::GenerateToAddress, hex::HexToArrayError> = json.into_model();
74+
let model: Result<mtype::GenerateToAddress, hex::HexToArrayError> = json.into_model();
6875
model.unwrap();
6976
}
7077

@@ -77,7 +84,8 @@ fn generating__generate_to_descriptor__modelled() {
7784
let address = node.client.new_address().expect("failed to get new address");
7885
let descriptor = format!("addr({})", address);
7986

80-
let json: GenerateToDescriptor = node.client.generate_to_descriptor(NBLOCKS, &descriptor).expect("generatetodescriptor");
87+
let json: GenerateToDescriptor =
88+
node.client.generate_to_descriptor(NBLOCKS, &descriptor).expect("generatetodescriptor");
8189
let model: Result<mtype::GenerateToDescriptor, hex::HexToArrayError> = json.into_model();
8290
model.unwrap();
8391
}

integration_test/tests/mining.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
use bitcoin::SignedAmount;
88
use integration_test::{Node, NodeExt as _, Wallet};
9-
use node::{mtype, TemplateRequest, TemplateRules};
10-
use node::vtype::*; // All the version specific types.
9+
use node::vtype::*;
10+
use node::{mtype, TemplateRequest, TemplateRules}; // All the version specific types.
1111

1212
#[test]
1313
fn mining__get_block_template__modelled() {
@@ -27,11 +27,11 @@ fn mining__get_block_template__modelled() {
2727
rules: vec![TemplateRules::Segwit],
2828
mode: Some("template".to_string()),
2929
..Default::default()
30-
}
30+
},
3131
};
3232

33-
let json: GetBlockTemplate = node1.client.get_block_template(&options)
34-
.expect("get_block_template RPC failed");
33+
let json: GetBlockTemplate =
34+
node1.client.get_block_template(&options).expect("get_block_template RPC failed");
3535
let model: Result<mtype::GetBlockTemplate, GetBlockTemplateError> = json.into_model();
3636
model.unwrap();
3737
}
@@ -82,7 +82,7 @@ fn mining__prioritise_transaction() {
8282
}
8383

8484
#[test]
85-
#[cfg(feature = "TODO")] // This test is flaky - no clue why.
85+
#[cfg(feature = "TODO")] // This test is flaky - no clue why.
8686
fn mining__submit_block() {
8787
// Requires connected nodes otherwise the RPC call errors.
8888
let (node1, node2, node3) = integration_test::three_node_network();
@@ -93,7 +93,8 @@ fn mining__submit_block() {
9393
node3.mine_a_block();
9494

9595
let options = TemplateRequest { rules: vec![TemplateRules::Segwit] };
96-
let json: GetBlockTemplate = node1.client.get_block_template(&options).expect("getblocktemplate");
96+
let json: GetBlockTemplate =
97+
node1.client.get_block_template(&options).expect("getblocktemplate");
9798
let template: mtype::GetBlockTemplate = json.into_model().unwrap();
9899

99100
submit_empty_block(&node1, &template);
@@ -106,8 +107,8 @@ fn mining__submit_block() {
106107
fn submit_empty_block(node: &Node, bt: &mtype::GetBlockTemplate) {
107108
use bitcoin::hashes::Hash as _;
108109
use bitcoin::{
109-
absolute, block, transaction, Amount, Block, OutPoint, ScriptBuf, Sequence,
110-
Transaction, TxIn, TxOut, Witness, ScriptHash, TxMerkleNode,
110+
absolute, block, transaction, Amount, Block, OutPoint, ScriptBuf, ScriptHash, Sequence,
111+
Transaction, TxIn, TxMerkleNode, TxOut, Witness,
111112
};
112113

113114
let txdata = vec![Transaction {
@@ -134,7 +135,10 @@ fn submit_empty_block(node: &Node, bt: &mtype::GetBlockTemplate) {
134135
version: block::Version::default(),
135136
prev_blockhash: bt.previous_block_hash,
136137
merkle_root: TxMerkleNode::all_zeros(),
137-
time: Ord::max(bt.min_time, std::time::UNIX_EPOCH.elapsed().expect("elapsed").as_secs() as u32),
138+
time: Ord::max(
139+
bt.min_time,
140+
std::time::UNIX_EPOCH.elapsed().expect("elapsed").as_secs() as u32,
141+
),
138142
bits: bt.bits,
139143
nonce: 0,
140144
},
@@ -158,8 +162,8 @@ fn submit_empty_block(node: &Node, bt: &mtype::GetBlockTemplate) {
158162
fn mining__submit_block_with_dummy_coinbase(node: &Node, bt: &mtype::GetBlockTemplate) {
159163
use bitcoin::hashes::Hash as _;
160164
use bitcoin::{
161-
absolute, block, transaction, Amount, Block, OutPoint, ScriptBuf, Sequence,
162-
Transaction, TxIn, TxOut, Witness, TxMerkleNode,
165+
absolute, block, transaction, Amount, Block, OutPoint, ScriptBuf, Sequence, Transaction,
166+
TxIn, TxMerkleNode, TxOut, Witness,
163167
};
164168

165169
let address = node.client.new_address().expect("failed to get new address");
@@ -218,8 +222,10 @@ fn mining__submit_header() {
218222
node.fund_wallet();
219223
node.mine_a_block();
220224

221-
let best_block = node.client.get_best_block_hash().expect("getbestblockhash").into_model().unwrap().0;
222-
let mut header = node.client.get_block_header(&best_block).expect("getblockheader").into_model().unwrap().0;
225+
let best_block =
226+
node.client.get_best_block_hash().expect("getbestblockhash").into_model().unwrap().0;
227+
let mut header =
228+
node.client.get_block_header(&best_block).expect("getblockheader").into_model().unwrap().0;
223229

224230
for _ in 1..=u32::MAX {
225231
header.nonce = header.nonce.wrapping_add(1);

integration_test/tests/network.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#![allow(non_snake_case)] // Test names intentionally use double underscore.
66

77
use integration_test::{Node, NodeExt as _, Wallet};
8-
use node::vtype::*; // All the version specific types.
9-
use node::{AddNodeCommand, mtype, SetBanCommand};
8+
use node::vtype::*; // All the version specific types.
9+
use node::{mtype, AddNodeCommand, SetBanCommand};
1010

1111
#[test]
1212
fn network__add_node() {
@@ -59,7 +59,7 @@ fn network__get_addr_man_info() {
5959
for (network_name, network_info) in &json.0 {
6060
assert!(!network_name.is_empty());
6161
assert_eq!(network_info.total, network_info.new + network_info.tried);
62-
};
62+
}
6363
}
6464

6565
#[test]
@@ -169,9 +169,11 @@ fn network__set_ban() {
169169
#[test]
170170
fn network__set_network_active() {
171171
let node = Node::with_wallet(Wallet::None, &[]);
172-
let json: SetNetworkActive = node.client.set_network_active(false).expect("setnetworkactive false");
172+
let json: SetNetworkActive =
173+
node.client.set_network_active(false).expect("setnetworkactive false");
173174
assert!(!json.0);
174175

175-
let json: SetNetworkActive = node.client.set_network_active(true).expect("setnetworkactive true");
176+
let json: SetNetworkActive =
177+
node.client.set_network_active(true).expect("setnetworkactive true");
176178
assert!(json.0);
177179
}

0 commit comments

Comments
 (0)