Skip to content

Conversation

@EnriqueL8
Copy link
Contributor

@EnriqueL8 EnriqueL8 commented Dec 12, 2025

There was a race condition in the test on the way the consumers are added and we way for that , a cursor breakdown was useful

Timeline:
────────────────────────────────────────────────────────────────────
Test calls bl.addConsumer()
    │
    ├─► checkAndStartListenerLoop() ─► starts listener goroutine
    │
    ├─► waitUntilStarted() ◄─── BLOCKS HERE
    │                               │
    │       ┌───────────────────────┘
    │       │   Listener goroutine runs:
    │       │     1. eth_blockNumber ✓
    │       │     2. eth_newBlockFilter ✓
    │       │     3. eth_getFilterChanges ← conditionalMockOnce checks consumers
    │       │                               len(bl.consumers) == 0 ❌
    │       │                               Returns EMPTY array!
    │       │     4. markStarted() ← unblocks waitUntilStarted
    │       └───────────────────────┐
    │                               │
    ├─► waitUntilStarted() returns ◄┘
    │
    └─► bl.consumers[id] = consumer  ← Consumer added TOO LATE!

Test waits on: bu := <-updates  ← Never receives anything, TIMEOUT!

@EnriqueL8 EnriqueL8 requested a review from a team as a code owner December 12, 2025 10:56
@EnriqueL8
Copy link
Contributor Author

The other way to fix this is by adding a dummy mRPC.On("CallRPC", mock.Anything, mock.Anything, "eth_getFilterChanges", mock.Anything).Return(nil).Once() infront

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants