mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-25 22:26:42 +00:00
TEST: Basic test file for block flushing
This commit is contained in:
parent
4c868888a7
commit
6d558613d7
2 changed files with 33 additions and 7 deletions
|
|
@ -496,12 +496,12 @@ func (f *Firehose) OnBlockEnd(err error) {
|
|||
}
|
||||
|
||||
f.ensureInBlockAndNotInTrx()
|
||||
|
||||
job := &blockPrintJob{
|
||||
block: f.block,
|
||||
finality: f.blockFinality,
|
||||
}
|
||||
f.blockPrintQueue <- job
|
||||
f.printBlockToFirehose(f.block, f.blockFinality)
|
||||
//job := &blockPrintJob{
|
||||
// block: f.block,
|
||||
// finality: f.blockFinality,
|
||||
//}
|
||||
//f.blockPrintQueue <- job
|
||||
|
||||
} else {
|
||||
// An error occurred, could have happen in transaction/call context, we must not check if in trx/call, only check in block
|
||||
|
|
|
|||
|
|
@ -1,9 +1,35 @@
|
|||
package tracers
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/stretchr/testify/require"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFirehoseBlockPrintingOrder(t *testing.T) {
|
||||
func TestFirehose_BlockPrintsToFirehose(t *testing.T) {
|
||||
f := NewFirehose(&FirehoseConfig{
|
||||
ApplyBackwardCompatibility: ptr(false),
|
||||
private: &privateFirehoseConfig{
|
||||
FlushToTestBuffer: true,
|
||||
},
|
||||
})
|
||||
|
||||
f.OnBlockchainInit(params.AllEthashProtocolChanges)
|
||||
|
||||
f.OnBlockStart(blockEvent(123))
|
||||
blockHash := hex.EncodeToString(f.block.Hash) // Store the block hash before it gets reset
|
||||
f.onTxStart(txEvent(), hex2Hash("ABCD"), from, to)
|
||||
f.OnCallEnter(0, byte(vm.CALL), from, to, nil, 0, nil)
|
||||
f.OnBalanceChange(from, b(100), b(50), 0)
|
||||
f.OnCallExit(0, nil, 0, nil, false)
|
||||
f.OnTxEnd(txReceiptEvent(0), nil)
|
||||
f.OnBlockEnd(nil)
|
||||
|
||||
output := f.InternalTestingBuffer().String()
|
||||
|
||||
require.Contains(t, output, "FIRE BLOCK", "expected FIRE BLOCK output not found")
|
||||
require.Contains(t, output, "123", "expected block number not found in output")
|
||||
require.Contains(t, output, blockHash, "expected block hash not found in output")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue