diff --git a/fab3/ethservice.go b/fab3/ethservice.go index 8046db49..f612a777 100644 --- a/fab3/ethservice.go +++ b/fab3/ethservice.go @@ -601,11 +601,11 @@ func (s *ethService) GetFilterChanges(_ *http.Request, filterID *types.FilterID, func (s *ethService) GetFilterLogs(_ *http.Request, filterID *types.FilterID, alwaysLogs *[]interface{}) error { id := filterID.ID - var f logsFilter + var f *logsFilter // get the filter s.filterMapLock.Lock() if e, ok := s.filterMap[id]; ok { - if f, ok := e.(*logsFilter); !ok { + if f, ok = e.(*logsFilter); !ok { s.filterMapLock.Unlock() return fmt.Errorf("Filter id %d is not for retrieving logs, it is %T", id, f) } @@ -620,7 +620,7 @@ func (s *ethService) GetFilterLogs(_ *http.Request, filterID *types.FilterID, al // delegate to existing function var removed bool s.UninstallFilter(nil, filterID, &removed) - return fmt.Errorf("No filter found for id %d", id) + return fmt.Errorf("U No filter found for id %d", id) } // use the filter var logs []types.Log diff --git a/fab3/ethservice_test.go b/fab3/ethservice_test.go index b29138a2..fe7a0da4 100644 --- a/fab3/ethservice_test.go +++ b/fab3/ethservice_test.go @@ -1483,10 +1483,29 @@ var _ = Describe("Ethservice", func() { }) }) - Context("logsFilter", func() { + Context("getFilterLogs", func() { + BeforeEach(func() { + By("setting the legder up to have one block") + mockLedgerClient.QueryInfoReturns(&fab.BlockchainInfoResponse{BCI: &common.BlockchainInfo{Height: 1}}, nil) + }) + + It("errors on asking for a newBlock filter", func() { + var reply string + By("Installing a newBlock filter") + Expect(ethservice.NewBlockFilter(&http.Request{}, nil, &reply)).ToNot(HaveOccurred()) + id, err := strconv.ParseUint(reply, 0, 16) + Expect(err).ToNot(HaveOccurred()) + + filter := types.FilterID{ID: id} + + var ret []interface{} + Expect(ethservice.GetFilterLogs(&http.Request{}, &filter, &ret)).To(HaveOccurred()) + }) + It("gets logs the same way as GetLogs", func() { var logsArgs *types.GetLogsArgs = &types.GetLogsArgs{} var reply string + By("creating the filter with default args") Expect(ethservice.NewFilter(&http.Request{}, logsArgs, &reply)).ToNot(HaveOccurred()) id, err := strconv.ParseUint(reply, 0, 16)