Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
gtebrean committed Aug 30, 2023
1 parent a6a37fb commit 151d6aa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ private byte[] convertToEncodedItem(String baseType, Object data) {
rawValue.length);
}
} else if (baseType.equals("string")) {
hashBytes = sha3(((String) data).getBytes());
hashBytes = Numeric.hexStringToByteArray(sha3String((String) data));
} else if (baseType.equals("bytes")) {
hashBytes = sha3(Numeric.hexStringToByteArray((String) data));

Check warning on line 265 in crypto/src/main/java/org/web3j/crypto/StructuredDataEncoder.java

View check run for this annotation

Codecov / codecov/patch

crypto/src/main/java/org/web3j/crypto/StructuredDataEncoder.java#L265

Added line #L265 was not covered by tests
} else {
Expand Down
4 changes: 2 additions & 2 deletions crypto/src/test/java/org/web3j/crypto/StructuredDataTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,12 +308,12 @@ public void testValidStructureWithArrays() throws IOException {
(HashMap<String, Object>) dataEncoder.jsonMessageObject.getMessage());

String expectedMessageStructHash =
"0xc1c7d7b7dab9a65b30a6e951923b2d54536778329712e2239ed8a3f2f5f2329f";
"0x14f510c172a64b76f1105338b2e0b09dccfa4aef922131716d58d7fd94e097e8";

assertEquals(expectedMessageStructHash, Numeric.toHexString(dataHash));

assertEquals(
"0x935426a6009a3798ee87cd16ebeb9cea26b29d2d3762ac0951166d032f55d522",
"0xa31e6ec120743db6e47cf44cd6b116cc4383ff4875cf823308938f8ba4566cc0",
Numeric.toHexString(dataEncoder.hashStructuredData()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
-25
],
"ids": [
1,
2
"23ee3e3",
"3e2e23"
]
},
"to": [
Expand All @@ -36,9 +36,9 @@
-300
],
"ids": [
0,
3,
7
"2ed2d2",
"21ew2e",
"ewewe2"
]
}
]
Expand Down Expand Up @@ -92,7 +92,7 @@
},
{
"name": "ids",
"type": "uint16[]"
"type": "string[]"
}
]
}
Expand Down

0 comments on commit 151d6aa

Please sign in to comment.