Skip to content

Commit

Permalink
fix tests after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
axenteoctavian committed Jan 30, 2025
1 parent 11c5a7c commit a6f5982
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
22 changes: 12 additions & 10 deletions process/block/preprocess/sovereignChainTransactions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ import (
"errors"
"math/big"
"testing"
"time"

"github.com/multiversx/mx-chain-core-go/data"
"github.com/multiversx/mx-chain-core-go/data/block"
"github.com/multiversx/mx-chain-core-go/data/transaction"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/multiversx/mx-chain-go/common"
"github.com/multiversx/mx-chain-go/process"
state2 "github.com/multiversx/mx-chain-go/state"
Expand All @@ -17,8 +21,6 @@ import (
"github.com/multiversx/mx-chain-go/testscommon/economicsmocks"
"github.com/multiversx/mx-chain-go/testscommon/enableEpochsHandlerMock"
"github.com/multiversx/mx-chain-go/testscommon/state"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func TestTxsPreprocessor_NewSovereignChainTransactionPreprocessorShouldErrNilPreProcessor(t *testing.T) {
Expand Down Expand Up @@ -144,10 +146,10 @@ func TestTxsPreprocessor_CreateAndProcessMiniBlocksShouldWork(t *testing.T) {
args.TxDataPool = &testscommon.ShardedDataStub{
ShardDataStoreCalled: func(id string) (c storage.Cacher) {
return &testscommon.TxCacherStub{
SelectTransactionsWithBandwidthCalled: func(numRequested int, batchSizePerSender int, bandwidthPerSender uint64) []*txcache.WrappedTransaction {
SelectTransactionsCalled: func(_ txcache.SelectionSession, _ uint64, _ int, _ time.Duration) ([]*txcache.WrappedTransaction, uint64) {
return []*txcache.WrappedTransaction{
{Tx: &transaction.Transaction{Nonce: 1}},
}
}, 0
},
}
},
Expand All @@ -169,10 +171,10 @@ func TestTxsPreprocessor_CreateAndProcessMiniBlocksShouldWork(t *testing.T) {
args.TxDataPool = &testscommon.ShardedDataStub{
ShardDataStoreCalled: func(id string) (c storage.Cacher) {
return &testscommon.TxCacherStub{
SelectTransactionsWithBandwidthCalled: func(numRequested int, batchSizePerSender int, bandwidthPerSender uint64) []*txcache.WrappedTransaction {
SelectTransactionsCalled: func(_ txcache.SelectionSession, _ uint64, _ int, _ time.Duration) ([]*txcache.WrappedTransaction, uint64) {
return []*txcache.WrappedTransaction{
{Tx: &transaction.Transaction{Nonce: 1}},
}
}, 0
},
}
},
Expand Down Expand Up @@ -224,12 +226,12 @@ func TestTxsPreprocessor_CreateAndProcessMiniBlocksShouldWork(t *testing.T) {
args.TxDataPool = &testscommon.ShardedDataStub{
ShardDataStoreCalled: func(id string) (c storage.Cacher) {
return &testscommon.TxCacherStub{
SelectTransactionsWithBandwidthCalled: func(numRequested int, batchSizePerSender int, bandwidthPerSender uint64) []*txcache.WrappedTransaction {
SelectTransactionsCalled: func(_ txcache.SelectionSession, _ uint64, _ int, _ time.Duration) ([]*txcache.WrappedTransaction, uint64) {
return []*txcache.WrappedTransaction{
{Tx: tx1, TxHash: txHash1},
{Tx: tx2, TxHash: txHash2},
{Tx: tx3, TxHash: txHash3},
}
}, 0
},
}
},
Expand Down Expand Up @@ -275,10 +277,10 @@ func TestTxsPreprocessor_ComputeSortedTxsShouldWork(t *testing.T) {
args.TxDataPool = &testscommon.ShardedDataStub{
ShardDataStoreCalled: func(id string) (c storage.Cacher) {
return &testscommon.TxCacherStub{
SelectTransactionsWithBandwidthCalled: func(numRequested int, batchSizePerSender int, bandwidthPerSender uint64) []*txcache.WrappedTransaction {
SelectTransactionsCalled: func(_ txcache.SelectionSession, _ uint64, _ int, _ time.Duration) ([]*txcache.WrappedTransaction, uint64) {
return []*txcache.WrappedTransaction{
{Tx: tx, TxHash: txHash},
}
}, 0
},
}
},
Expand Down
26 changes: 11 additions & 15 deletions testscommon/txCacherStub.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
package testscommon

import "github.com/multiversx/mx-chain-go/storage/txcache"
import (
"time"

"github.com/multiversx/mx-chain-go/storage/txcache"
)

type TxCacherStub struct {
CacherStub
SelectTransactionsWithBandwidthCalled func(numRequested int, batchSizePerSender int, bandwidthPerSender uint64) []*txcache.WrappedTransaction
NotifyAccountNonceCalled func(accountKey []byte, nonce uint64)
SelectTransactionsCalled func(session txcache.SelectionSession, gasRequested uint64, maxNum int, selectionLoopMaximumDuration time.Duration) ([]*txcache.WrappedTransaction, uint64)
}

// SelectTransactionsWithBandwidth -
func (tcs *TxCacherStub) SelectTransactionsWithBandwidth(numRequested int, batchSizePerSender int, bandwidthPerSender uint64) []*txcache.WrappedTransaction {
if tcs.SelectTransactionsWithBandwidthCalled != nil {
return tcs.SelectTransactionsWithBandwidthCalled(numRequested, batchSizePerSender, bandwidthPerSender)
// SelectTransactions -
func (tcs *TxCacherStub) SelectTransactions(session txcache.SelectionSession, gasRequested uint64, maxNum int, selectionLoopMaximumDuration time.Duration) ([]*txcache.WrappedTransaction, uint64) {
if tcs.SelectTransactionsCalled != nil {
return tcs.SelectTransactionsCalled(session, gasRequested, maxNum, selectionLoopMaximumDuration)
}

return make([]*txcache.WrappedTransaction, 0)
}

// NotifyAccountNonce -
func (tcs *TxCacherStub) NotifyAccountNonce(accountKey []byte, nonce uint64) {
if tcs.NotifyAccountNonceCalled != nil {
tcs.NotifyAccountNonceCalled(accountKey, nonce)
}
return make([]*txcache.WrappedTransaction, 0), 0
}

0 comments on commit a6f5982

Please sign in to comment.