예제 #1
0
    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
예제 #2
0
    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?")
예제 #3
0
 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)
예제 #4
0
 def setUpClass(cls):
     cls.ci = ContractInterface.from_michelson(code).using('mainnet')
예제 #5
0
 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)))
예제 #6
0
 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)
예제 #7
0
 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)