Skip to content

Commit 3dd68dd

Browse files
committed
chore: Apply Clippy lint vec_init_then_push
1 parent bbde40f commit 3dd68dd

File tree

2 files changed

+59
-72
lines changed

2 files changed

+59
-72
lines changed

stackslib/src/chainstate/nakamoto/coordinator/tests.rs

Lines changed: 49 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -3234,54 +3234,53 @@ fn test_stacks_on_burnchain_ops() {
32343234
let (mut burn_ops, mut tenure_change, miner_key) =
32353235
peer.begin_nakamoto_tenure(TenureChangeCause::BlockFound);
32363236

3237-
let mut new_burn_ops = vec![];
3238-
new_burn_ops.push(BlockstackOperationType::DelegateStx(DelegateStxOp {
3239-
sender: addr.clone(),
3240-
delegate_to: recipient_addr.clone(),
3241-
reward_addr: None,
3242-
delegated_ustx: 1,
3243-
until_burn_height: None,
3244-
3245-
// mocked
3246-
txid: Txid([i; 32]),
3247-
vtxindex: 11,
3248-
block_height: block_height + 1,
3249-
burn_header_hash: BurnchainHeaderHash([0x00; 32]),
3250-
}));
3251-
new_burn_ops.push(BlockstackOperationType::StackStx(StackStxOp {
3252-
sender: addr.clone(),
3253-
reward_addr: PoxAddress::Standard(
3254-
recipient_addr.clone(),
3255-
Some(AddressHashMode::SerializeP2PKH),
3256-
),
3257-
stacked_ustx: 1,
3258-
num_cycles: 1,
3259-
signer_key: Some(StacksPublicKeyBuffer::from_public_key(
3260-
&StacksPublicKey::from_private(&recipient_private_key),
3261-
)),
3262-
max_amount: Some(1),
3263-
auth_id: Some(i as u32),
3264-
3265-
// mocked
3266-
txid: Txid([i | 0x80; 32]),
3267-
vtxindex: 12,
3268-
block_height: block_height + 1,
3269-
burn_header_hash: BurnchainHeaderHash([0x00; 32]),
3270-
}));
3271-
new_burn_ops.push(BlockstackOperationType::TransferStx(TransferStxOp {
3272-
sender: addr.clone(),
3273-
recipient: recipient_addr.clone(),
3274-
transfered_ustx: 1,
3275-
memo: vec![0x2],
3276-
3277-
// mocked
3278-
txid: Txid([i | 0x40; 32]),
3279-
vtxindex: 13,
3280-
block_height: block_height + 1,
3281-
burn_header_hash: BurnchainHeaderHash([0x00; 32]),
3282-
}));
3283-
new_burn_ops.push(BlockstackOperationType::VoteForAggregateKey(
3284-
VoteForAggregateKeyOp {
3237+
let mut new_burn_ops = vec![
3238+
BlockstackOperationType::DelegateStx(DelegateStxOp {
3239+
sender: addr.clone(),
3240+
delegate_to: recipient_addr.clone(),
3241+
reward_addr: None,
3242+
delegated_ustx: 1,
3243+
until_burn_height: None,
3244+
3245+
// mocked
3246+
txid: Txid([i; 32]),
3247+
vtxindex: 11,
3248+
block_height: block_height + 1,
3249+
burn_header_hash: BurnchainHeaderHash([0x00; 32]),
3250+
}),
3251+
BlockstackOperationType::StackStx(StackStxOp {
3252+
sender: addr.clone(),
3253+
reward_addr: PoxAddress::Standard(
3254+
recipient_addr.clone(),
3255+
Some(AddressHashMode::SerializeP2PKH),
3256+
),
3257+
stacked_ustx: 1,
3258+
num_cycles: 1,
3259+
signer_key: Some(StacksPublicKeyBuffer::from_public_key(
3260+
&StacksPublicKey::from_private(&recipient_private_key),
3261+
)),
3262+
max_amount: Some(1),
3263+
auth_id: Some(i as u32),
3264+
3265+
// mocked
3266+
txid: Txid([i | 0x80; 32]),
3267+
vtxindex: 12,
3268+
block_height: block_height + 1,
3269+
burn_header_hash: BurnchainHeaderHash([0x00; 32]),
3270+
}),
3271+
BlockstackOperationType::TransferStx(TransferStxOp {
3272+
sender: addr.clone(),
3273+
recipient: recipient_addr.clone(),
3274+
transfered_ustx: 1,
3275+
memo: vec![0x2],
3276+
3277+
// mocked
3278+
txid: Txid([i | 0x40; 32]),
3279+
vtxindex: 13,
3280+
block_height: block_height + 1,
3281+
burn_header_hash: BurnchainHeaderHash([0x00; 32]),
3282+
}),
3283+
BlockstackOperationType::VoteForAggregateKey(VoteForAggregateKeyOp {
32853284
sender: addr.clone(),
32863285
aggregate_key: StacksPublicKeyBuffer::from_public_key(
32873286
&StacksPublicKey::from_private(&agg_private_key),
@@ -3298,8 +3297,8 @@ fn test_stacks_on_burnchain_ops() {
32983297
vtxindex: 14,
32993298
block_height: block_height + 1,
33003299
burn_header_hash: BurnchainHeaderHash([0x00; 32]),
3301-
},
3302-
));
3300+
}),
3301+
];
33033302

33043303
extra_burn_ops.push(new_burn_ops.clone());
33053304
burn_ops.append(&mut new_burn_ops);

stackslib/src/net/api/tests/postblock_v3.rs

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -178,19 +178,12 @@ fn handle_req_accepted() {
178178
|_| true,
179179
);
180180
let next_block_id = next_block.block_id();
181-
let mut requests = vec![];
182-
183-
// post the block
184-
requests.push(StacksHttpRequest::new_post_block_v3(
185-
addr.into(),
186-
&next_block,
187-
));
188-
189-
// idempotent
190-
requests.push(StacksHttpRequest::new_post_block_v3(
191-
addr.into(),
192-
&next_block,
193-
));
181+
let requests = vec![
182+
// post the block
183+
StacksHttpRequest::new_post_block_v3(addr.into(), &next_block),
184+
// idempotent
185+
StacksHttpRequest::new_post_block_v3(addr.into(), &next_block),
186+
];
194187

195188
let mut responses = rpc_test.run(requests);
196189

@@ -229,29 +222,24 @@ fn handle_req_without_trailing_accepted() {
229222
|_| true,
230223
);
231224
let next_block_id = next_block.block_id();
232-
let mut requests = vec![];
233-
234-
// post the block
235-
requests.push(
225+
let requests = vec![
226+
// post the block
236227
StacksHttpRequest::new_for_peer(
237228
addr.into(),
238229
"POST".into(),
239230
path_without_slash.into(),
240231
HttpRequestContents::new().payload_stacks(&next_block),
241232
)
242233
.unwrap(),
243-
);
244-
245-
// idempotent
246-
requests.push(
234+
// idempotent
247235
StacksHttpRequest::new_for_peer(
248236
addr.into(),
249237
"POST".into(),
250238
path_without_slash.into(),
251239
HttpRequestContents::new().payload_stacks(&next_block),
252240
)
253241
.unwrap(),
254-
);
242+
];
255243
let mut responses = rpc_test.run(requests);
256244

257245
let response = responses.remove(0);

0 commit comments

Comments
 (0)