Skip to content

Commit

Permalink
add more unit test for "claim_stake_reward8"
Browse files Browse the repository at this point in the history
  • Loading branch information
boscohyun committed Aug 29, 2023
1 parent d4a9834 commit 210b3b0
Showing 1 changed file with 127 additions and 0 deletions.
127 changes: 127 additions & 0 deletions .Lib9c.Tests/Action/ClaimStakeRewardTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 210b3b0

Please sign in to comment.