Skip to content

Commit

Permalink
Merge pull request #37 from Gabriel-Trintinalia/fix-adder-unit-tests
Browse files Browse the repository at this point in the history
Fix adder unit tests
  • Loading branch information
Gabriel-Trintinalia authored Apr 21, 2023
2 parents 6906f8e + d0a8335 commit 85a0c36
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/*
* Copyright ConsenSys AG.
*
* 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.module.alu.mod;

import org.hyperledger.besu.evm.frame.MessageFrame;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/*
* Copyright ConsenSys AG.
*
* 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.module.trm;

import org.hyperledger.besu.evm.frame.MessageFrame;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ public void getRangeTest() {
@Test
public void getTest() {
Bytes firstByte = Bytes.fromHexString("0x000000000000000a"); // baseTheta[3]
Bytes secondByte = Bytes.fromHexString("0x000000000000000b");// baseTheta[2]
Bytes secondByte = Bytes.fromHexString("0x000000000000000b"); // baseTheta[2]
Bytes thirdByte = Bytes.fromHexString("0x000000000000000c"); // baseTheta[1]
Bytes fourthByte = Bytes.fromHexString("0x000000000000000d");// baseTheta[0]
Bytes fourthByte = Bytes.fromHexString("0x000000000000000d"); // baseTheta[0]
Bytes32 bytes32 = Bytes32.wrap(Bytes.concatenate(firstByte, secondByte, thirdByte, fourthByte));

BaseTheta baseTheta = BaseTheta.fromBytes32(bytes32);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,27 @@ class AdderTest {
@Test
void zeroAddZero_isZero() {
BaseBytes actual = Adder.addSub(OpCode.ADD, Bytes32.ZERO, Bytes32.ZERO);
assertThat(actual).isEqualTo(Bytes32.ZERO);
assertThat(actual.getBytes32()).isEqualTo(Bytes32.ZERO);
}

@Test
void zeroSubZero_isZero() {
BaseBytes actual = Adder.addSub(OpCode.SUB, Bytes32.ZERO, Bytes32.ZERO);
assertThat(actual).isEqualTo(Bytes32.ZERO);
assertThat(actual.getBytes32()).isEqualTo(Bytes32.ZERO);
}

@Test
void xSubZero_isX() {
Bytes32 randomBytes = Bytes32.random();
BaseBytes actual = Adder.addSub(OpCode.SUB, randomBytes, Bytes32.ZERO);
assertThat(actual).isEqualTo(randomBytes);
assertThat(actual.getBytes32()).isEqualTo(randomBytes);
}

@Test
void xAddZero_isX() {
Bytes32 randomBytes = Bytes32.random();
BaseBytes actual = Adder.addSub(OpCode.ADD, randomBytes, Bytes32.ZERO);
assertThat(actual).isEqualTo(randomBytes);
assertThat(actual.getBytes32()).isEqualTo(randomBytes);
}

@Test
Expand All @@ -55,7 +55,7 @@ void maxSubMax_isZero() {
b = 'f';
Bytes32 max = Bytes32.repeat(b);
BaseBytes actual = Adder.addSub(OpCode.SUB, max, max);
assertThat(actual).isEqualTo(Bytes32.ZERO);
assertThat(actual.getBytes32()).isEqualTo(Bytes32.ZERO);
}

@Test
Expand All @@ -64,7 +64,7 @@ void maxSubZero_isMax() {
b = 'f';
Bytes32 max = Bytes32.repeat(b);
BaseBytes actual = Adder.addSub(OpCode.SUB, max, Bytes32.ZERO);
assertThat(actual).isEqualTo(max);
assertThat(actual.getBytes32()).isEqualTo(max);
}

@Test
Expand Down

0 comments on commit 85a0c36

Please sign in to comment.