Skip to content

Commit

Permalink
reduce max function name length
Browse files Browse the repository at this point in the history
  • Loading branch information
esaulpaugh committed Feb 3, 2025
1 parent 06b4164 commit d60ea97
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/esaulpaugh/headlong/abi/Function.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
public final class Function implements ABIObject {

public static final int SELECTOR_LEN = 4;
private static final int MAX_NAME_CHARS = 2048;
private static final int MAX_NAME_CHARS = 384;

private final TypeEnum type;
private final String name;
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/esaulpaugh/headlong/abi/FunctionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,11 @@ public void testFormatTupleType() {

@Test
public void testNameTooLong() throws Throwable {
final byte[] b = new byte[2096];
final byte[] b = new byte[387];
Arrays.fill(b, (byte) 'a');
b[b.length - 2] = '(';
b[b.length - 1] = ')';
final String sig = Strings.encode(b, Strings.ASCII);
TestUtils.assertThrown(IllegalArgumentException.class, "function name is too long: 2094 > 2048", () -> Function.parse(sig));
TestUtils.assertThrown(IllegalArgumentException.class, "function name is too long: 385 > 384", () -> Function.parse(sig));
}
}

0 comments on commit d60ea97

Please sign in to comment.