mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-31 13:54:27 +01:00
clippy fixes
This commit is contained in:
@@ -63,7 +63,7 @@ use turso_macros::match_ignore_ascii_case;
|
||||
/// ↓
|
||||
/// Turso Encrypted Header: "Turso" + Version + Cipher ID + Unused
|
||||
/// ```
|
||||
|
||||
///
|
||||
/// constants used for the Turso page header in the encrypted dbs.
|
||||
const TURSO_HEADER_PREFIX: &[u8] = b"Turso";
|
||||
const TURSO_VERSION: u8 = 0x00;
|
||||
@@ -552,8 +552,7 @@ impl EncryptionContext {
|
||||
let version = header[5];
|
||||
if version != TURSO_VERSION {
|
||||
return Err(LimboError::InternalError(format!(
|
||||
"Unsupported Turso header version: expected {}, got {}",
|
||||
TURSO_VERSION, version
|
||||
"Unsupported Turso header version: expected {TURSO_VERSION}, got {version}"
|
||||
)));
|
||||
}
|
||||
|
||||
@@ -984,9 +983,7 @@ mod tests {
|
||||
page[..SQLITE_HEADER.len()].copy_from_slice(SQLITE_HEADER);
|
||||
let mut rng = rand::thread_rng();
|
||||
// 48 is the max reserved bytes we might need for metadata with any cipher
|
||||
for i in SQLITE_HEADER.len()..DEFAULT_ENCRYPTED_PAGE_SIZE - 48 {
|
||||
page[i] = rng.gen();
|
||||
}
|
||||
rng.fill(&mut page[SQLITE_HEADER.len()..DEFAULT_ENCRYPTED_PAGE_SIZE - 48]);
|
||||
page
|
||||
}
|
||||
|
||||
|
||||
@@ -338,8 +338,7 @@ fn test_corruption_associated_data_bytes() -> anyhow::Result<()> {
|
||||
|
||||
assert!(
|
||||
should_panic.is_err(),
|
||||
"should panic when accessing encrypted DB with corrupted associated data at position {}",
|
||||
corrupt_pos
|
||||
"should panic when accessing encrypted DB with corrupted associated data at position {corrupt_pos}",
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -364,18 +363,12 @@ fn test_turso_header_structure() -> anyhow::Result<()> {
|
||||
assert_eq!(
|
||||
&header[0..5],
|
||||
b"Turso",
|
||||
"Magic bytes should be 'Turso' for {}",
|
||||
description
|
||||
);
|
||||
assert_eq!(
|
||||
header[5], 0x00,
|
||||
"Version should be 0x00 for {}",
|
||||
description
|
||||
"Magic bytes should be 'Turso' for {description}"
|
||||
);
|
||||
assert_eq!(header[5], 0x00, "Version should be 0x00 for {description}");
|
||||
assert_eq!(
|
||||
header[6], expected_cipher_id,
|
||||
"Cipher ID should be {} for {}",
|
||||
expected_cipher_id, description
|
||||
"Cipher ID should be {expected_cipher_id} for {description}"
|
||||
);
|
||||
|
||||
// the unused bytes should be zeroed
|
||||
@@ -445,12 +438,8 @@ fn test_turso_header_structure() -> anyhow::Result<()> {
|
||||
|
||||
{
|
||||
let conn = tmp_db.connect_limbo();
|
||||
run_query(&tmp_db, &conn, &format!("PRAGMA hexkey = '{}';", hexkey))?;
|
||||
run_query(
|
||||
&tmp_db,
|
||||
&conn,
|
||||
&format!("PRAGMA cipher = '{}';", cipher_name),
|
||||
)?;
|
||||
run_query(&tmp_db, &conn, &format!("PRAGMA hexkey = '{hexkey}';"))?;
|
||||
run_query(&tmp_db, &conn, &format!("PRAGMA cipher = '{cipher_name}';"))?;
|
||||
run_query(
|
||||
&tmp_db,
|
||||
&conn,
|
||||
@@ -459,7 +448,7 @@ fn test_turso_header_structure() -> anyhow::Result<()> {
|
||||
do_flush(&conn, &tmp_db)?;
|
||||
}
|
||||
|
||||
verify_header(&db_path.to_str().unwrap(), expected_id, description)?;
|
||||
verify_header(db_path.to_str().unwrap(), expected_id, description)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user