-
Notifications
You must be signed in to change notification settings - Fork 36
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: Neo <neotheprogramist@proton.me>
- Loading branch information
1 parent
b608aa9
commit 6b86956
Showing
2 changed files
with
309 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
...ultipoint/src/test/java/org/hyperledger/besu/nativelib/ipa_multipoint/CommitRootTest.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,46 @@ | ||
package org.hyperledger.besu.nativelib.ipa_multipoint; | ||
|
||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
import static org.assertj.core.api.Assertions.*; | ||
|
||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import org.apache.tuweni.bytes.Bytes; | ||
import org.apache.tuweni.bytes.Bytes32; | ||
import org.hyperledger.besu.nativelib.ipamultipoint.LibIpaMultipoint; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class CommitRootTest { | ||
private static final ObjectMapper objectMapper = new ObjectMapper(); | ||
|
||
public static List<TestData> JsonData() throws IOException { | ||
InputStream inputStream = PedersenCommitmentTest.class.getResourceAsStream("/genesis_lvl1_commits.json"); | ||
return objectMapper.readValue(inputStream, new TypeReference<List<TestData>>() { | ||
}); | ||
} | ||
|
||
static class TestData { | ||
public ArrayList<String> frs; | ||
public String expected; | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("JsonData") | ||
public void TestPolynomialCommitments(TestData testData) { | ||
List<Bytes> FrBytes = new ArrayList<>(); | ||
for (int i = 0; i < 256; i++) { | ||
Bytes32 value = Bytes32.fromHexString(testData.frs.get(i)); | ||
FrBytes.add(value); | ||
} | ||
byte[] input = Bytes.concatenate(FrBytes).toArray(); | ||
Bytes32 result = Bytes32.wrap(LibIpaMultipoint.commitRoot(input)); | ||
Bytes32 expected = Bytes32.fromHexString(testData.expected); | ||
assertThat(result).isEqualTo(expected); | ||
} | ||
} |
Oops, something went wrong.