#!/usr/bin/env python # -*- coding: utf-8 -*- import os import subprocess def evaluate_solution(task_id: str, solution: str): initial_dir = os.getcwd() task_dir = task_id.replace('/', '_') task_path = 'tasks/' + task_dir os.chdir(task_path) with open('contracts/Task.sol', 'w') as f: f.write(solution) try: subprocess.run(['npx', 'hardhat', 'test'], check=True) return True except subprocess.CalledProcessError: return False finally: os.chdir(initial_dir)