def test_addressing_email(): """Tests making a blockchain address for an email and that it: 1. is a 35-byte non-zero hexadecimal string 2. is unique - a different email yields a different address 3. is deterministic - same email yields same address, even if different case 4. the addresser recognizes the address as an email 5. the addresser can parse the address into its components 6. the identifier is a hash of the email""" email = helper.user.email() address = addresser.email.address(email) assert assert_is_address(address) assert address != addresser.email.address(helper.user.email()) assert address == addresser.email.address(email) assert address == addresser.email.address(email.upper()) assert addresser.get_address_type(address) == addresser.AddressSpace.EMAIL parsed = addresser.parse(address) assert parsed.object_type == addresser.ObjectType.EMAIL assert parsed.related_type == addresser.ObjectType.NONE assert parsed.relationship_type == addresser.RelationshipType.NONE assert assert_is_identifier(parsed.object_id) assert not parsed.related_id assert parsed.object_id == addresser.email.hash(email)
def test_addressing_key(): """Tests making a blockchain address for a public key and that it: 1. is a 35-byte non-zero hexadecimal string 2. is unique - a different public key yields a different address 3. is deterministic - same public key yields same address 4. the addresser recognizes the address as a public key 5. the addresser can parse the address into its components 6. the identifier is a hash of the public key""" key = helper.user.key().public_key address = addresser.key.address(key) assert assert_is_address(address) assert address != addresser.key.address(helper.user.key().public_key) assert address == addresser.key.address(key) assert address == addresser.key.address(key.upper()) assert addresser.get_address_type(address) == addresser.AddressSpace.KEY assert addresser.get_address_type(address) == addresser.AddressSpace.KEY parsed = addresser.parse(address) assert parsed.object_type == addresser.ObjectType.KEY assert parsed.related_type == addresser.ObjectType.NONE assert parsed.relationship_type == addresser.RelationshipType.NONE assert assert_is_identifier(parsed.object_id) assert not parsed.related_id assert parsed.object_id == addresser.key.hash(key)
def test_addressing_user_key(): """Tests making a blockchain address that is a user-key assignment: 1. is a 35-byte non-zero hexadecimal string 2. is unique - a different public user-key yields a different address 3. is deterministic - same public user-key yields same address 4. the addresser recognizes the address as a user-key 5. the addresser can parse the address into its components 6. the identifier is a hash of the user id 7. the related identifier is a hash of the public key """ key = helper.user.key().public_key user_id = helper.user.id() address = addresser.user.key.address(user_id, key) assert assert_is_address(address) assert address != addresser.user.key.address(user_id, helper.user.key().public_key) assert address != addresser.user.key.address(helper.user.id(), key) assert address == addresser.user.key.address(user_id, key) assert addresser.get_address_type( address) == addresser.AddressSpace.USER_KEY assert addresser.get_address_type( address) == addresser.AddressSpace.USER_KEY parsed = addresser.parse(address) assert parsed.object_type == addresser.ObjectType.USER assert parsed.related_type == addresser.ObjectType.KEY assert parsed.relationship_type == addresser.RelationshipType.OWNER assert assert_is_identifier(parsed.object_id) assert parsed.object_id == addresser.user.hash(user_id) assert parsed.related_id == addresser.key.hash(key)
def test_addressing_user(): """Tests making a blockchain address for an next_id and that it: 1. is a 35-byte non-zero hexadecimal string 2. is unique - a different next_id yields a different address 3. is deterministic - same next_id yields same address, even if different case 4. the addresser recognizes the address as an next_id 5. the addresser can parse the address into its components 6. the identifier is a hash of the next_id""" next_id = helper.user.id() address = addresser.user.address(next_id) assert assert_is_address(address) assert address != addresser.user.address(helper.user.id()) assert address == addresser.user.address(next_id) assert address == addresser.user.address(next_id.upper()) assert addresser.get_address_type(address) == addresser.AddressSpace.USER parsed = addresser.parse(address) assert parsed.object_type == addresser.ObjectType.USER assert parsed.related_type == addresser.ObjectType.NONE assert parsed.relationship_type == addresser.RelationshipType.ATTRIBUTES assert assert_is_identifier(parsed.object_id) assert not parsed.related_id assert parsed.object_id == addresser.user.hash(next_id)