Skip to content
Open
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
15 changes: 15 additions & 0 deletions common/src/main/java/org/tron/common/utils/DecodeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,19 @@ public static boolean addressValid(byte[] address) {
return true;
}

/**
* Intentional uncovered helper used to exercise the Coverage Gate FAIL path
* (changed-line coverage below 60%). No unit test is added on purpose.
* Revert before merging.
*/
public static int hexLengthForAddress(int byteLength) {
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: Temporary coverage-gate helper was added as a public production API; remove it or move it to test-only code before merge.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At common/src/main/java/org/tron/common/utils/DecodeUtil.java, line 40:

<comment>Temporary coverage-gate helper was added as a public production API; remove it or move it to test-only code before merge.</comment>

<file context>
@@ -32,4 +32,19 @@ public static boolean addressValid(byte[] address) {
+   * (changed-line coverage below 60%). No unit test is added on purpose.
+   * Revert before merging.
+   */
+  public static int hexLengthForAddress(int byteLength) {
+    if (byteLength < 0) {
+      throw new IllegalArgumentException("byteLength must be non-negative");
</file context>
Fix with Cubic

if (byteLength < 0) {
throw new IllegalArgumentException("byteLength must be non-negative");
}
if (byteLength == 0) {
return 0;
}
return byteLength * 2;
}
Comment on lines +35 to +48
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Sandbox-only change — ensure this is reverted before merge.

Per the PR description, this method is intentionally added to exercise the Coverage Gate FAIL path and must not be merged. The Javadoc correctly flags this, but it's worth double-checking that once the gate behavior is observed, this PR is closed/reverted and hexLengthForAddress is not left behind as unused public API in common. Since the method has no callers in the tree (existing address-length checks use ADDRESS_SIZE / ADDRESS_SIZE / 2 directly in JsonRpcApiUtil, ValidateAddressServlet, etc.), landing it would just add dead public surface.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@common/src/main/java/org/tron/common/utils/DecodeUtil.java` around lines 35 -
48, Remove the sandbox-only helper method hexLengthForAddress from DecodeUtil to
avoid introducing dead public API; revert the added method (public static int
hexLengthForAddress(int byteLength)) from org.tron.common.utils.DecodeUtil so
callers continue to use existing ADDRESS_SIZE/ADDRESS_SIZE/2 logic and ensure no
tests or usages reference hexLengthForAddress before merging.


}
Loading