Skip to content

Commit

Permalink
add unit test for rle like instruction (match len > match offset)
Browse files Browse the repository at this point in the history
Signed-off-by: noelwei <fan@scroll.io>
  • Loading branch information
noel2004 committed May 15, 2024
1 parent 08c4bf0 commit f181535
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions aggregator/src/aggregation/decoder/seq_exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,8 +1096,9 @@ mod tests {
inst.instruction_idx as usize,
SequenceExecInfo::BackRef(r.clone()),
));
let matched_bytes = Vec::from(&outputs[r]);
outputs.extend(matched_bytes);
for ref_pos in r {
outputs.push(outputs[ref_pos]);
}
}
current_literal_pos = new_literal_pos;
}
Expand Down Expand Up @@ -1233,7 +1234,7 @@ mod tests {
AddressTableRow::mock_samples_full([
[1, 4, 1, 1, 4, 8],
[9, 1, 3, 6, 1, 4],
[3, 0, 4, 5, 6, 1],
[3, 0, 4, 5, 6, 1], // ref offset 3 while literal == 0
]),
);

Expand All @@ -1245,6 +1246,26 @@ mod tests {
mock_prover.verify().unwrap();
}

#[test]
fn seq_exec_rle_like() {
// no instructions, we only copy literals to output
let circuit = SeqExecMock::mock_generate(
Vec::from("abcdef".as_bytes()),
AddressTableRow::mock_samples_full([
[1, 4, 1, 1, 4, 8],
[9, 1, 3, 6, 1, 4],
[5, 0, 6, 2, 6, 1], // an RLE like inst, match len exceed match offset
]),
);

assert_eq!(circuit.outputs, Vec::from("abcddeabcbcbcbcf".as_bytes()));

let k = 12;
let mock_prover =
MockProver::<Fr>::run(k, &circuit, vec![]).expect("failed to run mock prover");
mock_prover.verify().unwrap();
}

#[test]
fn seq_exec_no_tail_cp() {
// no instructions, we only copy literals to output
Expand Down

0 comments on commit f181535

Please sign in to comment.