mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-08 08:43:53 +01:00
NETSCRIPT: Don't make dynamicLoadedFns entries for free functions. (#1617)
This commit is contained in:
parent
2141032432
commit
028e779602
@ -343,6 +343,7 @@ function netscriptDelay(ctx: NetscriptContext, time: number): Promise<void> {
|
|||||||
|
|
||||||
/** Adds to dynamic ram cost when calling new ns functions from a script */
|
/** Adds to dynamic ram cost when calling new ns functions from a script */
|
||||||
function updateDynamicRam(ctx: NetscriptContext, ramCost: number): void {
|
function updateDynamicRam(ctx: NetscriptContext, ramCost: number): void {
|
||||||
|
if (ramCost === 0) return;
|
||||||
const ws = ctx.workerScript;
|
const ws = ctx.workerScript;
|
||||||
const fnName = ctx.function;
|
const fnName = ctx.function;
|
||||||
if (ws.dynamicLoadedFns[fnName]) return;
|
if (ws.dynamicLoadedFns[fnName]) return;
|
||||||
|
@ -103,7 +103,9 @@ describe("Netscript RAM Calculation/Generation Tests", function () {
|
|||||||
throw new Error(`Invalid function specified: [${fnPath.toString()}]`);
|
throw new Error(`Invalid function specified: [${fnPath.toString()}]`);
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(workerScript.dynamicLoadedFns).toHaveProperty(fnName);
|
if (expectedRamCost !== 0) {
|
||||||
|
expect(workerScript.dynamicLoadedFns).toHaveProperty(fnName);
|
||||||
|
}
|
||||||
expect(workerScript.dynamicRamUsage).toBeCloseTo(Math.min(expectedRamCost + baseCost, maxCost), 5);
|
expect(workerScript.dynamicRamUsage).toBeCloseTo(Math.min(expectedRamCost + baseCost, maxCost), 5);
|
||||||
expect(workerScript.dynamicRamUsage).toBeCloseTo(scriptRef.ramUsage - extraLayerCost, 5);
|
expect(workerScript.dynamicRamUsage).toBeCloseTo(scriptRef.ramUsage - extraLayerCost, 5);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user