Skip to content

Commit

Permalink
add test for PR 1537 (#1614)
Browse files Browse the repository at this point in the history
* add test for PR 1537

* spotless
  • Loading branch information
AlexandrouR authored Feb 2, 2022
1 parent f64e7af commit 21a1f67
Showing 1 changed file with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ public void testStructOnlyInArrayCompareJavaFile() throws Exception {
String inputFileName = "OnlyInArrayStruct";
String contract = inputFileName.toLowerCase();
String packagePath =
generateCode(emptyList(), contract, inputFileName, JAVA_TYPES_ARG, false, false);
generateCode(
emptyList(), contract, inputFileName, JAVA_TYPES_ARG, false, false, false);
File fileActual = new File(tempDirPath, packagePath + "/OnlyInArrayStruct.java");
File fileExpected =
new File(
Expand All @@ -157,7 +158,8 @@ public void testArraysInStructCompareJavaFileTest() throws Exception {
String inputFileName = "ArraysInStruct";
String contract = inputFileName.toLowerCase();
String packagePath =
generateCode(emptyList(), contract, inputFileName, JAVA_TYPES_ARG, false, false);
generateCode(
emptyList(), contract, inputFileName, JAVA_TYPES_ARG, false, false, false);
File fileActual = new File(tempDirPath, packagePath + "/ArraysInStruct.java");
File fileExpected =
new File(
Expand Down Expand Up @@ -209,6 +211,11 @@ public void testPrimitiveTypes() throws Exception {
testCodeGenerationJvmTypes("primitive", "Primitive", true);
}

@Test
public void testABIFlag() throws Exception {
testCodeGeneration(emptyList(), "primitive", "Primitive", JAVA_TYPES_ARG, true, true, true);
}

private void testCodeGenerationJvmTypes(String contractName, String inputFileName)
throws Exception {
testCodeGeneration(contractName, inputFileName, JAVA_TYPES_ARG, true);
Expand All @@ -217,7 +224,7 @@ private void testCodeGenerationJvmTypes(String contractName, String inputFileNam
private void testCodeGenerationJvmTypes(
String contractName, String inputFileName, boolean primitive) throws Exception {
testCodeGeneration(
emptyList(), contractName, inputFileName, JAVA_TYPES_ARG, true, primitive);
emptyList(), contractName, inputFileName, JAVA_TYPES_ARG, true, primitive, false);
}

private void testCodeGenerationSolidityTypes(String contractName, String inputFileName)
Expand All @@ -238,7 +245,7 @@ private void testCodeGeneration(
String types,
boolean useBin)
throws Exception {
testCodeGeneration(prefixes, contractName, inputFileName, types, useBin, false);
testCodeGeneration(prefixes, contractName, inputFileName, types, useBin, false, false);
}

private void testCodeGeneration(
Expand All @@ -247,11 +254,13 @@ private void testCodeGeneration(
String inputFileName,
String types,
boolean useBin,
boolean primitives)
boolean primitives,
boolean abiFuncs)
throws Exception {

String packagePath =
generateCode(prefixes, contractName, inputFileName, types, useBin, primitives);
generateCode(
prefixes, contractName, inputFileName, types, useBin, primitives, abiFuncs);
verifyGeneratedCode(
tempDirPath
+ File.separator
Expand All @@ -267,7 +276,8 @@ private String generateCode(
String inputFileName,
String types,
boolean useBin,
boolean primitives) {
boolean primitives,
boolean abiFuncs) {
String packageName = null;
if (types.equals(JAVA_TYPES_ARG)) {
packageName = "org.web3j.unittests.java";
Expand Down Expand Up @@ -308,6 +318,9 @@ private String generateCode(
if (primitives) {
options.add(PRIMITIVE_TYPES_ARG);
}
if (abiFuncs) {
options.add("-r");
}

SolidityFunctionWrapperGenerator.main(options.toArray(new String[options.size()]));
return packageName.replace('.', File.separatorChar);
Expand Down

0 comments on commit 21a1f67

Please sign in to comment.