From 2d1f1aeb8f4493c6dd077de639d9a5dad027c03e Mon Sep 17 00:00:00 2001 From: Jacinta Ferrant Date: Mon, 5 Feb 2024 12:33:23 -0800 Subject: [PATCH] Use the same slot id for retrieving the proposed block Signed-off-by: Jacinta Ferrant --- .../stacks-node/src/tests/nakamoto_integrations.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/testnet/stacks-node/src/tests/nakamoto_integrations.rs b/testnet/stacks-node/src/tests/nakamoto_integrations.rs index 962990067e..a2129475fe 100644 --- a/testnet/stacks-node/src/tests/nakamoto_integrations.rs +++ b/testnet/stacks-node/src/tests/nakamoto_integrations.rs @@ -1448,20 +1448,24 @@ fn miner_writes_proposed_block_to_stackerdb() { .expect("Failed to parse socket"); let sortdb = naka_conf.get_burnchain().open_sortition_db(true).unwrap(); - let burn_height = SortitionDB::get_canonical_burn_chain_tip(sortdb.conn()) - .unwrap() - .block_height as u32; + let tip = SortitionDB::get_canonical_burn_chain_tip(sortdb.conn()).unwrap(); + let miner_pubkey = + StacksPublicKey::from_private(&naka_conf.get_miner_config().mining_key.unwrap()); + let slot_id = NakamotoChainState::get_miner_slot(&sortdb, &tip, &miner_pubkey) + .expect("Unable to get miner slot") + .expect("No miner slot exists"); let chunk = std::thread::spawn(move || { let miner_contract_id = boot_code_id(MINERS_NAME, false); let mut miners_stackerdb = StackerDBSession::new(rpc_sock, miner_contract_id); miners_stackerdb - .get_latest_chunk(burn_height % 2) + .get_latest_chunk(slot_id) .expect("Failed to get latest chunk from the miner slot ID") .expect("No chunk found") }) .join() .expect("Failed to join chunk handle"); + // We should now successfully deserialize a chunk let proposed_block = NakamotoBlock::consensus_deserialize(&mut &chunk[..]) .expect("Failed to deserialize chunk into block");