Skip to content

Commit c5880c6

Browse files
committed
chore: remove infinite loop in signer during tests
1 parent 18c70b4 commit c5880c6

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

stacks-signer/src/v0/signer.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use std::collections::HashMap;
1616
use std::fmt::Debug;
1717
use std::sync::mpsc::Sender;
18+
use std::time::{Duration, Instant};
1819

1920
use blockstack_lib::chainstate::nakamoto::{NakamotoBlock, NakamotoBlockHeader};
2021
use blockstack_lib::net::api::postblock_proposal::{
@@ -185,27 +186,25 @@ impl SignerTrait<SignerMessage> for Signer {
185186
);
186187
}
187188
SignerMessage::BlockPushed(b) => {
188-
let block_push_result = stacks_client.post_block(b);
189-
if let Err(ref e) = &block_push_result {
190-
warn!(
191-
"{self}: Failed to post block {} (id {}): {e:?}",
192-
&b.header.signer_signature_hash(),
193-
&b.block_id()
194-
);
195-
};
196189
// This will infinitely loop until the block is acknowledged by the node
197190
info!(
198191
"{self}: Got block pushed message";
199192
"block_id" => %b.block_id(),
200193
"signer_sighash" => %b.header.signer_signature_hash(),
201194
);
195+
let start_time = Instant::now();
202196
loop {
203197
match stacks_client.post_block(b) {
204198
Ok(block_push_result) => {
205199
debug!("{self}: Block pushed to stacks node: {block_push_result:?}");
206200
break;
207201
}
208202
Err(e) => {
203+
if cfg!(test)
204+
&& start_time.elapsed() > Duration::from_secs(30)
205+
{
206+
panic!("{self}: Timed out in test while pushing block to stacks node: {e}");
207+
}
209208
warn!("{self}: Failed to push block to stacks node: {e}. Retrying...");
210209
}
211210
};

0 commit comments

Comments
 (0)