Skip to content

Fix ProposalInfo default constructor for zero-address initialization#953

Merged
kyonRay merged 6 commits into
release-3.9.0from
copilot/fix-proposalinfo-no-arg-constructor
Jul 16, 2026
Merged

Fix ProposalInfo default constructor for zero-address initialization#953
kyonRay merged 6 commits into
release-3.9.0from
copilot/fix-proposalinfo-no-arg-constructor

Conversation

Copilot AI commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

ProposalInfo() could not be instantiated because its no-arg constructor built an Address from an empty string, which throws NumberFormatException. The constructor also omitted the second address field from the dynamic struct template, leaving the default ABI shape incomplete.

  • Constructor fix

    • Replace new Address("") with valid zero-address placeholders via Address.DEFAULT
    • Initialize both resourceId and proposer in the no-arg constructor so the default DynamicStruct matches the full 7-field ProposalInfo ABI
  • Regression coverage

    • Add a focused unit test for new ProposalInfo()
    • Assert the default instance:
      • constructs successfully
      • exposes 7 struct components
      • reports the expected ABI type string
      • uses zero addresses for both address fields
public ProposalInfo() {
    super(
            Address.DEFAULT,
            Address.DEFAULT,
            new Uint8(0),
            new Uint256(0),
            new Uint8(0),
            new DynamicArray<>(Address.class),
            new DynamicArray<>(Address.class));
}

Copilot AI and others added 2 commits March 4, 2026 13:34
* Initial plan

* Remove fisco-bcos.org URL, replace with GitHub repo URL in build.gradle

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix ProposalInfo no-arg constructor to avoid NumberFormatException Fix ProposalInfo default constructor for zero-address initialization Jun 16, 2026
Copilot AI requested a review from kyonRay June 16, 2026 03:35
@kyonRay kyonRay marked this pull request as ready for review June 17, 2026 03:59
Copilot AI review requested due to automatic review settings June 17, 2026 03:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes ProposalInfo’s no-arg constructor so it can be instantiated safely and its DynamicStruct ABI shape matches the full 7-field ProposalInfo definition.

Changes:

  • Update ProposalInfo() to use Address.DEFAULT (zero address) and include both address fields in the DynamicStruct template.
  • Add a unit test validating ProposalInfo() constructs, exposes 7 components, reports the expected ABI type string, and uses zero addresses for both address fields.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/main/java/org/fisco/bcos/sdk/v3/contract/auth/po/ProposalInfo.java Fixes default constructor to avoid NumberFormatException and to build a 7-field ABI template (incl. both addresses).
src/test/java/org/fisco/bcos/sdk/v3/test/contract/auth/ProposalInfoTest.java Adds regression test for default constructor ABI shape and zero-address initialization.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 22 to 26
public ProposalInfo() {
super(
new Address(""),
Address.DEFAULT,
Address.DEFAULT,
new Uint8(0),
@kyonRay kyonRay changed the base branch from master to release-3.9.0 June 22, 2026 09:27
@sonarqubecloud

Copy link
Copy Markdown

@kyonRay

kyonRay commented Jul 16, 2026

Copy link
Copy Markdown
Member

@copilot windows ci failed with: org.fisco.bcos.sdk.v3.test.transaction.DecodeAndPojoCoverageTest > testProposalInfoDefaultConstructorThrowsOnEmptyAddress FAILED
java.lang.AssertionError at DecodeAndPojoCoverageTest.java:189

Copilot AI commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

@copilot windows ci failed with: org.fisco.bcos.sdk.v3.test.transaction.DecodeAndPojoCoverageTest > testProposalInfoDefaultConstructorThrowsOnEmptyAddress FAILED
java.lang.AssertionError at Decod...

Fixed in commit fix(auth): delegate ProposalInfo() to 7-arg ctor; update obsolete characterization test.

The no-arg constructor now delegates to the 7-arg String-based constructor, which initializes all POJO fields. The characterization test testProposalInfoDefaultConstructorThrowsOnEmptyAddress has been updated to testProposalInfoDefaultConstructorSucceeds, which verifies the constructor succeeds and all POJO fields are non-null.

Copilot AI requested a review from kyonRay July 16, 2026 08:47
@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.08%. Comparing base (ab0390c) to head (2a7e709).

Additional details and impacted files
@@                 Coverage Diff                 @@
##             release-3.9.0     #953      +/-   ##
===================================================
+ Coverage            64.05%   64.08%   +0.02%     
- Complexity            4567     4569       +2     
===================================================
  Files                  430      430              
  Lines                17628    17632       +4     
  Branches              1969     1969              
===================================================
+ Hits                 11292    11299       +7     
+ Misses                5576     5574       -2     
+ Partials               760      759       -1     
Flag Coverage Δ
unittest 64.08% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kyonRay kyonRay merged commit ca6927e into release-3.9.0 Jul 16, 2026
5 of 6 checks passed
@kyonRay kyonRay deleted the copilot/fix-proposalinfo-no-arg-constructor branch July 16, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants