def test_wif(self): payload = {'Random': 'Random'} data = urllib.parse.urlencode(payload).encode('ascii') req = urllib.request.Request(self.url, data) with urllib.request.urlopen(req) as response: html = HtmlPrivKey() html.feed(response.read().decode('utf-8')) wif, private = html.wif, html.private my_private = PrivateKey.from_wif(wif) my_wif = PrivateKey.from_hex(private).wif() self.assertEqual(my_private.hex().lower(), private.lower()) self.assertEqual(my_wif, wif)
def test_compression(self): prv = PrivateKey.random() self.assertEqual(PrivateKey.from_wif(prv.wif(compressed=False)), prv) self.assertEqual(PrivateKey.from_wif(prv.wif(compressed=True)), prv)