Skip to content

Commit

Permalink
New bootstrapper tests announce and backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcutme committed Jan 20, 2019
1 parent 4db723f commit a9608c0
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions plugins/disabled-Bootstrapper/Test/TestBootstrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,41 @@ def testRequestPeers(self, file_server, site, bootstrapper_db, tor_manager):
site.announceTracker("zero", "127.0.0.1:1544")
assert len(site.peers) == 2
assert "bka4ht2bzxchy44r.onion:1234" in site.peers

@pytest.mark.skipif(not pytest.config.getvalue("slow"), reason="--slow not requested (takes around ~ 1min)")
def testAnnounce(self, file_server, tor_manager):
file_server.tor_manager = tor_manager
hash1 = hashlib.sha256("1Nekos4fiBqfcazyG1bAxdBT5oBvA76Z").digest()
hash2 = hashlib.sha256("1EU1tbG9oC1A8jz2ouVwGZyQ5asrNsE4Vr").digest()
peer = Peer("zero.booth.moe", 443, connection_server=file_server)
assert peer.request("ping")
peer = Peer("boot3rdez4rzn36x.onion", 15441, connection_server=file_server)
assert peer.request("ping")
res = peer.request("announce", {
"hashes": [hash1, hash2],
"port": 15441, "need_types": ["ip4", "onion"], "need_num": 100, "add": [""]
})

assert res

def testBackwardCompatibility(self, file_server, bootstrapper_db):
peer = Peer(file_server.ip, 1544, connection_server=file_server)
hash1 = hashlib.sha256("site1").digest()

bootstrapper_db.peerAnnounce("ipv4", file_server.ip_external, port=15441, hashes=[hash1], delete_missing_hashes=True)

# Test with ipv4 need type
res = peer.request("announce", {
"hashes": [hash1],
"port": 15441, "need_types": ["ipv4"], "need_num": 10, "add": []
})

assert len(res["peers"][0]["ipv4"]) == 1

# Test with ip4 need type
res = peer.request("announce", {
"hashes": [hash1],
"port": 15441, "need_types": ["ip4"], "need_num": 10, "add": []
})

assert len(res["peers"][0]["ip4"]) == 1

0 comments on commit a9608c0

Please sign in to comment.