Skip to content

Commit

Permalink
[blockchain] add uni tests for runnable.go (#4172)
Browse files Browse the repository at this point in the history
Co-authored-by: CoderZhi <thecoderzhi@gmail.com>
  • Loading branch information
millken and CoderZhi authored Mar 10, 2024
1 parent 0fc3f59 commit 8f5e47f
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions blockchain/block/runnable_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package block

import (
"encoding/hex"
"math/big"
"testing"

"github.com/iotexproject/go-pkgs/hash"
"github.com/iotexproject/iotex-core/action"
"github.com/iotexproject/iotex-core/test/identityset"
"github.com/stretchr/testify/require"
)

func TestRunnableActionsBuilder(t *testing.T) {
require := require.New(t)
data, err := hex.DecodeString("")
require.NoError(err)
v, err := action.NewExecution("", 0, big.NewInt(10), uint64(10), big.NewInt(10), data)
require.NoError(err)
ra := NewRunnableActionsBuilder()
bd := &action.EnvelopeBuilder{}
elp := bd.SetGasPrice(big.NewInt(10)).
SetGasLimit(uint64(100000)).
SetAction(v).Build()

selp, err := action.Sign(elp, identityset.PrivateKey(28))
require.NoError(err)
ra.AddActions(selp)
racs := ra.Build()
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())
require.Equal(1, len(racs.Actions()))
act := racs.Actions()[0]
require.Equal(big.NewInt(10), act.GasPrice())
require.Equal(uint64(100000), act.GasLimit())
}

0 comments on commit 8f5e47f

Please sign in to comment.