diff --git a/scripts/replace_bytecode_test.py b/scripts/replace_bytecode_test.py index 0bde9b09..7516d923 100644 --- a/scripts/replace_bytecode_test.py +++ b/scripts/replace_bytecode_test.py @@ -9,12 +9,13 @@ def update_bytecode(json_file_path, contract_name, new_bytecode): :param contract_name: Nombre del contrato cuyo bytecode se va a sustituir. :param new_bytecode: Nuevo valor para la clave 'bytecode'. """ - + for c in json_file_path: + json_contract = json_file_path[c] - if contract_name.startswith(json_contract["contract"]): - # Verificar si 'bytecode' está en el JSON + if contract_name.startswith(json_contract["contract"].strip(":")): + # Verificar si 'bytecode' está en el JSON json_contract["bytecode"] = new_bytecode def get_evm_code(log_file): @@ -45,9 +46,8 @@ def get_evm_code(log_file): evm_codes = get_evm_code(log_file) - path_to_test = test_file.split("/")[:-2] + path_to_test = test_file.split("/")[:-1] - print(path_to_test) result_file = "/".join(path_to_test)+"/test_grey" @@ -58,10 +58,11 @@ def get_evm_code(log_file): for c in evm_codes: evm = evm_codes[c] - - update_bytecode(data, c, evm) + + update_bytecode(data, c.strip(), evm.strip()) # Guardar el archivo JSON actualizado + with open(result_file, 'w') as file: json.dump(data, file, indent=4)