Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ publishing {
pom {
name = 'fisco-bcos'
description = 'fisco-bcos java-sdk'
url = 'http://www.fisco-bcos.org'
url = 'https://github.com/FISCO-BCOS/java-sdk'

licenses {
license {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.fisco.bcos.sdk.v3.contract.auth.po;

import java.math.BigInteger;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.fisco.bcos.sdk.v3.codec.datatypes.Address;
Expand All @@ -20,13 +21,14 @@ public class ProposalInfo extends DynamicStruct {
private List<String> againstVoters;

public ProposalInfo() {
super(
new Address(""),
new Uint8(0),
new Uint256(0),
new Uint8(0),
new DynamicArray<>(Address.class),
new DynamicArray<>(Address.class));
this(
Address.DEFAULT.getValue(),
Address.DEFAULT.getValue(),
0,
BigInteger.ZERO,
0,
Collections.emptyList(),
Collections.emptyList());
}

public ProposalInfo(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.fisco.bcos.sdk.v3.test.contract.auth;

import org.fisco.bcos.sdk.v3.codec.datatypes.Address;
import org.fisco.bcos.sdk.v3.contract.auth.po.ProposalInfo;
import org.junit.Assert;
import org.junit.Test;

public class ProposalInfoTest {

@Test
public void testDefaultConstructor() {
ProposalInfo proposalInfo = new ProposalInfo();

Assert.assertEquals(7, proposalInfo.getValue().size());
Assert.assertEquals(
"(address,address,uint8,uint256,uint8,address[],address[])",
proposalInfo.getTypeAsString());
Assert.assertEquals(Address.DEFAULT, proposalInfo.getValue().get(0));
Assert.assertEquals(Address.DEFAULT, proposalInfo.getValue().get(1));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,16 +180,16 @@ public void testProposalInfoStringConstructor() {
}

@Test
public void testProposalInfoDefaultConstructorThrowsOnEmptyAddress() {
// Characterization test: new ProposalInfo() builds new Address("") which calls
// Numeric.toBigInt("") and throws NumberFormatException. Documents current behavior of the
// no-arg constructor (a possible latent issue on the chain-decode path).
try {
new ProposalInfo();
Assert.fail("expected NumberFormatException from empty Address");
} catch (NumberFormatException expected) {
// expected
}
public void testProposalInfoDefaultConstructorSucceeds() {
// The no-arg constructor now delegates to the 7-arg constructor using zero-address defaults,
// so it must not throw and must initialize all POJO fields.
ProposalInfo proposalInfo = new ProposalInfo();
Assert.assertNotNull(proposalInfo);
Assert.assertEquals(7, proposalInfo.getValue().size());
Assert.assertNotNull(proposalInfo.getResourceId());
Assert.assertNotNull(proposalInfo.getProposer());
Assert.assertNotNull(proposalInfo.getAgreeVoters());
Assert.assertNotNull(proposalInfo.getAgainstVoters());
}

// ----------------------------------------------------------------------------------
Expand Down
Loading