validateEvents checks that the correct number of transaction addition events were fired on the pool's event feed.
(events chan NewTxsEvent, count int)
| 121 | // validateEvents checks that the correct number of transaction addition events |
| 122 | // were fired on the pool's event feed. |
| 123 | func validateEvents(events chan NewTxsEvent, count int) error { |
| 124 | var received []*types.Transaction |
| 125 | |
| 126 | for len(received) < count { |
| 127 | select { |
| 128 | case ev := <-events: |
| 129 | received = append(received, ev.Txs...) |
| 130 | case <-time.After(time.Second): |
| 131 | return fmt.Errorf("event #%v not fired", received) |
| 132 | } |
| 133 | } |
| 134 | if len(received) > count { |
| 135 | return fmt.Errorf("more than %d events fired: %v", count, received[count:]) |
| 136 | } |
| 137 | select { |
| 138 | case ev := <-events: |
| 139 | return fmt.Errorf("more than %d events fired: %v", count, ev.Txs) |
| 140 | |
| 141 | case <-time.After(50 * time.Millisecond): |
| 142 | // This branch should be "default", but it's a data race between goroutines, |
| 143 | // reading the event channel and pushing into it, so better wait a bit ensuring |
| 144 | // really nothing gets injected. |
| 145 | } |
| 146 | return nil |
| 147 | } |
| 148 | |
| 149 | func deriveSender(tx *types.Transaction) (common.Address, error) { |
| 150 | return types.Sender(types.HomesteadSigner{}, tx) |
no outgoing calls
no test coverage detected