fix test suite

This commit is contained in:
Olivier Gagnon 2022-07-21 02:13:47 -04:00
parent d01fd55bde
commit 43b8cfec5c
7 changed files with 71 additions and 71 deletions

@ -62,7 +62,6 @@ export const RamCostConstants: IMap<number> = {
ScriptGetFavorToDonate: 0.1, ScriptGetFavorToDonate: 0.1,
ScriptCodingContractBaseRamCost: 10, ScriptCodingContractBaseRamCost: 10,
ScriptSleeveBaseRamCost: 4, ScriptSleeveBaseRamCost: 4,
ScriptGetOwnedSourceFiles: 5,
ScriptClearTerminalCost: 0.2, ScriptClearTerminalCost: 0.2,
ScriptSingularityFn1RamCost: 2, ScriptSingularityFn1RamCost: 2,
@ -191,6 +190,7 @@ const singularity = {
getCrimeChance: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost), getCrimeChance: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
getCrimeStats: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost), getCrimeStats: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
getOwnedAugmentations: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost), getOwnedAugmentations: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
getOwnedSourceFiles: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
getAugmentationsFromFaction: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost), getAugmentationsFromFaction: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
getAugmentationCost: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost), getAugmentationCost: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
getAugmentationPrereq: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost), getAugmentationPrereq: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
@ -519,7 +519,6 @@ const SourceRamCosts = {
getFavorToDonate: RamCostConstants.ScriptGetFavorToDonate, getFavorToDonate: RamCostConstants.ScriptGetFavorToDonate,
getPlayer: RamCostConstants.ScriptSingularityFn1RamCost / 4, getPlayer: RamCostConstants.ScriptSingularityFn1RamCost / 4,
mv: 0, mv: 0,
getOwnedSourceFiles: RamCostConstants.ScriptGetOwnedSourceFiles,
tail: 0, tail: 0,
toast: 0, toast: 0,
closeTail: 0, closeTail: 0,

@ -2425,16 +2425,6 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
getFavorToDonate: () => (): number => { getFavorToDonate: () => (): number => {
return Math.floor(CONSTANTS.BaseFavorToDonate * BitNodeMultipliers.RepToDonateToFaction); return Math.floor(CONSTANTS.BaseFavorToDonate * BitNodeMultipliers.RepToDonateToFaction);
}, },
getOwnedSourceFiles: () => (): SourceFileLvl[] => {
const res: SourceFileLvl[] = [];
for (let i = 0; i < Player.sourceFiles.length; ++i) {
res.push({
n: Player.sourceFiles[i].n,
lvl: Player.sourceFiles[i].lvl,
});
}
return res;
},
getPlayer: () => (): INetscriptPlayer => { getPlayer: () => (): INetscriptPlayer => {
const data = { const data = {
hacking: Player.hacking, hacking: Player.hacking,

@ -17,6 +17,7 @@ import {
CrimeStats, CrimeStats,
PlayerSkills, PlayerSkills,
Singularity as ISingularity, Singularity as ISingularity,
SourceFileLvl,
} from "../ScriptEditor/NetscriptDefinitions"; } from "../ScriptEditor/NetscriptDefinitions";
import { findCrime } from "../Crime/CrimeHelpers"; import { findCrime } from "../Crime/CrimeHelpers";
@ -114,6 +115,16 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript
} }
return res; return res;
}, },
getOwnedSourceFiles: () => (): SourceFileLvl[] => {
const res: SourceFileLvl[] = [];
for (let i = 0; i < player.sourceFiles.length; ++i) {
res.push({
n: player.sourceFiles[i].n,
lvl: player.sourceFiles[i].lvl,
});
}
return res;
},
getAugmentationsFromFaction: (_ctx: NetscriptContext) => getAugmentationsFromFaction: (_ctx: NetscriptContext) =>
function (_facName: unknown): string[] { function (_facName: unknown): string[] {
_ctx.helper.checkSingularityAccess(); _ctx.helper.checkSingularityAccess();

@ -2081,6 +2081,17 @@ export interface Singularity {
*/ */
getOwnedAugmentations(purchased?: boolean): string[]; getOwnedAugmentations(purchased?: boolean): string[];
/**
* Get a list of acquired Source-Files.
* @remarks
* RAM cost: 5 GB
*
* Returns an array of source files
*
* @returns Array containing an object with number and level of the source file.
*/
getOwnedSourceFiles(): SourceFileLvl[];
/** /**
* Get a list of augmentation available from a faction. * Get a list of augmentation available from a faction.
* @remarks * @remarks
@ -6446,17 +6457,6 @@ export interface NS {
*/ */
getBitNodeMultipliers(): BitNodeMultipliers; getBitNodeMultipliers(): BitNodeMultipliers;
/**
* Get a list of acquired Source-Files.
* @remarks
* RAM cost: 5 GB
*
* Returns an array of source files
*
* @returns Array containing an object with number and level of the source file.
*/
getOwnedSourceFiles(): SourceFileLvl[];
/** /**
* Get information about the player. * Get information about the player.
* @remarks * @remarks

@ -623,13 +623,13 @@ describe("Netscript Dynamic RAM Calculation/Generation Tests", function () {
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("stock.buy()", async function () { it("stock.buyStock()", async function () {
const f = ["stock", "buy"]; const f = ["stock", "buyStock"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("stock.sell()", async function () { it("stock.sellStock()", async function () {
const f = ["stock", "sell"]; const f = ["stock", "sellStock"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
@ -681,187 +681,187 @@ describe("Netscript Dynamic RAM Calculation/Generation Tests", function () {
describe("Singularity Functions", function () { describe("Singularity Functions", function () {
it("universityCourse()", async function () { it("universityCourse()", async function () {
const f = ["universityCourse"]; const f = ["singularity", "universityCourse"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("gymWorkout()", async function () { it("gymWorkout()", async function () {
const f = ["gymWorkout"]; const f = ["singularity", "gymWorkout"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("travelToCity()", async function () { it("travelToCity()", async function () {
const f = ["travelToCity"]; const f = ["singularity", "travelToCity"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("purchaseTor()", async function () { it("purchaseTor()", async function () {
const f = ["purchaseTor"]; const f = ["singularity", "purchaseTor"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("purchaseProgram()", async function () { it("purchaseProgram()", async function () {
const f = ["purchaseProgram"]; const f = ["singularity", "purchaseProgram"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("getStats()", async function () { it("getStats()", async function () {
const f = ["getStats"]; const f = ["singularity", "getStats"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("getDarkwebProgramCost()", async function () { it("getDarkwebProgramCost()", async function () {
const f = ["getDarkwebProgramCost"]; const f = ["singularity", "getDarkwebProgramCost"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("getDarkwebPrograms()", async function () { it("getDarkwebPrograms()", async function () {
const f = ["getDarkwebPrograms"]; const f = ["singularity", "getDarkwebPrograms"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("getCharacterInformation()", async function () { it("getCharacterInformation()", async function () {
const f = ["getCharacterInformation"]; const f = ["singularity", "getCharacterInformation"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("isBusy()", async function () { it("isBusy()", async function () {
const f = ["isBusy"]; const f = ["singularity", "isBusy"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("stopAction()", async function () { it("stopAction()", async function () {
const f = ["stopAction"]; const f = ["singularity", "stopAction"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("upgradeHomeRam()", async function () { it("upgradeHomeRam()", async function () {
const f = ["upgradeHomeRam"]; const f = ["singularity", "upgradeHomeRam"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("getUpgradeHomeRamCost()", async function () { it("getUpgradeHomeRamCost()", async function () {
const f = ["getUpgradeHomeRamCost"]; const f = ["singularity", "getUpgradeHomeRamCost"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("workForCompany()", async function () { it("workForCompany()", async function () {
const f = ["workForCompany"]; const f = ["singularity", "workForCompany"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("applyToCompany()", async function () { it("applyToCompany()", async function () {
const f = ["applyToCompany"]; const f = ["singularity", "applyToCompany"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("getCompanyRep()", async function () { it("getCompanyRep()", async function () {
const f = ["getCompanyRep"]; const f = ["singularity", "getCompanyRep"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("getCompanyFavor()", async function () { it("getCompanyFavor()", async function () {
const f = ["getCompanyFavor"]; const f = ["singularity", "getCompanyFavor"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("getCompanyFavorGain()", async function () { it("getCompanyFavorGain()", async function () {
const f = ["getCompanyFavorGain"]; const f = ["singularity", "getCompanyFavorGain"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("checkFactionInvitations()", async function () { it("checkFactionInvitations()", async function () {
const f = ["checkFactionInvitations"]; const f = ["singularity", "checkFactionInvitations"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("joinFaction()", async function () { it("joinFaction()", async function () {
const f = ["joinFaction"]; const f = ["singularity", "joinFaction"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("workForFaction()", async function () { it("workForFaction()", async function () {
const f = ["workForFaction"]; const f = ["singularity", "workForFaction"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("getFactionRep()", async function () { it("getFactionRep()", async function () {
const f = ["getFactionRep"]; const f = ["singularity", "getFactionRep"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("getFactionFavor()", async function () { it("getFactionFavor()", async function () {
const f = ["getFactionFavor"]; const f = ["singularity", "getFactionFavor"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("getFactionFavorGain()", async function () { it("getFactionFavorGain()", async function () {
const f = ["getFactionFavorGain"]; const f = ["singularity", "getFactionFavorGain"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("donateToFaction()", async function () { it("donateToFaction()", async function () {
const f = ["donateToFaction"]; const f = ["singularity", "donateToFaction"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("createProgram()", async function () { it("createProgram()", async function () {
const f = ["createProgram"]; const f = ["singularity", "createProgram"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("commitCrime()", async function () { it("commitCrime()", async function () {
const f = ["commitCrime"]; const f = ["singularity", "commitCrime"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("getCrimeChance()", async function () { it("getCrimeChance()", async function () {
const f = ["getCrimeChance"]; const f = ["singularity", "getCrimeChance"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("getOwnedAugmentations()", async function () { it("getOwnedAugmentations()", async function () {
const f = ["getOwnedAugmentations"]; const f = ["singularity", "getOwnedAugmentations"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("getOwnedSourceFiles()", async function () { it("getOwnedSourceFiles()", async function () {
const f = ["getOwnedSourceFiles"]; const f = ["singularity", "getOwnedSourceFiles"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("getAugmentationsFromFaction()", async function () { it("getAugmentationsFromFaction()", async function () {
const f = ["getAugmentationsFromFaction"]; const f = ["singularity", "getAugmentationsFromFaction"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("getAugmentationCost()", async function () { it("getAugmentationCost()", async function () {
const f = ["getAugmentationCost"]; const f = ["singularity", "getAugmentationCost"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("getAugmentationPrereq()", async function () { it("getAugmentationPrereq()", async function () {
const f = ["getAugmentationPrereq"]; const f = ["singularity", "getAugmentationPrereq"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("getAugmentationPrice()", async function () { it("getAugmentationPrice()", async function () {
const f = ["getAugmentationPrice"]; const f = ["singularity", "getAugmentationPrice"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("getAugmentationRepReq()", async function () { it("getAugmentationRepReq()", async function () {
const f = ["getAugmentationRepReq"]; const f = ["singularity", "getAugmentationRepReq"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("purchaseAugmentation()", async function () { it("purchaseAugmentation()", async function () {
const f = ["purchaseAugmentation"]; const f = ["singularity", "purchaseAugmentation"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
it("installAugmentations()", async function () { it("installAugmentations()", async function () {
const f = ["installAugmentations"]; const f = ["singularity", "installAugmentations"];
await testNonzeroDynamicRamCost(f); await testNonzeroDynamicRamCost(f);
}); });
}); });

@ -591,13 +591,13 @@ describe("Netscript Static RAM Calculation/Generation Tests", function () {
await expectNonZeroRamCost(f); await expectNonZeroRamCost(f);
}); });
it("stock.buy()", async function () { it("stock.buyStock()", async function () {
const f = ["stock", "buy"]; const f = ["stock", "buyStock"];
await expectNonZeroRamCost(f); await expectNonZeroRamCost(f);
}); });
it("stock.sell()", async function () { it("stock.sellStock()", async function () {
const f = ["stock", "sell"]; const f = ["stock", "sellStock"];
await expectNonZeroRamCost(f); await expectNonZeroRamCost(f);
}); });
@ -607,7 +607,7 @@ describe("Netscript Static RAM Calculation/Generation Tests", function () {
}); });
it("stock.sellShort()", async function () { it("stock.sellShort()", async function () {
const f = ["stock", "sell"]; const f = ["stock", "sellShort"];
await expectNonZeroRamCost(f); await expectNonZeroRamCost(f);
}); });

@ -457,13 +457,13 @@ describe("Stock Market Tests", function () {
it("should trigger a price update when it has enough cycles", function () { it("should trigger a price update when it has enough cycles", function () {
// Get the initial prices // Get the initial prices
const initialValues: IMap<Stock> = {}; const initialValues: IMap<any> = {};
for (const stockName in StockMarket) { for (const stockName in StockMarket) {
const stock = StockMarket[stockName]; const stock = StockMarket[stockName];
if (!(stock instanceof Stock)) { if (!(stock instanceof Stock)) {
continue; continue;
} }
initialValues[stock.symbol] = stock; initialValues[stock.symbol] = { ...stock };
} }
// Don't know or care how many exact cycles are required // Don't know or care how many exact cycles are required