MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / byte_position

Function byte_position

crates/commitlog/src/tests/bitflip.rs:102–111  ·  view source on GitHub ↗

Select a random position of a byte within a segment. The position shall not fall on any headers (segment or commit), so as to reliably provoke checksum errors (and not any other errors).

(segment_len: usize)

Source from the content-addressed store, hash-verified

100/// The position shall not fall on any headers (segment or commit), so as to
101/// reliably provoke checksum errors (and not any other errors).
102fn byte_position(segment_len: usize) -> impl Strategy<Value = usize> {
103 (segment::Header::LEN + commit::Header::LEN + 1..segment_len).prop_map(|mut byte_pos| {
104 for x in commit_boundaries() {
105 if byte_pos >= x && byte_pos < x + COMMIT_SIZE {
106 byte_pos = byte_pos.max(x + commit::Header::LEN + 1);
107 }
108 }
109 byte_pos
110 })
111}
112
113proptest! {
114 #[test]

Callers 1

generateMethod · 0.85

Calls 2

commit_boundariesFunction · 0.85
maxMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…