class ECPrivateKeyTest(unittest.TestCase): reference = _reference_info def setUp(self): self.private_key = ECPrivateKey(self.reference['hex_private_key'], compressed=False) def tearDown(self): pass def test_random_private_key(self): private_key = ECPrivateKey() self.assertTrue(isinstance(private_key, ECPrivateKey)) def test_private_key_from_wif(self): self.private_key_from_wif = ECPrivateKey( self.reference['wif_private_key'], compressed=False) self.assertEqual( self.private_key.to_hex(), self.private_key_from_wif.to_hex()) def test_hex_private_key(self): self.assertEqual( self.private_key.to_hex(), self.reference['hex_private_key']) def test_wif_private_key(self): self.assertEqual( self.private_key.to_wif(), self.reference['wif_private_key']) def test_pem_private_key(self): self.assertEqual( self.private_key.to_pem(), self.reference['pem_private_key']) def test_der_private_key(self): self.assertEqual( self.private_key.to_der(), self.reference['der_private_key'])
class ECPrivateKeyCompressedTest(unittest.TestCase): ref = _compressed_info def setUp(self): self.private_key = ECPrivateKey( self.ref['hex_private_key'], compressed=True) def tearDown(self): pass def test_random_private_key(self): private_key = ECPrivateKey() self.assertTrue(isinstance(private_key, ECPrivateKey)) def test_hex_private_key(self): self.assertEqual(self.private_key.to_hex(), self.ref['hex_private_key']) def test_wif_private_key(self): self.assertEqual(self.private_key.to_wif(), self.ref['wif_private_key']) def test_pem_private_key(self): self.assertEqual(self.private_key.to_pem(), self.ref['pem_private_key']) def test_der_private_key(self): self.assertEqual(self.private_key.to_der(), self.ref['der_private_key']) def test_to_public_key_conversion(self): public_key = self.private_key.public_key() self.assertEqual(public_key.to_hex(), self.ref['hex_public_key']) self.assertEqual(public_key.address(), self.ref['address'])
class ECPrivateKeyTest(unittest.TestCase): reference = _reference_info def setUp(self): self.private_key = ECPrivateKey(self.reference['hex_private_key'], compressed=False) def tearDown(self): pass def test_random_private_key(self): private_key = ECPrivateKey() self.assertTrue(isinstance(private_key, ECPrivateKey)) def test_private_key_from_wif(self): self.private_key_from_wif = ECPrivateKey( self.reference['wif_private_key'], compressed=False) self.assertEqual(self.private_key.to_hex(), self.private_key_from_wif.to_hex()) def test_hex_private_key(self): self.assertEqual(self.private_key.to_hex(), self.reference['hex_private_key']) def test_wif_private_key(self): self.assertEqual(self.private_key.to_wif(), self.reference['wif_private_key']) def test_pem_private_key(self): self.assertEqual(self.private_key.to_pem(), self.reference['pem_private_key']) def test_der_private_key(self): self.assertEqual(self.private_key.to_der(), self.reference['der_private_key'])