Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
Use the same slot id for retrieving the proposed block
Browse files Browse the repository at this point in the history
Signed-off-by: Jacinta Ferrant <[email protected]>
  • Loading branch information
jferrant committed Feb 5, 2024
1 parent 20d7869 commit 2d1f1ae
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions testnet/stacks-node/src/tests/nakamoto_integrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 2d1f1ae

Please sign in to comment.