@@ -2275,6 +2275,10 @@ pub mod test {
2275
2275
> ,
2276
2276
/// list of malleablized blocks produced when mining.
2277
2277
pub malleablized_blocks : Vec < NakamotoBlock > ,
2278
+ pub mine_malleablized_blocks : bool ,
2279
+ /// tenure-start block of tenure to mine on.
2280
+ /// gets consumed on the call to begin_nakamoto_tenure
2281
+ pub nakamoto_parent_tenure_opt : Option < Vec < NakamotoBlock > > ,
2278
2282
}
2279
2283
2280
2284
impl < ' a > TestPeer < ' a > {
@@ -2689,6 +2693,8 @@ pub mod test {
2689
2693
coord : coord,
2690
2694
indexer : Some ( indexer) ,
2691
2695
malleablized_blocks : vec ! [ ] ,
2696
+ mine_malleablized_blocks : true ,
2697
+ nakamoto_parent_tenure_opt : None ,
2692
2698
}
2693
2699
}
2694
2700
@@ -3509,6 +3515,10 @@ pub mod test {
3509
3515
self . sortdb . as_mut ( ) . unwrap ( )
3510
3516
}
3511
3517
3518
+ pub fn sortdb_ref ( & mut self ) -> & SortitionDB {
3519
+ self . sortdb . as_ref ( ) . unwrap ( )
3520
+ }
3521
+
3512
3522
pub fn with_db_state < F , R > ( & mut self , f : F ) -> Result < R , net_error >
3513
3523
where
3514
3524
F : FnOnce (
@@ -4198,6 +4208,43 @@ pub mod test {
4198
4208
}
4199
4209
}
4200
4210
}
4211
+
4212
+ /// Set the nakamoto tenure to mine on
4213
+ pub fn mine_nakamoto_on ( & mut self , parent_tenure : Vec < NakamotoBlock > ) {
4214
+ self . nakamoto_parent_tenure_opt = Some ( parent_tenure) ;
4215
+ }
4216
+
4217
+ /// Clear the tenure to mine on. This causes the miner to build on the canonical tip
4218
+ pub fn mine_nakamoto_on_canonical_tip ( & mut self ) {
4219
+ self . nakamoto_parent_tenure_opt = None ;
4220
+ }
4221
+
4222
+ /// Get an account off of a tip
4223
+ pub fn get_account (
4224
+ & mut self ,
4225
+ tip : & StacksBlockId ,
4226
+ account : & PrincipalData ,
4227
+ ) -> StacksAccount {
4228
+ let sortdb = self . sortdb . take ( ) . expect ( "FATAL: sortdb not restored" ) ;
4229
+ let mut node = self
4230
+ . stacks_node
4231
+ . take ( )
4232
+ . expect ( "FATAL: chainstate not restored" ) ;
4233
+
4234
+ let acct = node
4235
+ . chainstate
4236
+ . maybe_read_only_clarity_tx (
4237
+ & sortdb. index_handle_at_block ( & node. chainstate , tip) . unwrap ( ) ,
4238
+ tip,
4239
+ |clarity_tx| StacksChainState :: get_account ( clarity_tx, account) ,
4240
+ )
4241
+ . unwrap ( )
4242
+ . unwrap ( ) ;
4243
+
4244
+ self . sortdb = Some ( sortdb) ;
4245
+ self . stacks_node = Some ( node) ;
4246
+ acct
4247
+ }
4201
4248
}
4202
4249
4203
4250
pub fn to_addr ( sk : & StacksPrivateKey ) -> StacksAddress {
0 commit comments