Skip to content

Commit

Permalink
add test for actionByPrice (#4135)
Browse files Browse the repository at this point in the history
  • Loading branch information
envestcc authored Feb 8, 2024
1 parent 78dcdba commit 5b52415
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions actpool/actioniterator/actioniterator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/stretchr/testify/require"

"github.com/iotexproject/go-pkgs/crypto"

"github.com/iotexproject/iotex-core/action"
"github.com/iotexproject/iotex-core/test/identityset"
)
Expand Down Expand Up @@ -99,6 +100,29 @@ func TestActionIterator(t *testing.T) {
require.Equal(appliedActionList, []*action.SealedEnvelope{selp3, selp1, selp2, selp4, selp5, selp6})
}

func TestActionByPrice(t *testing.T) {
require := require.New(t)

s := &actionByPrice{}
require.Equal(0, s.Len())

tsf1, err := action.NewTransfer(uint64(1), big.NewInt(100), "100", nil, uint64(0), big.NewInt(13))
require.NoError(err)
bd := &action.EnvelopeBuilder{}
elp := bd.SetNonce(1).
SetGasPrice(big.NewInt(5)).
SetAction(tsf1).Build()
selp, err := action.Sign(elp, identityset.PrivateKey(28))
require.NoError(err)

s.Push(selp)
require.Equal(1, s.Len())

se := s.Pop()
require.Equal(0, s.Len())
require.Equal(selp, se)
}

func BenchmarkLooping(b *testing.B) {
accMap := make(map[string][]*action.SealedEnvelope)
for i := 0; i < b.N; i++ {
Expand Down

0 comments on commit 5b52415

Please sign in to comment.