github.com/iotexproject/iotex-core@v1.14.1-rc1/action/grantreward_test.go (about) 1 package action 2 3 import ( 4 "math/big" 5 "testing" 6 7 "github.com/iotexproject/iotex-core/pkg/util/byteutil" 8 "github.com/stretchr/testify/require" 9 ) 10 11 func TestGrandReward(t *testing.T) { 12 require := require.New(t) 13 tests := []struct { 14 rewardType int 15 height uint64 16 }{ 17 {BlockReward, 100}, 18 {EpochReward, 200}, 19 } 20 for _, test := range tests { 21 g := &GrantReward{ 22 rewardType: test.rewardType, 23 height: test.height, 24 } 25 require.Equal(test.rewardType, g.RewardType()) 26 require.Equal(test.height, g.Height()) 27 require.NoError(g.SanityCheck()) 28 require.NoError(g.LoadProto(g.Proto())) 29 intrinsicGas, err := g.IntrinsicGas() 30 require.NoError(err) 31 require.Equal(uint64(0), intrinsicGas) 32 cost, err := g.Cost() 33 require.NoError(err) 34 require.Equal(big.NewInt(0), cost) 35 ethTx, err := g.ToEthTx(0) 36 require.NoError(err) 37 require.NotNil(ethTx) 38 require.Equal(byteutil.Must(g.EncodeABIBinary()), ethTx.Data()) 39 require.Equal(big.NewInt(0), ethTx.GasPrice()) 40 require.Equal(uint64(0), ethTx.Gas()) 41 require.Equal(big.NewInt(0), ethTx.Value()) 42 require.Equal(_rewardingProtocolEthAddr.Hex(), ethTx.To().Hex()) 43 } 44 }