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
+4 -2
View File
@@ -127,9 +127,11 @@ export function NetscriptCodingContract(): InternalAPI<ICodingContract> {
const contract = getCodingContract(ctx, host, filename);
return contract.getMaxNumTries() - contract.tries;
},
createDummyContract: (ctx) => (_type) => {
createDummyContract: (ctx) => (_type, _host?) => {
const type = getEnumHelper("CodingContractName").nsGetMember(ctx, _type);
return generateDummyContract(type);
const host = _host ? helpers.string(ctx, "host", _host) : ctx.workerScript.hostname;
const server = helpers.getServer(ctx, host);
return generateDummyContract(type, server);
},
getContractTypes: () => () => Object.values(CodingContractName),
};