github.com/iotexproject/iotex-core@v1.14.1-rc1/blockchain/block/runnable_test.go (about) 1 package block 2 3 import ( 4 "encoding/hex" 5 "math/big" 6 "testing" 7 8 "github.com/iotexproject/go-pkgs/hash" 9 "github.com/iotexproject/iotex-core/action" 10 "github.com/iotexproject/iotex-core/test/identityset" 11 "github.com/stretchr/testify/require" 12 ) 13 14 func TestRunnableActionsBuilder(t *testing.T) { 15 require := require.New(t) 16 data, err := hex.DecodeString("") 17 require.NoError(err) 18 v, err := action.NewExecution("", 0, big.NewInt(10), uint64(10), big.NewInt(10), data) 19 require.NoError(err) 20 ra := NewRunnableActionsBuilder() 21 bd := &action.EnvelopeBuilder{} 22 elp := bd.SetGasPrice(big.NewInt(10)). 23 SetGasLimit(uint64(100000)). 24 SetAction(v).Build() 25 26 selp, err := action.Sign(elp, identityset.PrivateKey(28)) 27 require.NoError(err) 28 ra.AddActions(selp) 29 racs := ra.Build() 30 require.Equal(hash.Hash256{0x76, 0x6d, 0x8b, 0x5b, 0x98, 0xa5, 0xb2, 0xdb, 0x8d, 0x99, 0x0, 0xd2, 0x9c, 0xd1, 0x31, 0xf1, 0x59, 0xb6, 0x2f, 0x7e, 0x74, 0x6b, 0x92, 0x1b, 0x42, 0x68, 0x97, 0x4a, 0x47, 0x3e, 0x8d, 0xc5}, racs.TxHash()) 31 require.Equal(1, len(racs.Actions())) 32 act := racs.Actions()[0] 33 require.Equal(big.NewInt(10), act.GasPrice()) 34 require.Equal(uint64(100000), act.GasLimit()) 35 }