@@ -151,3 +151,58 @@ impl Command<SignerTestState, SignerTestContext>
151
151
) )
152
152
}
153
153
}
154
+
155
+ pub struct MineBitcoinBlock {
156
+ miners : Arc < Mutex < MultipleMinerTest > > ,
157
+ timeout_secs : u64 ,
158
+ }
159
+
160
+ impl MineBitcoinBlock {
161
+ pub fn new ( miners : Arc < Mutex < MultipleMinerTest > > , timeout_secs : u64 ) -> Self {
162
+ Self {
163
+ miners,
164
+ timeout_secs,
165
+ }
166
+ }
167
+ }
168
+
169
+ impl Command < SignerTestState , SignerTestContext > for MineBitcoinBlock {
170
+ fn check ( & self , _state : & SignerTestState ) -> bool {
171
+ info ! ( "Checking: Mining tenure. Result: {:?}" , true ) ;
172
+ true
173
+ }
174
+
175
+ fn apply ( & self , _state : & mut SignerTestState ) {
176
+ info ! (
177
+ "Applying: Mining tenure and waiting for it for {:?} seconds" ,
178
+ self . timeout_secs
179
+ ) ;
180
+
181
+ let sortdb = {
182
+ let miners = self . miners . lock ( ) . unwrap ( ) ;
183
+ let ( conf_1, _) = miners. get_node_configs ( ) ;
184
+ let burnchain = conf_1. get_burnchain ( ) ;
185
+ let sortdb = burnchain. open_sortition_db ( true ) . unwrap ( ) ;
186
+ sortdb
187
+ } ;
188
+
189
+ {
190
+ let mut miners = self . miners . lock ( ) . unwrap ( ) ;
191
+ miners
192
+ . mine_bitcoin_blocks_and_confirm ( & sortdb, 1 , self . timeout_secs )
193
+ . expect ( "Failed to mine BTC block" ) ;
194
+ }
195
+ }
196
+
197
+ fn label ( & self ) -> String {
198
+ "MINE_BITCOIN_BLOCK" . to_string ( )
199
+ }
200
+
201
+ fn build (
202
+ ctx : Arc < SignerTestContext > ,
203
+ ) -> impl Strategy < Value = CommandWrapper < SignerTestState , SignerTestContext > > {
204
+ ( 60u64 ..90u64 ) . prop_map ( move |timeout_secs| {
205
+ CommandWrapper :: new ( MineBitcoinBlock :: new ( ctx. miners . clone ( ) , timeout_secs) )
206
+ } )
207
+ }
208
+ }
0 commit comments