mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
TEST: Fixed tests
This commit is contained in:
parent
a465709da4
commit
2ef4ea641c
3 changed files with 16 additions and 16 deletions
|
|
@ -78,6 +78,7 @@ func NewTracingHooksFromFirehose(tracer *Firehose) *tracing.Hooks {
|
||||||
OnBlockStart: tracer.OnBlockStart,
|
OnBlockStart: tracer.OnBlockStart,
|
||||||
OnBlockEnd: tracer.OnBlockEnd,
|
OnBlockEnd: tracer.OnBlockEnd,
|
||||||
OnSkippedBlock: tracer.OnSkippedBlock,
|
OnSkippedBlock: tracer.OnSkippedBlock,
|
||||||
|
// TODO: OnClose
|
||||||
|
|
||||||
OnTxStart: tracer.OnTxStart,
|
OnTxStart: tracer.OnTxStart,
|
||||||
OnTxEnd: tracer.OnTxEnd,
|
OnTxEnd: tracer.OnTxEnd,
|
||||||
|
|
@ -108,6 +109,8 @@ func NewTracingHooksFromFirehose(tracer *Firehose) *tracing.Hooks {
|
||||||
|
|
||||||
type FirehoseConfig struct {
|
type FirehoseConfig struct {
|
||||||
ApplyBackwardCompatibility *bool `json:"applyBackwardCompatibility"`
|
ApplyBackwardCompatibility *bool `json:"applyBackwardCompatibility"`
|
||||||
|
// TODO: Add LOGGING on init
|
||||||
|
ConcurrentBlockFlushing bool `json:"concurrentBlockFlushing"`
|
||||||
|
|
||||||
// Only used for testing, only possible through JSON configuration
|
// Only used for testing, only possible through JSON configuration
|
||||||
private *privateFirehoseConfig
|
private *privateFirehoseConfig
|
||||||
|
|
|
||||||
0
eth/tracers/firehose_concurrency.md
Normal file
0
eth/tracers/firehose_concurrency.md
Normal file
|
|
@ -13,6 +13,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFirehose_BlockPrintsToFirehose_SingleBlock(t *testing.T) {
|
func TestFirehose_BlockPrintsToFirehose_SingleBlock(t *testing.T) {
|
||||||
|
|
||||||
f := NewFirehose(&FirehoseConfig{
|
f := NewFirehose(&FirehoseConfig{
|
||||||
ApplyBackwardCompatibility: ptr(false),
|
ApplyBackwardCompatibility: ptr(false),
|
||||||
private: &privateFirehoseConfig{
|
private: &privateFirehoseConfig{
|
||||||
|
|
@ -23,11 +24,9 @@ func TestFirehose_BlockPrintsToFirehose_SingleBlock(t *testing.T) {
|
||||||
f.OnBlockchainInit(params.AllEthashProtocolChanges)
|
f.OnBlockchainInit(params.AllEthashProtocolChanges)
|
||||||
|
|
||||||
blockNumbers := []uint64{123, 124, 125}
|
blockNumbers := []uint64{123, 124, 125}
|
||||||
blockHashes := make([]string, 3)
|
|
||||||
|
|
||||||
for i, blockNum := range blockNumbers {
|
for i, blockNum := range blockNumbers {
|
||||||
f.OnBlockStart(blockEvent(blockNum))
|
f.OnBlockStart(blockEvent(blockNum))
|
||||||
blockHashes[i] = hex.EncodeToString(f.block.Hash) // Store the hash before it gets reset
|
|
||||||
|
|
||||||
f.onTxStart(txEvent(), hex2Hash(fmt.Sprintf("ABCD%d", i)), from, to)
|
f.onTxStart(txEvent(), hex2Hash(fmt.Sprintf("ABCD%d", i)), from, to)
|
||||||
f.OnCallEnter(0, byte(vm.CALL), from, to, nil, 0, nil)
|
f.OnCallEnter(0, byte(vm.CALL), from, to, nil, 0, nil)
|
||||||
|
|
@ -42,23 +41,21 @@ func TestFirehose_BlockPrintsToFirehose_SingleBlock(t *testing.T) {
|
||||||
|
|
||||||
output := f.InternalTestingBuffer().String()
|
output := f.InternalTestingBuffer().String()
|
||||||
|
|
||||||
require.Contains(t, output, "FIRE BLOCK", "expected FIRE BLOCK output not found")
|
outNumber := make([]string, 0)
|
||||||
|
for i, line := range strings.Split(output, "\n") {
|
||||||
for i, blockNum := range blockNumbers {
|
if i == 0 {
|
||||||
require.Contains(t, output, fmt.Sprintf("%d", blockNum),
|
require.Equal(t, "FIRE INIT 3.0 geth 1.15.10", line)
|
||||||
"expected block number %d not found in output", blockNum)
|
continue
|
||||||
require.Contains(t, output, blockHashes[i],
|
|
||||||
"expected block hash for block %d not found in output", blockNum)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
blockNumIndex123 := strings.Index(output, "123")
|
fields := strings.SplitN(line, " ", 4)
|
||||||
blockNumIndex124 := strings.Index(output, "124")
|
if len(fields) >= 3 {
|
||||||
blockNumIndex125 := strings.Index(output, "125")
|
outNumber = append(outNumber, fields[2])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
require.True(t, blockNumIndex123 < blockNumIndex124,
|
require.Contains(t, output, "FIRE BLOCK", "expected FIRE BLOCK output not found")
|
||||||
"Block 123 should appear before block 124 in output")
|
require.Equal(t, []string{"123", "124", "125"}, outNumber)
|
||||||
require.True(t, blockNumIndex124 < blockNumIndex125,
|
|
||||||
"Block 124 should appear before block 125 in output")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFirehose_BlocksPrintToFirehose_MultipleBlocksInOrder(t *testing.T) {
|
func TestFirehose_BlocksPrintToFirehose_MultipleBlocksInOrder(t *testing.T) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue