@@ -20,6 +20,7 @@ use std::sync::mpsc::sync_channel;
20
20
use std:: thread;
21
21
use std:: thread:: JoinHandle ;
22
22
23
+ use clarity:: vm:: types:: PrincipalData ;
23
24
use stacks_common:: address:: { AddressHashMode , C32_ADDRESS_VERSION_TESTNET_SINGLESIG } ;
24
25
use stacks_common:: codec:: { read_next, StacksMessageCodec } ;
25
26
use stacks_common:: types:: chainstate:: { StacksAddress , StacksPrivateKey , StacksPublicKey } ;
@@ -336,6 +337,49 @@ pub fn make_nakamoto_peers_from_invs<'a>(
336
337
prepare_len : u32 ,
337
338
bitvecs : Vec < Vec < bool > > ,
338
339
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 ) > ,
339
383
) -> ( TestPeer < ' a > , Vec < TestPeer < ' a > > ) {
340
384
for bitvec in bitvecs. iter ( ) {
341
385
assert_eq ! ( bitvec. len( ) as u32 , rc_len) ;
@@ -415,10 +459,11 @@ pub fn make_nakamoto_peers_from_invs<'a>(
415
459
0 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 2 , 2 , 2 , 2 , 2 , 2 , 3 , 3 , 3 , 3 , 3 , 3 ,
416
460
] ) ;
417
461
462
+ initial_balances. push ( ( addr. into ( ) , 1_000_000 ) ) ;
418
463
let plan = NakamotoBootPlan :: new ( test_name)
419
464
. with_private_key ( private_key)
420
465
. with_pox_constants ( rc_len, prepare_len)
421
- . with_initial_balances ( vec ! [ ( addr . into ( ) , 1_000_000 ) ] )
466
+ . with_initial_balances ( initial_balances )
422
467
. with_extra_peers ( num_peers)
423
468
. with_test_signers ( test_signers)
424
469
. with_test_stackers ( test_stackers) ;
0 commit comments