Skip to content

Commit 228c6bd

Browse files
committed
fix: clarify VoteId collision errors and stabilize time-based tests
1 parent 7b82528 commit 228c6bd

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

contract/AElf.Contracts.Vote/VoteContract.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ public override Empty Vote(VoteInput input)
108108
if (existingRecord != null)
109109
{
110110
Assert(input.IsChangeTarget, "VoteId already exists.");
111-
Assert(existingRecord.IsWithdrawn, "VoteId already exists.");
112-
Assert(existingRecord.VotingItemId == input.VotingItemId, "VoteId already exists.");
113-
Assert(existingRecord.Voter == input.Voter, "VoteId already exists.");
111+
Assert(existingRecord.IsWithdrawn, "VoteId already exists and not withdrawn.");
112+
Assert(existingRecord.VotingItemId == input.VotingItemId, "VoteId belongs to a different voting item.");
113+
Assert(existingRecord.Voter == input.Voter, "VoteId belongs to a different voter.");
114114
}
115115

116116
var votingRecord = new VotingRecord

test/AElf.Contracts.Election.Tests/BVT/ElectionTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1301,9 +1301,10 @@ public async Task ElectionContract_Withdraw_Succeeds_When_Delegated_VoteId_Colli
13011301
recordAfterRejectedCollision.Option.ShouldBe(candidatePubkey);
13021302
recordAfterRejectedCollision.IsWithdrawn.ShouldBeFalse();
13031303

1304-
BlockTimeProvider.SetBlockTime(recordAfterRejectedCollision.VoteTimestamp.AddSeconds(lockTime + 1));
1304+
BlockTimeProvider.SetBlockTime(recordAfterRejectedCollision.VoteTimestamp.AddSeconds(lockTime + 1000));
13051305

13061306
var withdrawResult = await WithdrawVotes(voterKeyPair, voteId);
1307+
withdrawResult.Error.ShouldBeEmpty();
13071308
withdrawResult.Status.ShouldBe(TransactionResultStatus.Mined);
13081309

13091310
var electorVote = await ElectionContractStub.GetElectorVoteWithAllRecords.CallAsync(new StringValue

test/AElf.Contracts.Profit.Tests/ProfitTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
using System.Threading.Tasks;
33
using AElf.Contracts.MultiToken;
44
using AElf.CSharp.Core;
5+
using AElf.CSharp.Core.Extension;
6+
using AElf.Kernel;
57
using AElf.Types;
68
using Google.Protobuf.WellKnownTypes;
79
using Shouldly;
@@ -1950,7 +1952,7 @@ await TokenContractStub.Create.SendAsync(new CreateInput
19501952
{ "__seed_owned_symbol", symbol },
19511953
{
19521954
"__seed_exp_time",
1953-
Timestamp.FromDateTime(global::System.DateTime.UtcNow.AddDays(1)).Seconds.ToString()
1955+
TimestampHelper.GetUtcNow().AddHours(1).Seconds.ToString()
19541956
}
19551957
}
19561958
},

0 commit comments

Comments
 (0)