Skip to content

Commit

Permalink
Fix judgements and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eanzhao committed Jul 1, 2024
1 parent 1cee8b9 commit 3dbd5df
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion contract/AElf.Contracts.Association/Association_Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private void CheckCreateProposalInput(CreateProposalInput input)
// Check the length of title
Assert(input.Title.Length <= AssociationConstants.MaxLengthForTitle, "Title is too long.");
// Check the length of description
Assert(input.Title.Length <= AssociationConstants.MaxLengthForDescription, "Description is too long.");
Assert(input.Description.Length <= AssociationConstants.MaxLengthForDescription, "Description is too long.");
// Check the length of description url
Assert(input.ProposalDescriptionUrl.Length <= AssociationConstants.MaxLengthForProposalDescriptionUrl,
"Description url is too long.");
Expand Down
2 changes: 1 addition & 1 deletion contract/AElf.Contracts.Parliament/Parliament_Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ private void CheckCreateProposalInput(CreateProposalInput input)
// Check the length of title
Assert(input.Title.Length <= ParliamentConstants.MaxLengthForTitle, "Title is too long.");
// Check the length of description
Assert(input.Title.Length <= ParliamentConstants.MaxLengthForDescription, "Description is too long.");
Assert(input.Description.Length <= ParliamentConstants.MaxLengthForDescription, "Description is too long.");
// Check the length of description url
Assert(input.ProposalDescriptionUrl.Length <= ParliamentConstants.MaxLengthForProposalDescriptionUrl,
"Description url is too long.");
Expand Down
2 changes: 1 addition & 1 deletion contract/AElf.Contracts.Referendum/Referendum_Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private void CheckCreateProposalInput(CreateProposalInput input)
// Check the length of title
Assert(input.Title.Length <= ReferendumConstants.MaxLengthForTitle, "Title is too long.");
// Check the length of description
Assert(input.Title.Length <= ReferendumConstants.MaxLengthForDescription, "Description is too long.");
Assert(input.Description.Length <= ReferendumConstants.MaxLengthForDescription, "Description is too long.");
// Check the length of description url
Assert(input.ProposalDescriptionUrl.Length <= ReferendumConstants.MaxLengthForProposalDescriptionUrl,
"Description url is too long.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ public async Task Get_Proposal_Test()
getProposal.Output.ProposalId.ShouldBe(proposalId);
getProposal.Output.OrganizationAddress.ShouldBe(organizationAddress);
getProposal.Output.ToAddress.ShouldBe(TokenContractAddress);
getProposal.Output.Title.ShouldNotBeNullOrEmpty();
getProposal.Output.Description.ShouldNotBeNullOrEmpty();

var transferParam = TransferInput.Parser.ParseFrom(getProposal.Output.Params);
transferParam.Symbol.ShouldBe(transferInput.Symbol);
Expand Down Expand Up @@ -1541,7 +1543,9 @@ private async Task<Hash> CreateProposalAsync(ECKeyPair proposalKeyPair, Address
ToAddress = TokenContractAddress,
Params = transferInput.ToByteString(),
ExpiredTime = BlockTimeProvider.GetBlockTime().AddDays(2),
OrganizationAddress = organizationAddress
OrganizationAddress = organizationAddress,
Title = "Token Transfer",
Description = "Transfer 100 ELF to Tester's address",
};
var parliamentContractStub = GetParliamentContractTester(proposalKeyPair);
var proposal = await parliamentContractStub.CreateProposal.SendAsync(createProposalInput);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ public async Task Get_Proposal_Test()
getProposal.Output.OrganizationAddress.ShouldBe(organizationAddress);
getProposal.Output.ToAddress.ShouldBe(TokenContractAddress);
getProposal.Output.Params.ShouldBe(createInput.ToByteString());
getProposal.Output.Title.ShouldNotBeNullOrEmpty();
getProposal.Output.Description.ShouldNotBeNullOrEmpty();
}

[Fact]
Expand Down Expand Up @@ -1320,7 +1322,9 @@ private async Task<Hash> CreateProposalAsync(ECKeyPair proposalKeyPair, Address
ToAddress = TokenContractAddress,
Params = createInput.ToByteString(),
ExpiredTime = timestamp ?? BlockTimeProvider.GetBlockTime().AddSeconds(1000),
OrganizationAddress = organizationAddress
OrganizationAddress = organizationAddress,
Title = "Create token: NEW",
Description = "Create a new token named NEW."
};
ReferendumContractStub = GetReferendumContractTester(proposalKeyPair);
var proposal = await ReferendumContractStub.CreateProposal.SendAsync(createProposalInput);
Expand Down

0 comments on commit 3dbd5df

Please sign in to comment.