class TestContracts: """Test type checking and execution of a bunch of contracts""" @pytest.mark.parametrize("contract", all_contracts()) def test_typecheck(self, client, contract): assert contract.endswith('.tz'), \ "test contract should have .tz extension" client.typecheck(os.path.join(CONTRACT_PATH, contract)) @pytest.mark.parametrize( "contract,error_pattern", [ # operations cannot be PACKed ("pack_operation.tz", r'operation type forbidden in parameter, storage and constants'), # big_maps cannot be PACKed ("pack_big_map.tz", r'big_map type not expected here'), ("invalid_self_entrypoint.tz", r'Contract has no entrypoint named D'), ("contract_annotation_default.tz", r'unexpected annotation'), ]) def test_ill_typecheck(self, client, contract, error_pattern): def cmd(): client.typecheck(os.path.join(ILLTYPED_CONTRACT_PATH, contract)) utils.assert_run_failure(cmd, error_pattern)
class TestMacroExpansion: """Test expanding macros""" @pytest.mark.parametrize("contract", all_contracts(['macros'])) def test_macro_expansion(self, client_regtest, contract): """This test expands macros in all macro test contracts, with regression detection enabled. This test should fail if the definition of any macros change. """ client_regtest.expand_macros(path.join(CONTRACT_PATH, contract))
def all_contracts(directories: List[str] = None) -> List[str]: return paths.all_contracts(CONTRACT_PATH, directories)