Skip to content

Commit

Permalink
test: Fix AllocateRewardTest failure with static seed 37149681
Browse files Browse the repository at this point in the history
  • Loading branch information
s2quake committed Oct 31, 2024
1 parent 7e49661 commit 651299d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions .Lib9c.Tests/Action/ValidatorDelegation/AllocateRewardTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public void Execute_WithoutReward_Throw()
[InlineData(1181126949)]
[InlineData(793705868)]
[InlineData(707058493)]
[InlineData(37149681)]
public void Execute_Theory_WithStaticSeed(int randomSeed)
{
var fixture = new RandomFixture(randomSeed);
Expand Down Expand Up @@ -301,12 +302,13 @@ public RandomFixture(int randomSeed)
ValidatorsInfos = CreateArray(_random.Next(1, 200), i =>
{
var balance = GetRandomFAV(DelegationCurrency, _random);
var flag = _random.Next() % 2 == 0 ? VoteFlag.PreCommit : VoteFlag.Null;
var cash = GetRandomCash(_random, balance);
var flag = i == 0 || _random.Next() % 2 == 0 ? VoteFlag.PreCommit : VoteFlag.Null;
return new ValidatorInfo
{
Key = new PrivateKey(),
Balance = balance,
Cash = GetRandomCash(_random, balance),
Balance = balance < MinimumDelegation ? MinimumDelegation : balance,
Cash = cash < MinimumDelegation ? MinimumDelegation : cash,
VoteFlag = flag,
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ public ValidatorDelegationTestBase()
protected static BlockHash EmptyBlockHash { get; }
= new BlockHash(CreateArray(BlockHash.Size, _ => (byte)0x01));

protected static FungibleAssetValue MinimumDelegation { get; } = DelegationCurrency * 10;

protected PrivateKey AdminKey { get; } = new PrivateKey();

protected IWorld World { get; }

protected FungibleAssetValue MinimumDelegation { get; } = DelegationCurrency * 10;

protected static T[] CreateArray<T>(int length, Func<int, T> creator)
=> Enumerable.Range(0, length).Select(creator).ToArray();

Expand Down

0 comments on commit 651299d

Please sign in to comment.