Skip to content

Commit 8ddddae

Browse files
committed
Add positive integer for pox_sync_sample_secs and wait_on_interim_blocks for multiple_miners* tests
Signed-off-by: Jacinta Ferrant <[email protected]>
1 parent 0b4f3b2 commit 8ddddae

File tree

5 files changed

+37
-45
lines changed

5 files changed

+37
-45
lines changed

stacks-signer/src/client/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,6 @@ pub enum ClientError {
8989
/// Invalid response from the stacks node
9090
#[error("Invalid response from the stacks node: {0}")]
9191
InvalidResponse(String),
92-
/// A successful sortition has not occurred yet
93-
#[error("The Stacks chain has not processed any successful sortitions yet")]
94-
NoSortitionOnChain,
9592
/// A successful sortition's info response should be parseable into a SortitionState
9693
#[error("A successful sortition's info response should be parseable into a SortitionState")]
9794
UnexpectedSortitionInfo,

stacks-signer/src/client/stacks_client.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use blockstack_lib::net::api::get_tenures_fork_info::{
3333
use blockstack_lib::net::api::getaccount::AccountEntryResponse;
3434
use blockstack_lib::net::api::getpoxinfo::RPCPoxInfoData;
3535
use blockstack_lib::net::api::getsortition::{SortitionInfo, RPC_SORTITION_INFO_PATH};
36-
use blockstack_lib::net::api::getstackers::{GetStackersErrors, GetStackersResponse};
36+
use blockstack_lib::net::api::getstackers::GetStackersResponse;
3737
use blockstack_lib::net::api::postblock::StacksBlockAcceptedData;
3838
use blockstack_lib::net::api::postblock_proposal::NakamotoBlockProposal;
3939
use blockstack_lib::net::api::postblock_v3;
@@ -84,6 +84,7 @@ pub struct StacksClient {
8484

8585
#[derive(Deserialize)]
8686
struct GetStackersErrorResp {
87+
#[allow(dead_code)]
8788
err_type: String,
8889
err_msg: String,
8990
}
@@ -655,14 +656,11 @@ impl StacksClient {
655656
warn!("Failed to parse the GetStackers error response: {e}");
656657
backoff::Error::permanent(e.into())
657658
})?;
658-
if error_data.err_type == GetStackersErrors::NOT_AVAILABLE_ERR_TYPE {
659-
Err(backoff::Error::permanent(ClientError::NoSortitionOnChain))
660-
} else {
661-
warn!("Got error response ({status}): {}", error_data.err_msg);
662-
Err(backoff::Error::permanent(ClientError::RequestFailure(
663-
status,
664-
)))
665-
}
659+
660+
warn!("Got error response ({status}): {}", error_data.err_msg);
661+
Err(backoff::Error::permanent(ClientError::RequestFailure(
662+
status,
663+
)))
666664
};
667665
let stackers_response =
668666
retry_with_exponential_backoff::<_, ClientError, GetStackersResponse>(send_request)?;

testnet/stacks-node/src/tests/nakamoto_integrations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ pub fn naka_neon_integration_conf(seed: Option<&[u8]>) -> (Config, StacksAddress
584584

585585
conf.burnchain.magic_bytes = MagicBytes::from(['T' as u8, '3' as u8].as_ref());
586586
conf.burnchain.poll_time_secs = 1;
587-
conf.node.pox_sync_sample_secs = 0;
587+
conf.node.pox_sync_sample_secs = 5;
588588

589589
conf.miner.first_attempt_time_ms = i64::max_value() as u64;
590590
conf.miner.subsequent_attempt_time_ms = i64::max_value() as u64;

testnet/stacks-node/src/tests/signer/mod.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -375,14 +375,10 @@ impl<S: Signer<T> + Send + 'static, T: SignerEventTrait + 'static> SignerTest<Sp
375375
)
376376
.unwrap();
377377

378-
let t_start = Instant::now();
379-
while test_observer::get_mined_nakamoto_blocks().is_empty() {
380-
assert!(
381-
t_start.elapsed() < timeout,
382-
"Timed out while waiting for mined nakamoto block event"
383-
);
384-
thread::sleep(Duration::from_secs(1));
385-
}
378+
wait_for(timeout.as_secs(), || {
379+
Ok(!test_observer::get_mined_nakamoto_blocks().is_empty())
380+
})
381+
.unwrap();
386382
let mined_block_elapsed_time = mined_block_time.elapsed();
387383
info!(
388384
"Nakamoto block mine time elapsed: {:?}",

testnet/stacks-node/src/tests/signer/v0.rs

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,8 +1369,9 @@ fn multiple_miners() {
13691369
let node_2_rpc = 51026;
13701370
let node_2_p2p = 51025;
13711371

1372-
let node_1_rpc_bind = format!("127.0.0.1:{}", node_1_rpc);
1373-
let node_2_rpc_bind = format!("127.0.0.1:{}", node_2_rpc);
1372+
let localhost = "127.0.0.1";
1373+
let node_1_rpc_bind = format!("{localhost}:{node_1_rpc}");
1374+
let node_2_rpc_bind = format!("{localhost}:{node_2_rpc}");
13741375
let mut node_2_listeners = Vec::new();
13751376

13761377
// partition the signer set so that ~half are listening and using node 1 for RPC and events,
@@ -1388,11 +1389,12 @@ fn multiple_miners() {
13881389
signer_config.node_host = node_host.to_string();
13891390
},
13901391
|config| {
1391-
let localhost = "127.0.0.1";
1392-
config.node.rpc_bind = format!("{}:{}", localhost, node_1_rpc);
1393-
config.node.p2p_bind = format!("{}:{}", localhost, node_1_p2p);
1394-
config.node.data_url = format!("http://{}:{}", localhost, node_1_rpc);
1395-
config.node.p2p_address = format!("{}:{}", localhost, node_1_p2p);
1392+
config.node.rpc_bind = format!("{localhost}:{node_1_rpc}");
1393+
config.node.p2p_bind = format!("{localhost}:{node_1_p2p}");
1394+
config.node.data_url = format!("http://{localhost}:{node_1_rpc}");
1395+
config.node.p2p_address = format!("{localhost}:{node_1_p2p}");
1396+
config.node.pox_sync_sample_secs = 5;
1397+
config.miner.wait_on_interim_blocks = Duration::from_secs(5);
13961398

13971399
config.node.seed = btc_miner_1_seed.clone();
13981400
config.node.local_peer_seed = btc_miner_1_seed.clone();
@@ -1419,11 +1421,10 @@ fn multiple_miners() {
14191421
);
14201422
let conf = signer_test.running_nodes.conf.clone();
14211423
let mut conf_node_2 = conf.clone();
1422-
let localhost = "127.0.0.1";
1423-
conf_node_2.node.rpc_bind = format!("{}:{}", localhost, node_2_rpc);
1424-
conf_node_2.node.p2p_bind = format!("{}:{}", localhost, node_2_p2p);
1425-
conf_node_2.node.data_url = format!("http://{}:{}", localhost, node_2_rpc);
1426-
conf_node_2.node.p2p_address = format!("{}:{}", localhost, node_2_p2p);
1424+
conf_node_2.node.rpc_bind = format!("{localhost}:{node_2_rpc}");
1425+
conf_node_2.node.p2p_bind = format!("{localhost}:{node_2_p2p}");
1426+
conf_node_2.node.data_url = format!("http://{localhost}:{node_2_rpc}");
1427+
conf_node_2.node.p2p_address = format!("{localhost}:{node_2_p2p}");
14271428
conf_node_2.node.seed = btc_miner_2_seed.clone();
14281429
conf_node_2.burnchain.local_mining_public_key = Some(btc_miner_2_pk.to_hex());
14291430
conf_node_2.node.local_peer_seed = btc_miner_2_seed.clone();
@@ -3317,8 +3318,9 @@ fn multiple_miners_with_nakamoto_blocks() {
33173318
let node_2_rpc = 51026;
33183319
let node_2_p2p = 51025;
33193320

3320-
let node_1_rpc_bind = format!("127.0.0.1:{}", node_1_rpc);
3321-
let node_2_rpc_bind = format!("127.0.0.1:{}", node_2_rpc);
3321+
let localhost = "127.0.0.1";
3322+
let node_1_rpc_bind = format!("{localhost}:{node_1_rpc}");
3323+
let node_2_rpc_bind = format!("{localhost}:{node_2_rpc}");
33223324
let mut node_2_listeners = Vec::new();
33233325

33243326
// partition the signer set so that ~half are listening and using node 1 for RPC and events,
@@ -3338,11 +3340,11 @@ fn multiple_miners_with_nakamoto_blocks() {
33383340
signer_config.node_host = node_host.to_string();
33393341
},
33403342
|config| {
3341-
let localhost = "127.0.0.1";
3342-
config.node.rpc_bind = format!("{}:{}", localhost, node_1_rpc);
3343-
config.node.p2p_bind = format!("{}:{}", localhost, node_1_p2p);
3344-
config.node.data_url = format!("http://{}:{}", localhost, node_1_rpc);
3345-
config.node.p2p_address = format!("{}:{}", localhost, node_1_p2p);
3343+
config.node.rpc_bind = format!("{localhost}:{node_1_rpc}");
3344+
config.node.p2p_bind = format!("{localhost}:{node_1_p2p}");
3345+
config.node.data_url = format!("http://{localhost}:{node_1_rpc}");
3346+
config.node.p2p_address = format!("{localhost}:{node_1_p2p}");
3347+
config.miner.wait_on_interim_blocks = Duration::from_secs(5);
33463348

33473349
config.node.seed = btc_miner_1_seed.clone();
33483350
config.node.local_peer_seed = btc_miner_1_seed.clone();
@@ -3371,11 +3373,10 @@ fn multiple_miners_with_nakamoto_blocks() {
33713373

33723374
let conf = signer_test.running_nodes.conf.clone();
33733375
let mut conf_node_2 = conf.clone();
3374-
let localhost = "127.0.0.1";
3375-
conf_node_2.node.rpc_bind = format!("{}:{}", localhost, node_2_rpc);
3376-
conf_node_2.node.p2p_bind = format!("{}:{}", localhost, node_2_p2p);
3377-
conf_node_2.node.data_url = format!("http://{}:{}", localhost, node_2_rpc);
3378-
conf_node_2.node.p2p_address = format!("{}:{}", localhost, node_2_p2p);
3376+
conf_node_2.node.rpc_bind = format!("{localhost}:{node_2_rpc}");
3377+
conf_node_2.node.p2p_bind = format!("{localhost}:{node_2_p2p}");
3378+
conf_node_2.node.data_url = format!("http://{localhost}:{node_2_rpc}");
3379+
conf_node_2.node.p2p_address = format!("{localhost}:{node_2_p2p}");
33793380
conf_node_2.node.seed = btc_miner_2_seed.clone();
33803381
conf_node_2.burnchain.local_mining_public_key = Some(btc_miner_2_pk.to_hex());
33813382
conf_node_2.node.local_peer_seed = btc_miner_2_seed.clone();

0 commit comments

Comments
 (0)