atoulme commented on a change in pull request #274:
URL: https://github.com/apache/incubator-tuweni/pull/274#discussion_r650479294



##########
File path: 
devp2p-eth/src/test/kotlin/org/apache/tuweni/devp2p/eth/EthHandlerTest.kt
##########
@@ -128,22 +128,22 @@ class EthHandlerTest {
         controller = EthController(repository, MemoryTransactionPool(), 
requestsManager)
       )
 
-      for (i in 1..10) {
-        val newBlock = createChildBlock(header)
-        repository.storeBlock(newBlock)
-        var txIndex = 0
-        for (tx in newBlock.body.transactions) {
-          repository.storeTransactionReceipt(
-            TransactionReceipt(
-              Bytes32.random(),
-              32L, LogsBloomFilter(), emptyList()
-            ),
-            txIndex, tx.hash, newBlock.header.hash
-          )
-          txIndex++
-        }
-        header = newBlock.header
-      }
+
+      val newBlock = createChildBlock(header)
+      repository.storeBlock(newBlock)
+      var txIndex = 0
+
+      repository.storeTransactionReceipt(
+        TransactionReceipt(
+          Bytes32.random(),
+          32L, LogsBloomFilter(), emptyList()
+        ),
+        txIndex, newBlock.body.transactions.hash, newBlock.header.hash

Review comment:
       this is not going to compile, the list of transactions doesn't have a 
hash, each transaction has its own hash.
   Is there a reason for modifying this test? Seems unrelated to your changes.

##########
File path: 
eth-repository/src/main/kotlin/org/apache/tuweni/eth/repository/BlockchainIndex.kt
##########
@@ -553,16 +550,16 @@ class BlockchainIndex(private val indexWriter: 
IndexWriter) : BlockchainIndexWri
 
       val topDocs = searcher!!.search(
         TermQuery(Term("_type", "difficulty")),
-        10,
+        HITS,
         Sort(SortField(TOTAL_DIFFICULTY.fieldName, SortField.Type.STRING, 
true))
       )
-
-      for (hit in topDocs.scoreDocs) {
-        val doc = searcher.doc(hit.doc, setOf("_id"))
-        val bytes = doc.getBinaryValue("_id")
+      val doc = searcher.doc(topDocs.scoreDocs.elementAt(0).doc, setOf("_id"))

Review comment:
       What if scoreDocs is empty? Would be good to check the element exists, 
and return null early otherwise.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to