Skip to content

Commit 3a81438

Browse files
authored
Merge pull request #5063 from stacks-network/ci/fix-mock-miner-test
CI: fix mock miner test
2 parents 2feb784 + b04d121 commit 3a81438

File tree

2 files changed

+30
-21
lines changed

2 files changed

+30
-21
lines changed

testnet/stacks-node/src/run_loop/boot_nakamoto.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ impl BootRunLoop {
140140
naka_loop.start(burnchain_opt, mine_start, None)
141141
}
142142

143+
// configuring mutants::skip -- this function is covered through integration tests (this function
144+
// is pretty definitionally an integration, so thats unavoidable), and the integration tests
145+
// do not get counted in mutants coverage.
146+
#[cfg_attr(test, mutants::skip)]
143147
fn start_from_neon(&mut self, burnchain_opt: Option<Burnchain>, mine_start: u64) {
144148
let InnerLoops::Epoch2(ref mut neon_loop) = self.active_loop else {
145149
panic!("FATAL: unexpectedly invoked start_from_neon when active loop wasn't neon");
@@ -160,7 +164,12 @@ impl BootRunLoop {
160164
info!("Shutting down epoch-2/3 transition thread");
161165
return;
162166
}
163-
info!("Reached Epoch-3.0 boundary, starting nakamoto node");
167+
168+
info!(
169+
"Reached Epoch-3.0 boundary, starting nakamoto node";
170+
"with_neon_data" => data_to_naka.is_some(),
171+
"with_p2p_stack" => data_to_naka.as_ref().map(|x| x.peer_network.is_some()).unwrap_or(false)
172+
);
164173
termination_switch.store(true, Ordering::SeqCst);
165174
let naka = NakaRunLoop::new(
166175
self.config.clone(),

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7127,19 +7127,31 @@ fn mock_mining() {
71277127
}
71287128

71297129
let (mut naka_conf, _miner_account) = naka_neon_integration_conf(None);
7130-
let http_origin = format!("http://{}", &naka_conf.node.rpc_bind);
71317130
naka_conf.miner.wait_on_interim_blocks = Duration::from_secs(1);
71327131
let sender_sk = Secp256k1PrivateKey::new();
71337132
let sender_signer_sk = Secp256k1PrivateKey::new();
71347133
let sender_signer_addr = tests::to_addr(&sender_signer_sk);
71357134
let mut signers = TestSigners::new(vec![sender_signer_sk.clone()]);
7136-
let tenure_count = 5;
7137-
let inter_blocks_per_tenure = 9;
7135+
let tenure_count = 3;
7136+
let inter_blocks_per_tenure = 3;
71387137
// setup sender + recipient for some test stx transfers
71397138
// these are necessary for the interim blocks to get mined at all
71407139
let sender_addr = tests::to_addr(&sender_sk);
71417140
let send_amt = 100;
71427141
let send_fee = 180;
7142+
7143+
let node_1_rpc = 51024;
7144+
let node_1_p2p = 51023;
7145+
let node_2_rpc = 51026;
7146+
let node_2_p2p = 51025;
7147+
7148+
let localhost = "127.0.0.1";
7149+
naka_conf.node.rpc_bind = format!("{}:{}", localhost, node_1_rpc);
7150+
naka_conf.node.p2p_bind = format!("{}:{}", localhost, node_1_p2p);
7151+
naka_conf.node.data_url = format!("http://{}:{}", localhost, node_1_rpc);
7152+
naka_conf.node.p2p_address = format!("{}:{}", localhost, node_1_p2p);
7153+
let http_origin = format!("http://{}", &naka_conf.node.rpc_bind);
7154+
71437155
naka_conf.add_initial_balance(
71447156
PrincipalData::from(sender_addr.clone()).to_string(),
71457157
(send_amt + send_fee) * tenure_count * inter_blocks_per_tenure,
@@ -7212,11 +7224,7 @@ fn mock_mining() {
72127224
blind_signer(&naka_conf, &signers, proposals_submitted);
72137225

72147226
// Wait one block to confirm the VRF register, wait until a block commit is submitted
7215-
next_block_and(&mut btc_regtest_controller, 60, || {
7216-
let commits_count = commits_submitted.load(Ordering::SeqCst);
7217-
Ok(commits_count >= 1)
7218-
})
7219-
.unwrap();
7227+
wait_for_first_naka_block_commit(60, &commits_submitted);
72207228

72217229
let mut follower_conf = naka_conf.clone();
72227230
follower_conf.node.mock_mining = true;
@@ -7225,18 +7233,10 @@ fn mock_mining() {
72257233
follower_conf.node.seed = vec![0x01; 32];
72267234
follower_conf.node.local_peer_seed = vec![0x02; 32];
72277235

7228-
let mut rng = rand::thread_rng();
7229-
let mut buf = [0u8; 8];
7230-
rng.fill_bytes(&mut buf);
7231-
7232-
let rpc_port = u16::from_be_bytes(buf[0..2].try_into().unwrap()).saturating_add(1025) - 1; // use a non-privileged port between 1024 and 65534
7233-
let p2p_port = u16::from_be_bytes(buf[2..4].try_into().unwrap()).saturating_add(1025) - 1; // use a non-privileged port between 1024 and 65534
7234-
7235-
let localhost = "127.0.0.1";
7236-
follower_conf.node.rpc_bind = format!("{}:{}", &localhost, rpc_port);
7237-
follower_conf.node.p2p_bind = format!("{}:{}", &localhost, p2p_port);
7238-
follower_conf.node.data_url = format!("http://{}:{}", &localhost, rpc_port);
7239-
follower_conf.node.p2p_address = format!("{}:{}", &localhost, p2p_port);
7236+
follower_conf.node.rpc_bind = format!("{}:{}", localhost, node_2_rpc);
7237+
follower_conf.node.p2p_bind = format!("{}:{}", localhost, node_2_p2p);
7238+
follower_conf.node.data_url = format!("http://{}:{}", localhost, node_2_rpc);
7239+
follower_conf.node.p2p_address = format!("{}:{}", localhost, node_2_p2p);
72407240

72417241
let node_info = get_chain_info(&naka_conf);
72427242
follower_conf.node.add_bootstrap_node(

0 commit comments

Comments
 (0)