Skip to content

Commit

Permalink
scarb fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
oluwa-peski committed Aug 10, 2024
1 parent 12e4ee9 commit c3b84d3
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/validation.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ fn next_prev_timestamps(self: @ChainState, block: @Block) -> Span<u32> {
let mut prev_timestamps = *self.prev_timestamps;
let mut index = 1;
loop {
if index > 10 {
break timestamps.span();
}
timestamps.append(*prev_timestamps.at(index));
index += 1;
if index > 10 {
break timestamps.span();
}
timestamps.append(*prev_timestamps.at(index));
index += 1;
}
}

Expand Down Expand Up @@ -361,25 +361,25 @@ mod tests {
assert_eq!(last_reward, 0);
}

#[test]
#[test]
fn test_next_prev_timstamps() {
let chain_state = ChainState {
block_height: 1,
total_work: 1,
best_block_hash: 1,
current_target: 1,
epoch_start_time: 1,
prev_timestamps: array![0,1,2,3,4,5,6,7,8,9,10].span(),
prev_timestamps: array![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10].span(),
utreexo_state: UtreexoState { roots: array![].span() },
};
let block = Block {
header: Header { version: 1, time: 12, nonce: 1, bits: 1 },
txs: ArrayTrait::new().span(),
};
let next_prev_timestamps = next_prev_timestamps(@chain_state, @block);
assert (*next_prev_timestamps.at(0) == 12, 'Failed to compute');
assert (*next_prev_timestamps.at(6) == 6, 'Failed to compute');
assert (*next_prev_timestamps.at(8) == 8, 'Failed to compute');
assert (*next_prev_timestamps.at(9) == 9, 'Failed to compute');
assert(*next_prev_timestamps.at(0) == 12, 'Failed to compute');
assert(*next_prev_timestamps.at(6) == 6, 'Failed to compute');
assert(*next_prev_timestamps.at(8) == 8, 'Failed to compute');
assert(*next_prev_timestamps.at(9) == 9, 'Failed to compute');
}
}

0 comments on commit c3b84d3

Please sign in to comment.