Repository: tellor-io/telliot-feeds (language: python)

Issue:
Use new submission value count function
The interval reporter / DIVA reporter both are using `getTimestampCountById`, which is no longer in the updated contracts:
```python
async def get_num_reports_by_id(self, query_id: bytes) -> Tuple[int, ResponseStatus]:
        count, read_status = await self.oracle.read(func_name="getTimestampCountById", _queryId=query_id)
        return count, read_status
  ```
 Should use some of these:
 "to get a list of reported values:

`getNewValueCountbyQueryId(bytes32 _queryId)`
`getTimestampbyQueryIdandIndex(bytes32 _queryId, uint256 _index)`
`retrieveData(bytes32 _queryId, uint256 _timestamp)`

this will include disputed values. a disputed value gets overwritten to bytes(""). to check if a value is disputed:
`isInDispute(bytes32 _queryId, uint256 _timestamp)`"


Discussion / hints:

Fix patch:
diff --git a/src/telliot_feeds/reporters/interval.py b/src/telliot_feeds/reporters/interval.py
index 7e5b869b..19a1b538 100644
--- a/src/telliot_feeds/reporters/interval.py
+++ b/src/telliot_feeds/reporters/interval.py
@@ -294,7 +294,7 @@ async def fetch_datafeed(self) -> Optional[DataFeed[Any]]:
         return self.datafeed
 
     async def get_num_reports_by_id(self, query_id: bytes) -> Tuple[int, ResponseStatus]:
-        count, read_status = await self.oracle.read(func_name="getTimestampCountById", _queryId=query_id)
+        count, read_status = await self.oracle.read(func_name="getNewValueCountbyQueryId", _queryId=query_id)
         return count, read_status
 
     async def is_online(self) -> bool:
diff --git a/src/telliot_feeds/reporters/tellor_flex.py b/src/telliot_feeds/reporters/tellor_flex.py
index e36cad7f..640d1ddd 100644
--- a/src/telliot_feeds/reporters/tellor_flex.py
+++ b/src/telliot_feeds/reporters/tellor_flex.py
@@ -208,10 +208,6 @@ async def check_reporter_lock(self) -> ResponseStatus:
 
         return ResponseStatus()
 
-    async def get_num_reports_by_id(self, query_id: bytes) -> Tuple[int, ResponseStatus]:
-        count, read_status = await self.oracle.read(func_name="getNewValueCountbyQueryId", _queryId=query_id)
-        return count, read_status
-
     async def rewards(self) -> int:
         tip = 0
         datafeed: DataFeed[Any] = self.datafeed  # type: ignore


Test patch:
diff --git a/tests/reporters/test_360_reporter.py b/tests/reporters/test_360_reporter.py
index a7f3b4fd..62a75cda 100644
--- a/tests/reporters/test_360_reporter.py
+++ b/tests/reporters/test_360_reporter.py
@@ -1,5 +1,7 @@
 import pytest
 
+from telliot_feeds.feeds.eth_usd_feed import eth_usd_median_feed
+from telliot_feeds.feeds.snapshot_feed import snapshot_manual_feed
 from telliot_feeds.reporters.rewards.time_based_rewards import get_time_based_rewards
 from telliot_feeds.reporters.tellor_360 import Tellor360Reporter
 
@@ -142,3 +144,38 @@ async def test_no_native_token(tellor_360, caplog):
     await reporter.report(report_count=1)
 
     assert "insufficient native token funds" in caplog.text.lower()
+
+
+@pytest.mark.asyncio
+async def test_checks_reporter_lock_when_manual_source(tellor_360, monkeypatch, caplog):
+    """Test reporter lock check when reporting for a tip that requires a manaul data source"""
+    contracts, account = tellor_360
+
+    reporter_kwargs = {
+        "oracle": contracts.oracle,
+        "token": contracts.token,
+        "autopay": contracts.autopay,
+        "endpoint": contracts.oracle.node,
+        "account": account,
+        "chain_id": CHAIN_ID,
+        "transaction_type": 0,
+        "wait_period": 0,
+        "min_native_token_balance": 0,
+    }
+
+    # mock get_feed_and_tip, which is called in the Tellor360Reporter.fetch_datafeed method
+    async def mock_get_feed_and_tip(*args, **kwargs):
+        return [snapshot_manual_feed, int(1e18)]
+
+    monkeypatch.setattr("telliot_feeds.reporters.tellor_360.get_feed_and_tip", mock_get_feed_and_tip)
+    reporter = Tellor360Reporter(**reporter_kwargs)
+
+    # report once to trigger reporter lock next time
+    reporter.datafeed = eth_usd_median_feed
+    _, status = await reporter.report_once()
+    assert status.ok
+
+    # set datafeed to None so fetch_datafeed will call get_feed_and_tip
+    reporter.datafeed = None
+    await reporter.report(report_count=1)
+    assert "Currently in reporter lock. Time left: 11:59" in caplog.text
diff --git a/tests/reporters/test_interval_reporter.py b/tests/reporters/test_interval_reporter.py
index 20a1f494..f102d0f1 100644
--- a/tests/reporters/test_interval_reporter.py
+++ b/tests/reporters/test_interval_reporter.py
@@ -46,7 +46,7 @@ async def test_get_fee_info(tellor_flex_reporter):
 @pytest.mark.asyncio
 async def test_get_num_reports_by_id(tellor_flex_reporter):
     r = tellor_flex_reporter
-    num, status = await r.get_num_reports_by_id(r.datafeed.query.query_id)
+    num, status = await r.get_num_reports_by_id(eth_usd_median_feed.query.query_id)
 
     assert isinstance(status, ResponseStatus)