Skip to content

Commit

Permalink
improves test logs and fixes a disk format deserialization bug
Browse files Browse the repository at this point in the history
  • Loading branch information
arya2 committed Jan 17, 2025
1 parent a280b60 commit 93dfe43
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ impl IntoDisk for TransactionLocation {

impl FromDisk for Option<TransactionLocation> {
fn from_bytes(disk_bytes: impl AsRef<[u8]>) -> Self {
if disk_bytes.as_ref().len() == size_of::<TransactionLocation>() {
if disk_bytes.as_ref().len() == HEIGHT_DISK_BYTES + size_of::<TransactionIndex>() {
Some(TransactionLocation::from_bytes(disk_bytes))
} else {
None
Expand Down
17 changes: 16 additions & 1 deletion zebrad/tests/acceptance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3615,6 +3615,7 @@ async fn has_spending_transaction_ids() -> Result<()> {
// Read the last 500 blocks - should be greater than the MAX_BLOCK_REORG_HEIGHT so that
// both the finalized and non-finalized state are checked.
let num_blocks_to_check = 500;
let mut is_failure = false;
for i in 0..num_blocks_to_check {
let ReadResponse::Block(block) = read_state
.ready()
Expand Down Expand Up @@ -3654,7 +3655,16 @@ async fn has_spending_transaction_ids() -> Result<()> {
panic!("unexpected response to Block request");
};

let transaction_hash = transaction_hash.expect("should have spending transaction hash");
let Some(transaction_hash) = transaction_hash else {
tracing::warn!(
?spend,
depth = i,
height = ?block.coinbase_height(),
"querying spending tx id for spend failed"
);
is_failure = true;
continue;
};

assert_eq!(
transaction_hash, expected_transaction_hash,
Expand All @@ -3672,6 +3682,11 @@ async fn has_spending_transaction_ids() -> Result<()> {
tip_hash = block.header.previous_block_hash;
}

assert!(
!is_failure,
"at least one spend was missing a spending transaction id"
);

Ok(())
}

Expand Down

0 comments on commit 93dfe43

Please sign in to comment.