Skip to content

Commit d0f056b

Browse files
committed
feat: take additional balances
1 parent 5ee77d1 commit d0f056b

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

stackslib/src/net/tests/inv/nakamoto.rs

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use std::sync::mpsc::sync_channel;
2020
use std::thread;
2121
use std::thread::JoinHandle;
2222

23+
use clarity::vm::types::PrincipalData;
2324
use stacks_common::address::{AddressHashMode, C32_ADDRESS_VERSION_TESTNET_SINGLESIG};
2425
use stacks_common::codec::{read_next, StacksMessageCodec};
2526
use stacks_common::types::chainstate::{StacksAddress, StacksPrivateKey, StacksPublicKey};
@@ -336,6 +337,49 @@ pub fn make_nakamoto_peers_from_invs<'a>(
336337
prepare_len: u32,
337338
bitvecs: Vec<Vec<bool>>,
338339
num_peers: usize,
340+
) -> (TestPeer<'a>, Vec<TestPeer<'a>>) {
341+
inner_make_nakamoto_peers_from_invs(
342+
test_name,
343+
observer,
344+
rc_len,
345+
prepare_len,
346+
bitvecs,
347+
num_peers,
348+
vec![],
349+
)
350+
}
351+
352+
/// NOTE: The second return value does _not_ need `<'a>`, since `observer` is never installed into
353+
/// the peers here. However, it appears unavoidable to the borrow-checker.
354+
pub fn make_nakamoto_peers_from_invs_and_balances<'a>(
355+
test_name: &str,
356+
observer: &'a TestEventObserver,
357+
rc_len: u32,
358+
prepare_len: u32,
359+
bitvecs: Vec<Vec<bool>>,
360+
num_peers: usize,
361+
initial_balances: Vec<(PrincipalData, u64)>,
362+
) -> (TestPeer<'a>, Vec<TestPeer<'a>>) {
363+
inner_make_nakamoto_peers_from_invs(
364+
test_name,
365+
observer,
366+
rc_len,
367+
prepare_len,
368+
bitvecs,
369+
num_peers,
370+
initial_balances,
371+
)
372+
}
373+
374+
/// Make peers from inventories and balances
375+
fn inner_make_nakamoto_peers_from_invs<'a>(
376+
test_name: &str,
377+
observer: &'a TestEventObserver,
378+
rc_len: u32,
379+
prepare_len: u32,
380+
bitvecs: Vec<Vec<bool>>,
381+
num_peers: usize,
382+
mut initial_balances: Vec<(PrincipalData, u64)>,
339383
) -> (TestPeer<'a>, Vec<TestPeer<'a>>) {
340384
for bitvec in bitvecs.iter() {
341385
assert_eq!(bitvec.len() as u32, rc_len);
@@ -415,10 +459,11 @@ pub fn make_nakamoto_peers_from_invs<'a>(
415459
0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3,
416460
]);
417461

462+
initial_balances.push((addr.into(), 1_000_000));
418463
let plan = NakamotoBootPlan::new(test_name)
419464
.with_private_key(private_key)
420465
.with_pox_constants(rc_len, prepare_len)
421-
.with_initial_balances(vec![(addr.into(), 1_000_000)])
466+
.with_initial_balances(initial_balances)
422467
.with_extra_peers(num_peers)
423468
.with_test_signers(test_signers)
424469
.with_test_stackers(test_stackers);

0 commit comments

Comments
 (0)