Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test for PR 1537 #1614

Merged
merged 3 commits into from
Feb 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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