Skip to content

Commit

Permalink
test: Fix build errors in test
Browse files Browse the repository at this point in the history
  • Loading branch information
s2quake committed Dec 19, 2024
1 parent ef8fb48 commit c3bc1fd
Show file tree
Hide file tree
Showing 18 changed files with 52 additions and 52 deletions.
4 changes: 2 additions & 2 deletions .Lib9c.Tests/Action/Guild/ClaimRewardTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ private void ExecuteWithFixture(IClaimRewardFixture fixture)
// Calculate expected values for comparison with actual values.
var expectedRepository = new ValidatorRepository(world, actionContext);
var expectedGuildRepository = new GuildRepository(expectedRepository);
var expectedDelegatee = expectedRepository.GetValidatorDelegatee(validatorKey.Address);
var expectedDelegatee = expectedRepository.GetDelegatee(validatorKey.Address);
var expectedTotalShares = expectedDelegatee.TotalShares;
var expectedValidatorShare
= expectedRepository.GetBond(expectedDelegatee, validatorKey.Address).Share;
Expand Down Expand Up @@ -346,7 +346,7 @@ var expectedProposerReward
// Then
var validatorRepository = new ValidatorRepository(world, actionContext);
var guildRepository = new GuildRepository(world, actionContext);
var delegatee = validatorRepository.GetValidatorDelegatee(validatorKey.Address);
var delegatee = validatorRepository.GetDelegatee(validatorKey.Address);
var actualRemainGuildReward = world.GetBalance(delegatee.RewardRemainderPoolAddress, GuildAllocateRewardCurrency);
var actualValidatorBalance = world.GetBalance(StakeState.DeriveAddress(validatorKey.Address), DelegationCurrency);
var actualValidatorGuildReward = world.GetBalance(validatorKey.Address, GuildAllocateRewardCurrency);
Expand Down
2 changes: 1 addition & 1 deletion .Lib9c.Tests/Action/StakeTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ private IWorld Execute(
if (guildRepository.TryGetGuildParticipant(new AgentAddress(signer), out var guildParticipant))
{
var guild = guildRepository.GetGuild(guildParticipant.GuildAddress);
var validator = guildRepository.GetGuildDelegatee(guild.ValidatorAddress);
var validator = guildRepository.GetDelegatee(guild.ValidatorAddress);
var bond = guildRepository.GetBond(validator, signer);
var amountNCG = _ncg * amount;
var expectedGG = DelegationUtil.GetGuildCoinFromNCG(amountNCG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ var expectedProposerReward
}

var validatorAddress = vote.ValidatorPublicKey.Address;
var actualDelegatee = actualRepository.GetValidatorDelegatee(validatorAddress);
var actualDelegatee = actualRepository.GetDelegatee(validatorAddress);
var validatorRewardAddress = actualDelegatee.DistributionPoolAddress();
var actualDelegationBalance = world.GetBalance(validatorAddress, DelegationCurrency);
var actualCommission = world.GetBalance(validatorAddress, GuildAllocateRewardCurrency);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void Execute()

// Then
var repository = new ValidatorRepository(world, actionContext);
var validator = repository.GetValidatorDelegatee(validatorKey.Address);
var validator = repository.GetDelegatee(validatorKey.Address);
var bond = repository.GetBond(validator, validatorKey.Address);
var validatorList = repository.GetValidatorList();

Expand Down Expand Up @@ -222,7 +222,7 @@ private void ExecuteWithFixture(IDelegateValidatorFixture fixture)

// When
var expectedRepository = new ValidatorRepository(world, new ActionContext());
var expectedValidator = expectedRepository.GetValidatorDelegatee(validatorKey.Address);
var expectedValidator = expectedRepository.GetDelegatee(validatorKey.Address);
var expectedValidatorBalance = validatorBalance - validatorCash - validatorCashToDelegate;
var expectedPower = validatorCash.RawValue + validatorCashToDelegate.RawValue;

Expand All @@ -237,7 +237,7 @@ private void ExecuteWithFixture(IDelegateValidatorFixture fixture)

// Then
var actualRepository = new ValidatorRepository(world, actionContext);
var actualValidator = actualRepository.GetValidatorDelegatee(validatorKey.Address);
var actualValidator = actualRepository.GetDelegatee(validatorKey.Address);
var actualValidatorBalance = GetBalance(world, validatorKey.Address);
var actualPower = actualValidator.Power;
var actualBond = actualRepository.GetBond(actualValidator, validatorKey.Address);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void Execute()

// Then
var repository = new ValidatorRepository(world, actionContext);
var validator = repository.GetValidatorDelegatee(validatorKey.Address);
var validator = repository.GetDelegatee(validatorKey.Address);
var bond = repository.GetBond(validator, validatorKey.Address);
var validatorList = repository.GetValidatorList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void Execute()

// When
var expectedRepository = new GuildRepository(world, actionContext);
var expectedDelegatee = expectedRepository.GetGuildDelegatee(validatorKey.Address);
var expectedDelegatee = expectedRepository.GetDelegatee(validatorKey.Address);
var expectedUnbondingSet = expectedRepository.GetUnbondingSet();
var expectedReleaseCount = expectedUnbondingSet.UnbondingRefs.Count;
var expectedDepositGold = expectedDelegatee.FAVFromShare(share);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void Execute()

// Then
var actualRepository = new ValidatorRepository(world, actionContext);
var actualDelegatee = actualRepository.GetValidatorDelegatee(validatorKey.Address);
var actualDelegatee = actualRepository.GetDelegatee(validatorKey.Address);
var actualPercentage = actualDelegatee.CommissionPercentage;

Assert.Equal(11, actualPercentage);
Expand Down Expand Up @@ -119,7 +119,7 @@ public void Execute_Theory(int oldCommissionPercentage, int newCommissionPercent

// Then
var actualRepository = new ValidatorRepository(world, actionContext);
var actualDelegatee = actualRepository.GetValidatorDelegatee(validatorKey.Address);
var actualDelegatee = actualRepository.GetDelegatee(validatorKey.Address);
var actualPercentage = actualDelegatee.CommissionPercentage;

Assert.Equal(newCommissionPercentage, actualPercentage);
Expand Down Expand Up @@ -235,7 +235,7 @@ public void Execute_Theory_WitValue(int period)

// Then
var actualRepository = new ValidatorRepository(world, actionContext);
var actualDelegatee = actualRepository.GetValidatorDelegatee(validatorKey.Address);
var actualDelegatee = actualRepository.GetDelegatee(validatorKey.Address);
var actualPercentage = actualDelegatee.CommissionPercentage;

Assert.Equal(expectedCommission, actualPercentage);
Expand Down Expand Up @@ -280,7 +280,7 @@ public void Execute_With_SameValue_Throw()

// When
var repository = new ValidatorRepository(world, new ActionContext());
var delegatee = repository.GetValidatorDelegatee(validatorKey.Address);
var delegatee = repository.GetDelegatee(validatorKey.Address);
var commissionPercentage = delegatee.CommissionPercentage;
var setValidatorCommission = new SetValidatorCommission(
commissionPercentage: commissionPercentage);
Expand Down
14 changes: 7 additions & 7 deletions .Lib9c.Tests/Action/ValidatorDelegation/SlashValidatorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void Execute()

// When
var expectedRepository = new ValidatorRepository(world, actionContext);
var expectedDelegatee = expectedRepository.GetValidatorDelegatee(validatorKey.Address);
var expectedDelegatee = expectedRepository.GetDelegatee(validatorKey.Address);
var expectedValidatorShare = expectedRepository.GetBond(
expectedDelegatee, validatorKey.Address).Share;

Expand Down Expand Up @@ -96,7 +96,7 @@ public void Execute()
// Then
var balance = GetBalance(world, validatorKey.Address);
var actualRepository = new ValidatorRepository(world, actionContext);
var actualDelegatee = actualRepository.GetValidatorDelegatee(validatorKey.Address);
var actualDelegatee = actualRepository.GetDelegatee(validatorKey.Address);
var actualValidatorShare = actualRepository.GetBond(actualDelegatee, validatorKey.Address).Share;

Assert.True(actualDelegatee.Jailed);
Expand Down Expand Up @@ -165,7 +165,7 @@ public void Execute_ByAbstain()

// Then
var repository = new ValidatorRepository(world, actionContext);
var delegatee = repository.GetValidatorDelegatee(validatorKey.Address);
var delegatee = repository.GetDelegatee(validatorKey.Address);
Assert.True(delegatee.Jailed);
Assert.False(delegatee.Tombstoned);
}
Expand All @@ -184,7 +184,7 @@ public void Execute_ToJailedValidator_ThenNothingHappens()

// When
var expectedRepository = new ValidatorRepository(world, actionContext);
var expectedDelegatee = expectedRepository.GetValidatorDelegatee(validatorKey.Address);
var expectedDelegatee = expectedRepository.GetDelegatee(validatorKey.Address);
var expectedJailed = expectedDelegatee.Jailed;
var evidence = CreateDuplicateVoteEvidence(validatorKey, height - 1);
var lastCommit = new BlockCommit(
Expand All @@ -205,7 +205,7 @@ public void Execute_ToJailedValidator_ThenNothingHappens()

// Then
var actualRepository = new ValidatorRepository(world, actionContext);
var actualDelegatee = actualRepository.GetValidatorDelegatee(validatorKey.Address);
var actualDelegatee = actualRepository.GetDelegatee(validatorKey.Address);
var actualJailed = actualDelegatee.Jailed;

Assert.Equal(expectedJailed, actualJailed);
Expand All @@ -224,7 +224,7 @@ public void Execute_ByAbstain_ToJailedValidator_ThenNothingHappens()
world = EnsureJailedValidator(world, validatorKey, ref height);

var expectedRepository = new ValidatorRepository(world, actionContext);
var expectedDelegatee = expectedRepository.GetValidatorDelegatee(validatorKey.Address);
var expectedDelegatee = expectedRepository.GetDelegatee(validatorKey.Address);
var expectedTotalDelegated = expectedDelegatee.TotalDelegated;

// When
Expand All @@ -249,7 +249,7 @@ public void Execute_ByAbstain_ToJailedValidator_ThenNothingHappens()

// Then
var actualRepisitory = new ValidatorRepository(world, actionContext);
var actualDelegatee = actualRepisitory.GetValidatorDelegatee(validatorKey.Address);
var actualDelegatee = actualRepisitory.GetDelegatee(validatorKey.Address);
var actualTotalDelegated = actualDelegatee.TotalDelegated;

Assert.True(actualDelegatee.Jailed);
Expand Down
20 changes: 10 additions & 10 deletions .Lib9c.Tests/Action/ValidatorDelegation/UndelegateValidatorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void Execute()

// When
var expectedRepository = new ValidatorRepository(world, actionContext);
var expectedDelegatee = expectedRepository.GetValidatorDelegatee(validatorKey.Address);
var expectedDelegatee = expectedRepository.GetDelegatee(validatorKey.Address);
var expectedBond = expectedRepository.GetBond(expectedDelegatee, validatorKey.Address);
var undelegateValidator = new UndelegateValidator(expectedBond.Share);
actionContext = new ActionContext
Expand All @@ -66,7 +66,7 @@ public void Execute()
world = undelegateValidator.Execute(actionContext);

var actualRepository = new ValidatorRepository(world, actionContext);
var actualDelegatee = actualRepository.GetValidatorDelegatee(validatorKey.Address);
var actualDelegatee = actualRepository.GetDelegatee(validatorKey.Address);
var actualValidatorList = actualRepository.GetValidatorList();
var actualBond = actualRepository.GetBond(actualDelegatee, validatorKey.Address);

Expand Down Expand Up @@ -182,15 +182,15 @@ public void Execute_FromJailedValidator()
BlockIndex = height,
};
var expectedRepository = new ValidatorRepository(world, actionContext);
var expectedDelegatee = expectedRepository.GetValidatorDelegatee(validatorKey.Address);
var expectedDelegatee = expectedRepository.GetDelegatee(validatorKey.Address);
var expectedBond = expectedRepository.GetBond(expectedDelegatee, validatorKey.Address);

var undelegateValidator = new UndelegateValidator(10);
world = undelegateValidator.Execute(actionContext);

// Then
var actualRepository = new ValidatorRepository(world, actionContext);
var actualDelegatee = actualRepository.GetValidatorDelegatee(validatorKey.Address);
var actualDelegatee = actualRepository.GetDelegatee(validatorKey.Address);
var actualBond = actualRepository.GetBond(actualDelegatee, validatorKey.Address);

Assert.Equal(expectedBond.Share - 10, actualBond.Share);
Expand All @@ -215,15 +215,15 @@ public void Execute_FromTombstonedValidator()
BlockIndex = height,
};
var expectedRepository = new ValidatorRepository(world, actionContext);
var expectedDelegatee = expectedRepository.GetValidatorDelegatee(validatorKey.Address);
var expectedDelegatee = expectedRepository.GetDelegatee(validatorKey.Address);
var expectedBond = expectedRepository.GetBond(expectedDelegatee, validatorKey.Address);

var undelegateValidator = new UndelegateValidator(10);
world = undelegateValidator.Execute(actionContext);

// Then
var actualRepository = new ValidatorRepository(world, actionContext);
var actualDelegatee = actualRepository.GetValidatorDelegatee(validatorKey.Address);
var actualDelegatee = actualRepository.GetDelegatee(validatorKey.Address);
var actualBond = actualRepository.GetBond(actualDelegatee, validatorKey.Address);

Assert.Equal(expectedBond.Share - 10, actualBond.Share);
Expand All @@ -244,7 +244,7 @@ public void Execute_JailsValidatorWhenUndelegationCausesLowDelegation()

// When
var expectedRepository = new ValidatorRepository(world, actionContext);
var expectedDelegatee = expectedRepository.GetValidatorDelegatee(validatorKey.Address);
var expectedDelegatee = expectedRepository.GetDelegatee(validatorKey.Address);
var expectedJailed = expectedDelegatee.Jailed;

var undelegateValidator = new UndelegateValidator(10);
Expand All @@ -258,7 +258,7 @@ public void Execute_JailsValidatorWhenUndelegationCausesLowDelegation()

// Then
var actualRepository = new ValidatorRepository(world, actionContext);
var actualDelegatee = actualRepository.GetValidatorDelegatee(validatorKey.Address);
var actualDelegatee = actualRepository.GetDelegatee(validatorKey.Address);
var actualJailed = actualDelegatee.Jailed;
var actualJailedUntil = actualDelegatee.JailedUntil;

Expand All @@ -280,7 +280,7 @@ private void ExecuteWithFixture(IUndelegateValidatorFixture fixture)

// When
var expectedRepository = new ValidatorRepository(world, new ActionContext());
var expectedValidator = expectedRepository.GetValidatorDelegatee(validatorKey.Address);
var expectedValidator = expectedRepository.GetDelegatee(validatorKey.Address);
var expectedValidatorBalance = validatorBalance - validatorCash;
var expectedValidatorPower = expectedValidator.Power - fixture.ValidatorInfo.SubtractShare;

Expand All @@ -296,7 +296,7 @@ private void ExecuteWithFixture(IUndelegateValidatorFixture fixture)

// Then
var actualRepository = new ValidatorRepository(world, actionContext);
var actualValidator = actualRepository.GetValidatorDelegatee(validatorKey.Address);
var actualValidator = actualRepository.GetDelegatee(validatorKey.Address);
var actualValidatorBalance = GetBalance(world, validatorKey.Address);
var actualValiatorPower = actualValidator.Power;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void Execute()

// Then
var repository = new ValidatorRepository(world, actionContext);
var delegatee = repository.GetValidatorDelegatee(validatorKey.Address);
var delegatee = repository.GetDelegatee(validatorKey.Address);
Assert.False(delegatee.Jailed);
Assert.Equal(-1, delegatee.JailedUntil);
Assert.False(delegatee.Tombstoned);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void Execute_ExcludesTombstonedValidator()
var actualRepository = new ValidatorRepository(world, actionContext);
var actualValidators = actualRepository.GetValidatorList()
.ActiveSet().OrderBy(item => item.OperatorAddress).ToList();
var tombstonedValidator = actualRepository.GetValidatorDelegatee(validatorKeys[0].Address);
var tombstonedValidator = actualRepository.GetDelegatee(validatorKeys[0].Address);

Assert.True(tombstonedValidator.Tombstoned);
Assert.Equal(expectedValidators.Count - 1, actualValidators.Count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ protected static IWorld EnsureJailedValidator(
}

var repository = new ValidatorRepository(world, new ActionContext());
var delegatee = repository.GetValidatorDelegatee(validatorKey.Address);
var delegatee = repository.GetDelegatee(validatorKey.Address);
if (delegatee.Jailed)
{
throw new ArgumentException(
Expand All @@ -280,7 +280,7 @@ protected static IWorld EnsureJailedValidator(
world, validatorKey.PublicKey, lastCommit, blockHeight);
blockHeight++;
repository = new ValidatorRepository(world, new ActionContext());
delegatee = repository.GetValidatorDelegatee(validatorKey.Address);
delegatee = repository.GetDelegatee(validatorKey.Address);
if (delegatee.Jailed)
{
break;
Expand Down Expand Up @@ -326,7 +326,7 @@ protected static IWorld EnsureUnjailedValidator(
}

var repository = new ValidatorRepository(world, new ActionContext());
var delegatee = repository.GetValidatorDelegatee(validatorKey.Address);
var delegatee = repository.GetDelegatee(validatorKey.Address);
if (!delegatee.Jailed)
{
throw new ArgumentException(
Expand Down Expand Up @@ -437,7 +437,7 @@ protected static IWorld EnsureCommissionChangedValidator(

var cooldown = ValidatorDelegatee.CommissionPercentageUpdateCooldown;
var repository = new ValidatorRepository(world, new ActionContext());
var delegatee = repository.GetValidatorDelegatee(validatorKey.Address);
var delegatee = repository.GetDelegatee(validatorKey.Address);
var currentCommission = delegatee.CommissionPercentage;
var increment = commissionPercentage > currentCommission ? 1 : -1;
var preferredHeight = delegatee.CommissionPercentageLastUpdateHeight + cooldown;
Expand Down
4 changes: 2 additions & 2 deletions .Lib9c.Tests/Delegation/DummyDelegatee.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
using Libplanet.Types.Assets;
using Nekoyume.Delegation;

public sealed class DummyDelegatee : Delegatee<DummyDelegator, DummyDelegatee>
public sealed class DummyDelegatee : Delegatee<DummyRepository, DummyDelegatee, DummyDelegator>
{
public DummyDelegatee(Address address, IDelegationRepository repository)
public DummyDelegatee(Address address, DummyRepository repository)
: base(address, repository)
{
}
Expand Down
4 changes: 2 additions & 2 deletions .Lib9c.Tests/Delegation/DummyDelegator.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Libplanet.Crypto;
using Nekoyume.Delegation;

public sealed class DummyDelegator : Delegator<DummyDelegatee, DummyDelegator>
public sealed class DummyDelegator : Delegator<DummyRepository, DummyDelegatee, DummyDelegator>
{
public DummyDelegator(Address address, IDelegationRepository repository)
public DummyDelegator(Address address, DummyRepository repository)
: base(address, repository)
{
}
Expand Down
Loading

0 comments on commit c3bc1fd

Please sign in to comment.