def validate_proof(proof: List[dict], hex_target_hash: str,
                    hex_merkle_root: str):
     hex_merkle_root = ContractDataParser.to_reserve_hex_str(
         hex_merkle_root)
     hex_target_hash = ContractDataParser.to_reserve_hex_str(
         hex_target_hash)
     if len(proof) == 0:
         return hex_target_hash == hex_merkle_root
     else:
         hex_proof_hash = hex_target_hash
         for node in proof:
             sibling = ContractDataParser.to_reserve_hex_str(
                 node['TargetHash'])
             try:
                 direction = node['Direction'].lower()
             except KeyError:
                 raise SDKException(ErrorCode.other_error('Invalid proof'))
             if direction == 'left':
                 value = binascii.a2b_hex('01' + sibling + hex_proof_hash)
                 hex_proof_hash = Digest.sha256(value, is_hex=True)
             elif direction == 'right':
                 value = binascii.a2b_hex('01' + hex_proof_hash + sibling)
                 hex_proof_hash = Digest.sha256(value, is_hex=True)
             else:
                 raise SDKException(ErrorCode.other_error('Invalid proof.'))
         return hex_proof_hash == hex_merkle_root
 def test_address_from_vm_code(self):
     code = '55c56b6a00527ac46a51527ac46a00c30548656c6c6f7d9c7c756419006a51c300c36a52527ac46a52c3650d006c7' \
            '566620300006c756652c56b6a00527ac46a00c3681553797374656d2e52756e74696d652e4e6f74696679516c7566'
     code_address = Address.address_from_vm_code(code)
     contract_address = 'f2b6efc3e4360e69b8ff5db8ce8ac73651d07a12'
     self.assertEqual(contract_address, code_address.to_hex_str())
     self.assertEqual(contract_address,
                      b2a_hex(code_address.to_bytes()).decode('ascii'))
     self.assertEqual(contract_address,
                      b2a_hex(code_address.to_bytearray()).decode('ascii'))
     self.assertEqual(
         contract_address,
         ContractDataParser.to_reserve_hex_str(
             code_address.to_reverse_hex_str()))
     self.assertEqual(contract_address,
                      sdk.neo_vm.avm_code_to_hex_contract_address(code))
     bytes_address = sdk.neo_vm.avm_code_to_bytes_contract_address(code)
     self.assertEqual(contract_address,
                      b2a_hex(bytes_address).decode('ascii'))
     bytearray_address = sdk.neo_vm.avm_code_to_bytearray_contract_address(
         code)
     self.assertEqual(contract_address,
                      b2a_hex(bytearray_address).decode('ascii'))