Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kadenzipfel committed Oct 8, 2022
1 parent 491dbdc commit 80cd7dd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub fn check_rules(peephole: &mut Bytecode) -> Bytecode {
for j in 0..32 {
if byte.opcode == PUSH_OPS[j] {
let (min_len, min_string) = min_pushdata_len(&peephole[i].clone().pushdata.as_ref().unwrap());
if min_len < j {
if min_len - 1 < j {
byte = ByteData {
code_index: byte.code_index,
opcode: PUSH_OPS[min_len - 1],
Expand Down Expand Up @@ -723,17 +723,17 @@ mod tests {
fn test_reduced_push_size() {
let mut peephole = vec![ByteData {
code_index: 4,
opcode: Opcode::Push4,
pushdata: Some(String::from("30380020")),
opcode: Opcode::Push2,
pushdata: Some(String::from("0080")),
}, ByteData {
code_index: 5,
opcode: Opcode::Push18,
pushdata: Some(String::from("000000000000000000002030000000004040")),
}];
let optimized_peephole = vec![ByteData {
code_index: 4,
opcode: Opcode::Push4,
pushdata: Some(String::from("30380020")),
opcode: Opcode::Push1,
pushdata: Some(String::from("80")),
}, ByteData {
code_index: 5,
opcode: Opcode::Push8,
Expand Down

0 comments on commit 80cd7dd

Please sign in to comment.