def compile_contract(self): """ Force compilation of LIGO contract from source file and loads it into pytezos. :return: pytezos.ContractInterface """ command = f"{ligo_cmd} compile-contract {self.ligo_file} {self.main_func}" michelson = execute_command(command) self.contract_interface = ContractInterface.from_michelson(michelson) return self.contract_interface
def test_decode_from_michelson(self, file_name): """ Ensure that a valid Michelson contract with valid storage can be instantiated in Python """ storage_path = asset_directory.joinpath(file_name) with io.open(storage_path, 'r') as contract_data_input: michelson_storage = contract_data_input.read() contract_interface = ContractInterface.from_michelson( self.michelson_contract) python_storage = contract_interface.contract.storage.decode( michelson_storage) self.assertIsNotNone( python_storage, msg="Why couldn't the valid storage be decoded from Michelson?") contract_interface.contract.storage_from_michelson(michelson_storage) micheline_storage = contract_interface.contract.storage.encode( python_storage) self.assertIsNotNone( micheline_storage, msg= "Why couldn't python_storage (the result of decoding) be submitted " "for encoding?")
def test_now(self, network): contract = ContractInterface.from_michelson(code).using(network) now = pytezos.using(network).now() res = contract.default().run_code() self.assertEqual(now, res.storage)
def setUpClass(cls): cls.ci = ContractInterface.from_michelson(code).using('mainnet')
def test_1_originate_contract(self) -> None: ci = ContractInterface.from_michelson(code) res = self.client.origination(ci.script()).autofill().sign().inject( time_between_blocks=self.TIME_BETWEEN_BLOCKS, min_confirmations=1) self.assertEqual(1, len(OperationResult.originated_contracts(res)))
def test_pass_big_map_ptr(self): ci = ContractInterface.from_michelson(code) res = ci.call(123).interpret(storage={ 1: 1 }) # FIXME: this should fail with something like "Big_map not found" self.assertEqual({}, res.storage)
def test_pass_big_map_diff(self): ci = ContractInterface.from_michelson(code) res = ci.call({2: 2}).interpret(storage={1: 1}) self.assertEqual({2: 2}, res.storage)