Skip to content

Commit

Permalink
full blob test (#1423)
Browse files Browse the repository at this point in the history
* full blob test

* use get_blob_bytes

* try fix assert

* reduce one byte from batch274

* found full blob

* clean up
  • Loading branch information
DreamWuGit committed Sep 18, 2024
1 parent 5ee0157 commit 2879c23
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion aggregator/data/test_batches/batch274.hex

Large diffs are not rendered by default.

45 changes: 24 additions & 21 deletions aggregator/src/tests/blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,17 +273,18 @@ fn check_circuit(circuit: &BlobCircuit) -> Result<(), Vec<VerifyFailure>> {

#[test]
fn blob_circuit_completeness() {
// TODO: enable this once we have another deterministic case of batch -> blob (fully packed).
// now batch274 is an deterministic case of batch -> blob (fully packed).
// Full blob test case
// batch274 contains batch bytes that will produce a full blob
// let full_blob = hex::decode(
// fs::read_to_string("./data/test_batches/batch274.hex")
// .expect("file path exists")
// .trim(),
// )
// .expect("should load full blob batch bytes");
// batch274 contains metadata
// let segmented_full_blob_src = BatchData::<MAX_AGG_SNARKS>::segment_with_metadata(full_blob);
let full_blob = hex::decode(
fs::read_to_string("./data/test_batches/batch274.hex")
.expect("file path exists")
.trim(),
)
.expect("should load full blob batch bytes");

// batch274 contains metadatas
let segmented_full_blob_src = BatchData::<MAX_AGG_SNARKS>::segment_with_metadata(full_blob);

let all_empty_chunks: Vec<Vec<u8>> = vec![vec![]; MAX_AGG_SNARKS];
let one_chunk = vec![vec![2, 3, 4, 100, 1]];
Expand All @@ -305,8 +306,8 @@ fn blob_circuit_completeness() {
.chain(std::iter::once(vec![3, 100, 24, 30]))
.collect::<Vec<_>>();

for blob in [
// segmented_full_blob_src,
for (idx, blob) in [
segmented_full_blob_src,
one_chunk,
two_chunks,
max_chunks,
Expand All @@ -317,19 +318,21 @@ fn blob_circuit_completeness() {
all_empty_except_last,
]
.into_iter()
.enumerate()
{
let batch_data = BatchData::from(&blob);

// TODO: enable this once we have another deterministic case of batch -> blob (fully
// packed).
// First blob is purposely constructed to take full blob space
// if idx == 0 {
// let blob_data_bytes_len = batch_data.get_blob_data_bytes().len();
// assert_eq!(
// blob_data_bytes_len, N_BLOB_BYTES,
// "should be full blob: expected={N_BLOB_BYTES}, got={blob_data_bytes_len}",
// );
// }
// First blob(batch274's blob data) is purposely constructed to take full blob space
if idx == 0 {
let batch_data_bytes = batch_data.get_batch_data_bytes();
let blob_data_bytes = get_blob_bytes(&batch_data_bytes);
let blob_data_bytes_len = blob_data_bytes.len();

assert_eq!(
blob_data_bytes_len, N_BLOB_BYTES,
"should be full blob: expected={N_BLOB_BYTES}, got={blob_data_bytes_len}",
);
}

assert_eq!(check_data(batch_data), Ok(()), "{:?}", blob);
}
Expand Down

0 comments on commit 2879c23

Please sign in to comment.