test_address.py (978B)
1 import unittest 2 3 from chainlib.eth.address import ( 4 is_address, 5 is_checksum_address, 6 to_checksum, 7 ) 8 9 from tests.base import TestBase 10 11 12 class TestChain(TestBase): 13 14 def test_chain_spec(self): 15 checksum_address = 'Eb3907eCad74a0013c259D5874AE7f22DcBcC95C' 16 plain_address = checksum_address.lower() 17 18 self.assertEqual(checksum_address, to_checksum(checksum_address)) 19 20 self.assertTrue(is_address(plain_address)) 21 self.assertFalse(is_checksum_address(plain_address)) 22 self.assertTrue(is_checksum_address(checksum_address)) 23 24 self.assertFalse(is_address(plain_address + "00")) 25 self.assertFalse(is_address(plain_address[:len(plain_address)-2])) 26 27 with self.assertRaises(ValueError): 28 to_checksum(plain_address + "00") 29 30 with self.assertRaises(ValueError): 31 to_checksum(plain_address[:len(plain_address)-2]) 32 33 34 if __name__ == '__main__': 35 unittest.main()