CONTRACTS: Generate test contracts on executing host by default. Add support for optional parameter to specify the server. (#2417)

This commit is contained in:
Paul Setzer
2025-12-16 19:23:59 -05:00
committed by GitHub
parent e7768824ba
commit 968c0c2a8c
7 changed files with 47 additions and 14 deletions
+3 -4
View File
@@ -113,16 +113,15 @@ export function generateRandomContractOnHome(): void {
serv.addContract(contract);
}
export const generateDummyContract = (problemType: CodingContractName): string | null => {
export const generateDummyContract = (problemType: CodingContractName, server: BaseServer): string | null => {
if (!CodingContractTypes[problemType]) throw new Error(`Invalid problem type: '${problemType}'`);
const serv = Player.getHomeComputer();
const contractFn = getRandomFilename(serv);
const contractFn = getRandomFilename(server);
if (contractFn == null) {
return null;
}
const contract = new CodingContract(contractFn, problemType, null);
serv.addContract(contract);
server.addContract(contract);
return contractFn;
};