Skip to content

Commit

Permalink
excluded test cases where a short EWORD is not at the end
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzogentile404 committed Feb 20, 2025
1 parent 0efd317 commit 87f89e6
Showing 1 changed file with 22 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

package net.consensys.linea.zktracer.precompiles;

import static net.consensys.linea.zktracer.module.constants.GlobalConstants.WORD_SIZE;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.ArrayList;
Expand Down Expand Up @@ -101,26 +103,38 @@ void modexpTestForSequencer(Bytes input, boolean willFailDueToConstraints) {
} catch (IllegalArgumentException e) {
// This is expected when the input is invalid
assertTrue(willFailDueToConstraints);
return;
}
assertFalse(willFailDueToConstraints);
}

private Stream<Arguments> modexpTestForSequencerSource() {
List<Arguments> arguments = new ArrayList<>();
// Note that a short byte size WORD can be places only at the end of the input
// Including it may mess with the willFailDueToConstraints flag
for (ModexpCallDataWordVariants w1 : ModexpCallDataWordVariants.values()) {
arguments.add(Arguments.of(w1.getW(), w1.isInvalid()));
if (w1.isShort()) {
continue;
}
for (ModexpCallDataWordVariants w2 : ModexpCallDataWordVariants.values()) {
arguments.add(
Arguments.of(
Bytes.concatenate(w1.getW(), w2.getW()), w1.isInvalid() || w2.isInvalid()));
if (w2.isShort()) {
continue;
}
for (ModexpCallDataWordVariants w3 : ModexpCallDataWordVariants.values()) {
arguments.add(
Arguments.of(
Bytes.concatenate(w1.getW(), w2.getW(), w3.getW()),
w1.isInvalid() || w2.isInvalid() || w3.isInvalid()));
arguments.add(
Arguments.of(
Bytes.concatenate(w1.getW(), w2.getW(), w3.getW(), Bytes.random(1536, RANDOM)),
w1.isInvalid() || w2.isInvalid() || w3.isInvalid()));
if (!w3.isShort()) {
arguments.add(
Arguments.of(
Bytes.concatenate(w1.getW(), w2.getW(), w3.getW(), Bytes.random(1536, RANDOM)),
w1.isInvalid() || w2.isInvalid() || w3.isInvalid()));
}
}
}
}
Expand Down Expand Up @@ -159,5 +173,9 @@ public boolean isInvalid() {
|| this.getW() == ILLEGAL_SHORTEST.getW()
|| this.getW() == MAX_WORD.getW();
}

public boolean isShort() {
return this.getW().size() < WORD_SIZE;
}
}
}

0 comments on commit 87f89e6

Please sign in to comment.