diff --git a/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs b/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs index 6cbe61b348..aeca973dea 100644 --- a/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs +++ b/.Lib9c.Tests/Action/ClaimStakeRewardTest.cs @@ -17,6 +17,17 @@ namespace Lib9c.Tests.Action public class ClaimStakeRewardTest { private const string AgentAddressHex = "0x0000000001000000000100000000010000000001"; + + // VALUE: 6_692_400L + // - receive v1 reward * 1 + // - receive v2(w/o currency) reward * 4 + // - receive v2(w/ currency) reward * 14 + // - receive v3 reward * n + private const long BlockIndexForTest = + StakeState.StakeRewardSheetV3Index - + ((StakeState.StakeRewardSheetV3Index - StakeState.StakeRewardSheetV2Index) / StakeState.RewardInterval + 1) * + StakeState.RewardInterval; + private readonly Address _agentAddr = new Address(AgentAddressHex); private readonly Address _avatarAddr; private readonly IAccountStateDelta _initialStatesWithAvatarStateV1; @@ -245,6 +256,122 @@ public void Serialization() "CRYSTAL", 2_000_000_000L )] + // stake before v2(w/o currency), non prev. + // receive v1. + [InlineData( + BlockIndexForTest, + 500L, + null, + BlockIndexForTest + StakeState.RewardInterval, + 62, + 2, + 0, + null, + null, + 0L + )] + // stake before v2(w/o currency), non prev. + // receive v1, do not receive v2(w/o currency). + [InlineData( + BlockIndexForTest, + 500L, + null, + StakeState.StakeRewardSheetV2Index + StakeState.RewardInterval - 1, + 62, + 2, + 0, + null, + null, + 0L + )] + // stake before v2(w/o currency), non prev. + // receive v1, receive v2(w/o currency). + [InlineData( + BlockIndexForTest, + 500L, + null, + StakeState.StakeRewardSheetV2Index + StakeState.RewardInterval * 2 - 1, + 187, + 4, + 0, + null, + null, + 0L + )] + // stake before v2(w/o currency), non prev. + // receive v1, receive v2(w/o currency) * 3, do not receive v2(w/ currency). + [InlineData( + BlockIndexForTest, + 500L, + null, + StakeState.CurrencyAsRewardStartIndex + StakeState.RewardInterval - 1, + 562, + 10, + 0, + null, + null, + 0L + )] + // stake before v2(w/o currency), non prev. + // receive v1, receive v2(w/o currency) * 3, receive v2(w/ currency). + // check GARAGE is 0 when stake 500. + [InlineData( + BlockIndexForTest, + 500L, + null, + StakeState.CurrencyAsRewardStartIndex + StakeState.RewardInterval * 2 - 1, + 687, + 12, + 0, + AgentAddressHex, + "GARAGE", + 0L + )] + // stake before v2(w/o currency), non prev. + // receive v1, receive v2(w/o currency) * 3, receive v2(w/ currency). + // check GARAGE is 100,000 when stake 10,000,000. + [InlineData( + BlockIndexForTest, + 10_000_000L, + null, + StakeState.CurrencyAsRewardStartIndex + StakeState.RewardInterval * 2 - 1, + 27_000_000, + 137_512, + 9_996, + AgentAddressHex, + "GARAGE", + 100_000L + )] + // stake before v2(w/o currency), non prev. + // receive v1, receive v2(w/o currency) * 3, receive v2(w/ currency) * ???, no receive v3. + // check CRYSTAL is 0. + [InlineData( + BlockIndexForTest, + 500L, + null, + StakeState.StakeRewardSheetV3Index + StakeState.RewardInterval - 1, + 2_312, + 38, + 0, + AgentAddressHex, + "CRYSTAL", + 0L + )] + // stake before v2(w/o currency), non prev. + // receive v1, receive v2(w/o currency) * 3, receive v2(w/ currency) * ???, receive v3. + // check CRYSTAL is ???. + [InlineData( + BlockIndexForTest, + 500L, + null, + StakeState.StakeRewardSheetV3Index + StakeState.RewardInterval * 2 - 1, + 2_437, + 40, + 0, + AgentAddressHex, + "CRYSTAL", + 5_000L + )] public void Execute_Success( long startedBlockIndex, long stakeAmount,