Skip to content

Commit

Permalink
files and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gtebrean committed Feb 18, 2022
1 parent de020ba commit 8a3fec6
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,48 +132,12 @@ public void testStructOnlyInArray() throws Exception {

@Test
public void testStructOnlyInArrayCompareJavaFile() throws Exception {
String inputFileName = "OnlyInArrayStruct";
String contract = inputFileName.toLowerCase();
String packagePath =
generateCode(
emptyList(), contract, inputFileName, JAVA_TYPES_ARG, false, false, false);
File fileActual = new File(tempDirPath, packagePath + "/OnlyInArrayStruct.java");
File fileExpected =
new File(
Strings.join(
Arrays.asList(
solidityBaseDir,
contract,
"build",
"java",
inputFileName + ".java"),
File.separator));
assertEquals(
new String(Files.readAllBytes(fileExpected.toPath())),
new String(Files.readAllBytes(fileActual.toPath())));
compareJavaFile("OnlyInArrayStruct");
}

@Test
public void testArraysInStructCompareJavaFileTest() throws Exception {
String inputFileName = "ArraysInStruct";
String contract = inputFileName.toLowerCase();
String packagePath =
generateCode(
emptyList(), contract, inputFileName, JAVA_TYPES_ARG, false, false, false);
File fileActual = new File(tempDirPath, packagePath + "/ArraysInStruct.java");
File fileExpected =
new File(
Strings.join(
Arrays.asList(
solidityBaseDir,
contract,
"build",
"java",
inputFileName + ".java"),
File.separator));
assertEquals(
new String(Files.readAllBytes(fileExpected.toPath())),
new String(Files.readAllBytes(fileActual.toPath())));
compareJavaFile("ArraysInStruct");
}

@Test
Expand Down Expand Up @@ -216,6 +180,33 @@ public void testABIFlag() throws Exception {
testCodeGeneration(emptyList(), "primitive", "Primitive", JAVA_TYPES_ARG, true, true, true);
}

@Test
public void testEventParametersNoNamed() throws Exception {
testCodeGeneration("eventparameters", "EventParametersNoNamed", JAVA_TYPES_ARG, false);
testCodeGeneration("eventparameters", "EventParametersNoNamed", SOLIDITY_TYPES_ARG, false);
}

private void compareJavaFile(String inputFileName) throws Exception {
String contract = inputFileName.toLowerCase();
String packagePath =
generateCode(
emptyList(), contract, inputFileName, JAVA_TYPES_ARG, false, false, false);
File fileActual = new File(tempDirPath, packagePath + "/" + inputFileName + ".java");
File fileExpected =
new File(
Strings.join(
Arrays.asList(
solidityBaseDir,
contract,
"build",
"java",
inputFileName + ".java"),
File.separator));
assertEquals(
new String(Files.readAllBytes(fileExpected.toPath())),
new String(Files.readAllBytes(fileActual.toPath())));
}

private void testCodeGenerationJvmTypes(String contractName, String inputFileName)
throws Exception {
testCodeGeneration(contractName, inputFileName, JAVA_TYPES_ARG, true);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pragma solidity ^0.8.0;

contract EventParametersNoNamed {
event ContractCreated(address, uint256 indexed _contractNumber, string indexed, address);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"","type":"address"},{"indexed":true,"internalType":"uint256","name":"_contractNumber","type":"uint256"},{"indexed":true,"internalType":"string","name":"","type":"string"},{"indexed":false,"internalType":"address","name":"","type":"address"}],"name":"ContractCreated","type":"event"}]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
6080604052348015600f57600080fd5b50603f80601d6000396000f3fe6080604052600080fdfea2646970667358221220a37f1d42d197537a1e015cd4d46ef7e6028b16b26b192b6a0385b103d7d72ece64736f6c63430008070033

0 comments on commit 8a3fec6

Please sign in to comment.