set RewardAddress for candidate to mute warning(#1936)
@@ -334,7 +334,7 @@ func TestProtocol_NoRewardAddr(t *testing.T) {
{
Address: identityset.Address(0).String(),
Votes: unit.ConvertIotxToRau(1000000),
- RewardAddress: "",
+ RewardAddress: identityset.Address(0).String(),
},
{
Address: identityset.Address(1).String(),
@@ -437,28 +437,27 @@ func TestProtocol_NoRewardAddr(t *testing.T) {
require.NoError(t, err)
// Grant block reward
- rewardLog, err := p.GrantBlockReward(ctx, sm)
+ _, err = p.GrantBlockReward(ctx, sm)
require.NoError(t, err)
- require.Nil(t, rewardLog)
availableBalance, _, err := p.AvailableBalance(ctx, sm)
require.NoError(t, err)
- assert.Equal(t, big.NewInt(200), availableBalance)
+ assert.Equal(t, big.NewInt(190), availableBalance)
unclaimedBalance, _, err := p.UnclaimedBalance(ctx, sm, identityset.Address(0))
require.NoError(t, err)
- assert.Equal(t, big.NewInt(0), unclaimedBalance)
+ assert.Equal(t, big.NewInt(10), unclaimedBalance)
// Grant epoch reward
rewardLogs, err := p.GrantEpochReward(ctx, sm)
require.NoError(t, err)
- require.Equal(t, 2, len(rewardLogs))
+ require.Equal(t, 4, len(rewardLogs))
availableBalance, _, err = p.AvailableBalance(ctx, sm)
require.NoError(t, err)
- assert.Equal(t, big.NewInt(145), availableBalance)
+ assert.Equal(t, big.NewInt(80), availableBalance)
unclaimedBalance, _, err = p.UnclaimedBalance(ctx, sm, identityset.Address(0))
require.NoError(t, err)
- assert.Equal(t, big.NewInt(0), unclaimedBalance)
+ assert.Equal(t, big.NewInt(65), unclaimedBalance)
// It doesn't affect others to get reward
unclaimedBalance, _, err = p.UnclaimedBalance(ctx, sm, identityset.Address(1))
require.NoError(t, err)
@@ -467,11 +466,11 @@ func TestProtocol_NoRewardAddr(t *testing.T) {
var rl rewardingpb.RewardLog
require.NoError(t, proto.Unmarshal(rewardLogs[0].Data, &rl))
assert.Equal(t, rewardingpb.RewardLog_EPOCH_REWARD, rl.Type)
- assert.Equal(t, identityset.Address(1).String(), rl.Addr)
+ assert.Equal(t, identityset.Address(0).String(), rl.Addr)
assert.Equal(t, "50", rl.Amount)
require.Equal(t, p.addr.String(), rewardLogs[1].Address)
require.NoError(t, proto.Unmarshal(rewardLogs[1].Data, &rl))
- assert.Equal(t, rewardingpb.RewardLog_FOUNDATION_BONUS, rl.Type)
+ assert.Equal(t, rewardingpb.RewardLog_EPOCH_REWARD, rl.Type)
assert.Equal(t, identityset.Address(1).String(), rl.Addr)
- assert.Equal(t, "5", rl.Amount)
+ assert.Equal(t, "50", rl.Amount)
}
