Forking what is left of ZeroNet and hopefully adding an AT Proto Frontend/Proxy
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix and test bootstrapper hash cache reload from db

+23 -1
+1 -1
plugins/disabled-Bootstrapper/BootstrapperDb.py
··· 26 26 27 27 def updateHashCache(self): 28 28 res = self.execute("SELECT * FROM hash") 29 - self.hash_ids = {str(row["hash"]): row["hash_id"] for row in res} 29 + self.hash_ids = {row["hash"]: row["hash_id"] for row in res} 30 30 self.log.debug("Loaded %s hash_ids" % len(self.hash_ids)) 31 31 32 32 def checkTables(self):
+22
plugins/disabled-Bootstrapper/Test/TestBootstrapper.py
··· 27 27 28 28 @pytest.mark.usefixtures("resetSettings") 29 29 class TestBootstrapper: 30 + def testHashCache(self, file_server, bootstrapper_db): 31 + ip_type = helper.getIpType(file_server.ip) 32 + peer = Peer(file_server.ip, 1544, connection_server=file_server) 33 + hash1 = hashlib.sha256(b"site1").digest() 34 + hash2 = hashlib.sha256(b"site2").digest() 35 + hash3 = hashlib.sha256(b"site3").digest() 36 + 37 + # Verify empty result 38 + res = peer.request("announce", { 39 + "hashes": [hash1, hash2], 40 + "port": 15441, "need_types": [ip_type], "need_num": 10, "add": [ip_type] 41 + }) 42 + 43 + assert len(res["peers"][0][ip_type]) == 0 # Empty result 44 + 45 + hash_ids_before = bootstrapper_db.hash_ids.copy() 46 + 47 + bootstrapper_db.updateHashCache() 48 + 49 + assert hash_ids_before == bootstrapper_db.hash_ids 50 + 51 + 30 52 def testBootstrapperDb(self, file_server, bootstrapper_db): 31 53 ip_type = helper.getIpType(file_server.ip) 32 54 peer = Peer(file_server.ip, 1544, connection_server=file_server)