Skip to content

Commit

Permalink
feat: version bump and fmt
Browse files Browse the repository at this point in the history
BREAKING CHANGE: This PR alters the API
  • Loading branch information
dirvine committed Nov 14, 2024
1 parent 748dd24 commit 256f1f7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "GPL-3.0"
name = "self_encryption"
readme = "README.md"
repository = "https://github.com/maidsafe/self_encryption"
version = "0.30.266"
version = "0.31.0"

[features]
default = []
Expand Down
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ mod data_map_tests {
let chunk_size = *MAX_CHUNK_SIZE;
let data_size = num_chunks * chunk_size;
let data = test_helpers::random_bytes(data_size);
let (data_map, _) = encrypt(Bytes::from(data))?;
let (data_map, _) = encrypt(data)?;
Ok(data_map)
}

Expand All @@ -821,7 +821,7 @@ mod data_map_tests {
// Create dummy hashes - each hash is just the chunk number repeated
let chunk_identifiers = (0..num_chunks)
.map(|i| {
let dummy_hash = XorName::from_content(&vec![i as u8; 32]); // Convert to XorName
let dummy_hash = XorName::from_content(&[i as u8; 32]); // Convert to XorName
ChunkInfo {
index: i,
dst_hash: dummy_hash,
Expand Down Expand Up @@ -1031,7 +1031,7 @@ mod data_map_tests {

// Create test data and encrypt it
let test_data = test_helpers::random_bytes(1024 * 1024); // 1MB of random data
let (data_map, encrypted_chunks) = encrypt(Bytes::from(test_data.clone()))?;
let (data_map, encrypted_chunks) = encrypt(test_data.clone())?;

// Store chunks to disk
for chunk in encrypted_chunks {
Expand Down Expand Up @@ -1069,7 +1069,7 @@ mod data_map_tests {

// Create test data and encrypt it
let test_data = test_helpers::random_bytes(1024 * 1024); // 1MB of random data
let (data_map, encrypted_chunks) = encrypt(Bytes::from(test_data.clone()))?;
let (data_map, encrypted_chunks) = encrypt(test_data.clone())?;

// Store chunks in memory
for chunk in encrypted_chunks {
Expand Down Expand Up @@ -1110,7 +1110,7 @@ mod data_map_tests {

// Create test data and encrypt it
let test_data = test_helpers::random_bytes(1024 * 1024);
let (data_map, encrypted_chunks) = encrypt(Bytes::from(test_data))?;
let (data_map, encrypted_chunks) = encrypt(test_data)?;

// Store only half of the chunks
for (i, chunk) in encrypted_chunks.into_iter().enumerate() {
Expand Down Expand Up @@ -1149,7 +1149,7 @@ mod data_map_tests {

// Create test data and encrypt it
let test_data = test_helpers::random_bytes(1024 * 1024);
let (data_map, encrypted_chunks) = encrypt(Bytes::from(test_data))?;
let (data_map, encrypted_chunks) = encrypt(test_data)?;

// Store chunks
for chunk in encrypted_chunks {
Expand Down Expand Up @@ -1181,7 +1181,7 @@ mod data_map_tests {

// Create test data and encrypt it
let test_data = test_helpers::random_bytes(1024 * 1024);
let (data_map, encrypted_chunks) = encrypt(Bytes::from(test_data.clone()))?;
let (data_map, encrypted_chunks) = encrypt(test_data.clone())?;

// Store chunks with their original hashes
for chunk in encrypted_chunks {
Expand Down
5 changes: 1 addition & 4 deletions src/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,7 @@ fn encrypt_file(file_path: String, output_dir: String) -> PyResult<(PyDataMap, V
encrypt_from_file(&PathBuf::from(file_path), &PathBuf::from(output_dir))
.map_err(|e| PyErr::new::<pyo3::exceptions::PyValueError, _>(e.to_string()))?;

let chunk_filenames: Vec<String> = chunk_names
.into_iter()
.map(|name| hex::encode(name))
.collect();
let chunk_filenames: Vec<String> = chunk_names.into_iter().map(hex::encode).collect();

Ok((PyDataMap { inner: data_map }, chunk_filenames))
}
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl StorageBackend {
}
}

let disk_chunks: Vec<_> = std::fs::read_dir(&self.disk_dir.path())?
let disk_chunks: Vec<_> = std::fs::read_dir(self.disk_dir.path())?
.filter_map(|entry| entry.ok())
.collect();
println!("Disk storage contains {} chunks", disk_chunks.len());
Expand Down

0 comments on commit 256f1f7

Please sign in to comment.