-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: F Bojarski <ceciestunepoubelle@protonmail.ch>
- Loading branch information
1 parent
1618694
commit f09826e
Showing
1 changed file
with
74 additions
and
0 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
...on/src/test/java/net/consensys/linea/zktracer/containers/ModexpIllegalOperationTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright ConsenSys Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package net.consensys.linea.zktracer.containers; | ||
|
||
import static java.lang.Integer.MAX_VALUE; | ||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
|
||
import net.consensys.linea.zktracer.ZkTracer; | ||
import net.consensys.linea.zktracer.module.limits.precompiles.ModexpEffectiveCall; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class ModexpIllegalOperationTests { | ||
@Test | ||
void legalThenTwoIllegals() { | ||
final ZkTracer state = new ZkTracer(); | ||
final ModexpEffectiveCall countingOnlyModule = state.getHub().modexpEffectiveCall(); | ||
|
||
countingOnlyModule.addPrecompileLimit(1); | ||
|
||
countingOnlyModule.addPrecompileLimit(MAX_VALUE); | ||
assertThat(countingOnlyModule.lineCount()).isEqualTo(MAX_VALUE); | ||
|
||
countingOnlyModule.addPrecompileLimit(MAX_VALUE); | ||
assertThat(countingOnlyModule.lineCount()).isEqualTo(MAX_VALUE); | ||
|
||
countingOnlyModule.popTransactionBundle(); | ||
assertThat(countingOnlyModule.lineCount()).isEqualTo(0); | ||
} | ||
|
||
@Test | ||
void legalIllegalLegal() { | ||
final ZkTracer state = new ZkTracer(); | ||
final ModexpEffectiveCall countingOnlyModule = state.getHub().modexpEffectiveCall(); | ||
|
||
countingOnlyModule.addPrecompileLimit(1); | ||
|
||
countingOnlyModule.addPrecompileLimit(MAX_VALUE); | ||
assertThat(countingOnlyModule.lineCount()).isEqualTo(MAX_VALUE); | ||
|
||
countingOnlyModule.addPrecompileLimit(1); | ||
assertThat(countingOnlyModule.lineCount()).isEqualTo(MAX_VALUE); | ||
|
||
countingOnlyModule.popTransactionBundle(); | ||
assertThat(countingOnlyModule.lineCount()).isEqualTo(0); | ||
} | ||
|
||
@Test | ||
void TwoIllegals() { | ||
final ZkTracer state = new ZkTracer(); | ||
final ModexpEffectiveCall countingOnlyModule = state.getHub().modexpEffectiveCall(); | ||
|
||
countingOnlyModule.addPrecompileLimit(MAX_VALUE); | ||
assertThat(countingOnlyModule.lineCount()).isEqualTo(MAX_VALUE); | ||
|
||
countingOnlyModule.addPrecompileLimit(MAX_VALUE); | ||
assertThat(countingOnlyModule.lineCount()).isEqualTo(MAX_VALUE); | ||
|
||
countingOnlyModule.popTransactionBundle(); | ||
assertThat(countingOnlyModule.lineCount()).isEqualTo(0); | ||
} | ||
} |