github.com/iotexproject/iotex-core@v1.14.1-rc1/action/rewardmsg_test.go (about)

     1  // Copyright (c) 2019 IoTeX Foundation
     2  // This source code is provided 'as is' and no warranties are given as to title or non-infringement, merchantability
     3  // or fitness for purpose and, to the extent permitted by law, all liability for your use of the code is disclaimed.
     4  // This source code is governed by Apache License 2.0 that can be found in the LICENSE file.
     5  
     6  package action
     7  
     8  import (
     9  	"math/big"
    10  	"testing"
    11  
    12  	"github.com/stretchr/testify/assert"
    13  	"github.com/stretchr/testify/require"
    14  )
    15  
    16  func TestDonateToRewardingFund(t *testing.T) {
    17  	b := DepositToRewardingFundBuilder{}
    18  	s1 := b.SetAmount(big.NewInt(1)).
    19  		SetData([]byte{2}).
    20  		Build()
    21  	proto := s1.Proto()
    22  	s2 := DepositToRewardingFund{}
    23  	require.NoError(t, s2.LoadProto(proto))
    24  	assert.Equal(t, s1.Amount(), s2.Amount())
    25  	assert.Equal(t, s2.Data(), s2.Data())
    26  }
    27  
    28  func TestClaimFromRewardingFund(t *testing.T) {
    29  	b := ClaimFromRewardingFundBuilder{}
    30  	s1 := b.SetAmount(big.NewInt(1)).
    31  		SetData([]byte{2}).
    32  		Build()
    33  	proto := s1.Proto()
    34  	s2 := ClaimFromRewardingFund{}
    35  	require.NoError(t, s2.LoadProto(proto))
    36  	assert.Equal(t, s1.Amount(), s2.Amount())
    37  	assert.Equal(t, s2.Data(), s2.Data())
    38  }
    39  
    40  func TestGrantBlockReward(t *testing.T) {
    41  	b := GrantRewardBuilder{}
    42  	s1 := b.SetRewardType(BlockReward).SetHeight(1).Build()
    43  	proto := s1.Proto()
    44  	s2 := GrantReward{}
    45  	require.NoError(t, s2.LoadProto(proto))
    46  	assert.Equal(t, s1.RewardType(), s2.RewardType())
    47  }