Add track_caller to custom asserts
This change adds the track_caller meta tag to the custom test asserts.
This improves the ability to find which higher-level assertion is
failing in the test based on the line number in the test, not within the
custom assertion.
@@ -1462,6 +1462,7 @@ fn test_produce_same_state<L, R>(
assert_eq!(merkle_left_root_del, merkle_right_root_del);
}
+#[track_caller]
fn assert_value_at_address(merkle_db: &MerkleRadixTree, address: &str, expected_value: &str) {
let value = merkle_db.get_value(address);
match value {
@@ -1474,6 +1475,7 @@ fn assert_value_at_address(merkle_db: &MerkleRadixTree, address: &str, expected_
}
}
+#[track_caller]
fn assert_read_value_at_address<R>(
merkle_read: &R,
root_hash: &str,
@@ -1496,6 +1498,7 @@ fn assert_read_value_at_address<R>(
}
}
+#[track_caller]
fn expect_change_log(db: &dyn Database, root_hash: &[u8]) -> ChangeLogEntry {
let reader = db.get_reader().unwrap();
protobuf::Message::parse_from_bytes(
@@ -1507,6 +1510,7 @@ fn expect_change_log(db: &dyn Database, root_hash: &[u8]) -> ChangeLogEntry {
.expect("The change log entry to have bytes")
}
+#[track_caller]
fn assert_has_successors(change_log: &ChangeLogEntry, successor_roots: &[&[u8]]) {
assert_eq!(successor_roots.len(), change_log.successors.len());
for successor_root in successor_roots {
