diff --git a/process/block/preprocess/basePreProcess.go b/process/block/preprocess/basePreProcess.go index a928ab7e23b..cbee99359e5 100644 --- a/process/block/preprocess/basePreProcess.go +++ b/process/block/preprocess/basePreProcess.go @@ -491,7 +491,6 @@ func (bpp *basePreProcess) updateGasConsumedWithGasRefundedAndGasPenalized( func (bpp *basePreProcess) handleProcessTransactionInit(preProcessorExecutionInfoHandler process.PreProcessorExecutionInfoHandler, txHash []byte) int { snapshot := bpp.accounts.JournalLen() preProcessorExecutionInfoHandler.InitProcessedTxsResults(txHash) - bpp.gasHandler.Reset(txHash) return snapshot } diff --git a/process/block/preprocess/basePreProcess_test.go b/process/block/preprocess/basePreProcess_test.go new file mode 100644 index 00000000000..37a826cbfe5 --- /dev/null +++ b/process/block/preprocess/basePreProcess_test.go @@ -0,0 +1,47 @@ +package preprocess + +import ( + "bytes" + "testing" + + "github.com/ElrondNetwork/elrond-go/testscommon" + "github.com/ElrondNetwork/elrond-go/testscommon/state" + "github.com/stretchr/testify/assert" +) + +func TestBasePreProcess_handleProcessTransactionInit(t *testing.T) { + t.Parallel() + + txHash := []byte("tx hash") + initProcessedTxsCalled := false + + preProcessorExecutionInfoHandler := &testscommon.PreProcessorExecutionInfoHandlerMock{ + InitProcessedTxsResultsCalled: func(key []byte) { + if !bytes.Equal(key, txHash) { + return + } + + initProcessedTxsCalled = true + }, + } + + journalLen := 262845 + bp := &basePreProcess{ + accounts: &state.AccountsStub{ + JournalLenCalled: func() int { + return journalLen + }, + }, + gasTracker: gasTracker{ + gasHandler: &testscommon.GasHandlerStub{ + ResetCalled: func(hash []byte) { + assert.Fail(t, "should have not called gasComputation.Reset") + }, + }, + }, + } + + recoveredJournalLen := bp.handleProcessTransactionInit(preProcessorExecutionInfoHandler, txHash) + assert.Equal(t, journalLen, recoveredJournalLen) + assert.True(t, initProcessedTxsCalled) +}