Panic if connecting to geth subscription fails
This commit is contained in:
parent
0cc90a1f80
commit
9226e53e0b
@ -40,8 +40,8 @@ func (fetcher *GethRpcStorageFetcher) FetchStorageDiffs(out chan<- utils.Storage
|
|||||||
ethStatediffPayloadChan := fetcher.statediffPayloadChan
|
ethStatediffPayloadChan := fetcher.statediffPayloadChan
|
||||||
clientSubscription, clientSubErr := fetcher.streamer.Stream(ethStatediffPayloadChan)
|
clientSubscription, clientSubErr := fetcher.streamer.Stream(ethStatediffPayloadChan)
|
||||||
if clientSubErr != nil {
|
if clientSubErr != nil {
|
||||||
logrus.Warn("Error creating a geth client subscription: ", clientSubErr)
|
|
||||||
errs <- clientSubErr
|
errs <- clientSubErr
|
||||||
|
panic(fmt.Sprintf("Error creating a geth client subscription: %v", clientSubErr))
|
||||||
}
|
}
|
||||||
logrus.Info("Successfully created a geth client subscription: ", clientSubscription)
|
logrus.Info("Successfully created a geth client subscription: ", clientSubscription)
|
||||||
|
|
||||||
|
@ -68,10 +68,15 @@ var _ = Describe("Geth RPC Storage Fetcher", func() {
|
|||||||
errorChan = make(chan error)
|
errorChan = make(chan error)
|
||||||
})
|
})
|
||||||
|
|
||||||
It("adds errors to error channel if the RPC subscription fails ", func(done Done) {
|
It("adds errors to error channel if the RPC subscription fails and panics", func(done Done) {
|
||||||
streamer.SetSubscribeError(fakes.FakeError)
|
streamer.SetSubscribeError(fakes.FakeError)
|
||||||
|
|
||||||
go statediffFetcher.FetchStorageDiffs(storagediffChan, errorChan)
|
go func() {
|
||||||
|
failedSub := func() {
|
||||||
|
statediffFetcher.FetchStorageDiffs(storagediffChan, errorChan)
|
||||||
|
}
|
||||||
|
Expect(failedSub).To(Panic())
|
||||||
|
}()
|
||||||
|
|
||||||
Expect(<-errorChan).To(MatchError(fakes.FakeError))
|
Expect(<-errorChan).To(MatchError(fakes.FakeError))
|
||||||
close(done)
|
close(done)
|
||||||
|
@ -100,7 +100,6 @@ var _ = Describe("Geth Storage Watcher", func() {
|
|||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
mockFetcher.DiffsToReturn = []utils.StorageDiff{gethDiff}
|
mockFetcher.DiffsToReturn = []utils.StorageDiff{gethDiff}
|
||||||
storageWatcher = watcher.NewGethStorageWatcher(mockFetcher, test_config.NewTestDB(test_config.NewTestNode()))
|
storageWatcher = watcher.NewGethStorageWatcher(mockFetcher, test_config.NewTestDB(test_config.NewTestNode()))
|
||||||
storageWatcher.SetStorageDiffSource("geth")
|
|
||||||
storageWatcher.Queue = mockQueue
|
storageWatcher.Queue = mockQueue
|
||||||
storageWatcher.AddTransformers([]transformer.StorageTransformerInitializer{mockTransformer.FakeTransformerInitializer})
|
storageWatcher.AddTransformers([]transformer.StorageTransformerInitializer{mockTransformer.FakeTransformerInitializer})
|
||||||
})
|
})
|
||||||
@ -193,7 +192,6 @@ var _ = Describe("Geth Storage Watcher", func() {
|
|||||||
mockQueue.DiffsToReturn = []utils.StorageDiff{gethDiff}
|
mockQueue.DiffsToReturn = []utils.StorageDiff{gethDiff}
|
||||||
storageWatcher = watcher.NewGethStorageWatcher(mockFetcher, test_config.NewTestDB(test_config.NewTestNode()))
|
storageWatcher = watcher.NewGethStorageWatcher(mockFetcher, test_config.NewTestDB(test_config.NewTestNode()))
|
||||||
storageWatcher.Queue = mockQueue
|
storageWatcher.Queue = mockQueue
|
||||||
storageWatcher.SetStorageDiffSource("geth")
|
|
||||||
storageWatcher.AddTransformers([]transformer.StorageTransformerInitializer{mockTransformer.FakeTransformerInitializer})
|
storageWatcher.AddTransformers([]transformer.StorageTransformerInitializer{mockTransformer.FakeTransformerInitializer})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user