mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2024-12-04 18:00:18 +00:00
test fixes, wip
This commit is contained in:
parent
9e212118fc
commit
d418c3a135
@ -1,6 +1,7 @@
|
|||||||
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
||||||
module.exports = {
|
module.exports = {
|
||||||
extensionsToTreatAsEsm: ['.ts'],
|
extensionsToTreatAsEsm: ['.ts'],
|
||||||
|
testPathIgnorePatterns: ['dist'],
|
||||||
"preset": "ts-jest/presets/default-esm",
|
"preset": "ts-jest/presets/default-esm",
|
||||||
"moduleNameMapper": {
|
"moduleNameMapper": {
|
||||||
"^(\\.{1,2}/.*)\\.js$": "$1"
|
"^(\\.{1,2}/.*)\\.js$": "$1"
|
||||||
@ -12,6 +13,10 @@ module.exports = {
|
|||||||
"useESM": true
|
"useESM": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
tsConfig: {
|
||||||
|
skipLibCheck: true
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"compile-aqua": "aqua -i ./aqua/ -o ./src/internal/_aqua",
|
"compile-aqua": "aqua -i ./aqua/ -o ./src/internal/_aqua",
|
||||||
"test:smoke": "node ./dist/js-peer/__test__/integration/smokeTest.js",
|
"test:smoke": "node ./dist/js-peer/__test__/integration/smokeTest.js",
|
||||||
"test": "NODE_OPTIONS=--experimental-vm-modules npx jest",
|
"test": "NODE_OPTIONS=--experimental-vm-modules pnpm jest",
|
||||||
"test:unit": "NODE_OPTIONS=--experimental-vm-modules pnpm jest --testPathPattern=src/__test__/unit",
|
"test:unit": "NODE_OPTIONS=--experimental-vm-modules pnpm jest --testPathPattern=src/__test__/unit",
|
||||||
"test:integration": "NODE_OPTIONS=--experimental-vm-modules pnpm jest --testPathPattern=src/__test__/integration"
|
"test:integration": "NODE_OPTIONS=--experimental-vm-modules pnpm jest --testPathPattern=src/__test__/integration"
|
||||||
},
|
},
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { Particle } from '../../Particle.js';
|
import { Particle } from '../../Particle.js';
|
||||||
import { doNothing } from '../../utils.js';
|
import { doNothing } from '../../utils.js';
|
||||||
import {createClient} from "../../../../../../client/js-client.node";
|
import { FluencePeer } from '../../FluencePeer.js';
|
||||||
import {FluencePeer} from "../../FluencePeer";
|
import {mkTestNode} from "../util.js";
|
||||||
|
|
||||||
|
|
||||||
let peer: FluencePeer;
|
let peer: FluencePeer;
|
||||||
|
|
||||||
@ -13,7 +14,7 @@ describe('Sig service test suite', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
peer = createClient();
|
peer = await mkTestNode();
|
||||||
await peer.start();
|
await peer.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
import { nodes } from '../connection.js';
|
import { nodes } from '../connection.js';
|
||||||
import { checkConnection, doNothing, handleTimeout } from '../../utils.js';
|
import { checkConnection, doNothing, handleTimeout } from '../../utils.js';
|
||||||
import {registerHandlersHelper, mkTestPeer, withPeer, withConnectedPeer} from '../util.js';
|
import {registerHandlersHelper, mkTestPeer, withPeer, withConnectedPeer, mkTestNode} from '../util.js';
|
||||||
import {FluencePeer} from "../../FluencePeer";
|
import {FluencePeer} from "../../FluencePeer.js";
|
||||||
import {createClient} from "../../../../../../client/js-client.node";
|
|
||||||
|
|
||||||
describe('Typescript usage suite', () => {
|
describe('Typescript usage suite', () => {
|
||||||
|
|
||||||
describe('Should expose correct peer status', () => {
|
describe('Should expose correct peer status', () => {
|
||||||
it('Should expose correct status for uninitialized peer', () => {
|
it('Should expose correct status for uninitialized peer', async () => {
|
||||||
const peer = createClient();
|
const peer = await mkTestNode();
|
||||||
const status = peer.getStatus();
|
const status = peer.getStatus();
|
||||||
|
|
||||||
expect(status.isConnected).toBe(false);
|
expect(status.isConnected).toBe(false);
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import {createClient} from "../../../../../../client/js-client.node";
|
import {mkTestNode} from "../util.js";
|
||||||
|
|
||||||
describe('Parse ast tests', () => {
|
describe('Parse ast tests', () => {
|
||||||
|
|
||||||
let somePeer: any;
|
let somePeer: any;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
somePeer = await createClient();
|
somePeer = await mkTestNode();
|
||||||
await somePeer.start();
|
await somePeer.start();
|
||||||
}, 10000);
|
}, 10000);
|
||||||
|
|
||||||
|
@ -12,8 +12,9 @@ import { marineLogFunction } from '../utils.js';
|
|||||||
import { MarineBackgroundRunner } from '../../marine/worker/index.js';
|
import { MarineBackgroundRunner } from '../../marine/worker/index.js';
|
||||||
import { MarineBasedAvmRunner } from '../avm.js';
|
import { MarineBasedAvmRunner } from '../avm.js';
|
||||||
import { nodes } from './connection.js';
|
import { nodes } from './connection.js';
|
||||||
import {WorkerLoaderFromFs} from '../../marine/deps-loader/node.js';
|
import {WasmLoaderFromNpm, WorkerLoaderFromFs} from '../../marine/deps-loader/node.js';
|
||||||
import {createClient} from "../../../../../client/js-client.node";
|
import {defaultNames} from "../../../../../client/js-client.node/src/index.js";
|
||||||
|
import {WorkerLoader} from "../../marine/worker-script/workerLoader.js";
|
||||||
|
|
||||||
export const registerHandlersHelper = (
|
export const registerHandlersHelper = (
|
||||||
peer: FluencePeer,
|
peer: FluencePeer,
|
||||||
@ -58,6 +59,16 @@ export const compileAqua = async (aquaFile: string): Promise<CompiledFile> => {
|
|||||||
return { functions, services: compilationResult.services };
|
return { functions, services: compilationResult.services };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const mkTestNode = () => {
|
||||||
|
const workerLoader = new WorkerLoader();
|
||||||
|
const controlModuleLoader = new WasmLoaderFromNpm(defaultNames.marine.package, defaultNames.marine.file);
|
||||||
|
const avmModuleLoader = new WasmLoaderFromNpm(defaultNames.avm.package, defaultNames.avm.file);
|
||||||
|
|
||||||
|
const marine = new MarineBackgroundRunner(workerLoader, controlModuleLoader, marineLogFunction);
|
||||||
|
const avm = new MarineBasedAvmRunner(marine, avmModuleLoader, undefined);
|
||||||
|
return new FluencePeer(marine, avm);
|
||||||
|
};
|
||||||
|
|
||||||
export const mkTestPeer = () => {
|
export const mkTestPeer = () => {
|
||||||
const workerLoader = new WorkerLoaderFromFs('../../marine/worker-script');
|
const workerLoader = new WorkerLoaderFromFs('../../marine/worker-script');
|
||||||
|
|
||||||
@ -67,7 +78,7 @@ export const mkTestPeer = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const withPeer = async (action: (p: FluencePeer) => Promise<void>, config?: PeerConfig) => {
|
export const withPeer = async (action: (p: FluencePeer) => Promise<void>, config?: PeerConfig) => {
|
||||||
const p = createClient()
|
const p = await mkTestNode()
|
||||||
try {
|
try {
|
||||||
console.log("connecting to: ")
|
console.log("connecting to: ")
|
||||||
console.log(config)
|
console.log(config)
|
||||||
|
@ -20,7 +20,7 @@ import { Buffer } from 'buffer';
|
|||||||
import { CallServiceData, CallServiceResult, CallServiceResultType, ResultCodes } from '../interfaces/commonTypes.js';
|
import { CallServiceData, CallServiceResult, CallServiceResultType, ResultCodes } from '../interfaces/commonTypes.js';
|
||||||
import { ParticleExecutionStage } from './Particle.js';
|
import { ParticleExecutionStage } from './Particle.js';
|
||||||
import { LogFunction } from '@fluencelabs/marine-js/dist/types';
|
import { LogFunction } from '@fluencelabs/marine-js/dist/types';
|
||||||
import {FluencePeer} from "./FluencePeer";
|
import {FluencePeer} from "./FluencePeer.js";
|
||||||
|
|
||||||
export const MakeServiceCall =
|
export const MakeServiceCall =
|
||||||
(fn: (args: any[]) => CallServiceResultType) =>
|
(fn: (args: any[]) => CallServiceResultType) =>
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
"outDir": "./dist",
|
"outDir": "./dist",
|
||||||
"moduleResolution": "nodenext"
|
"moduleResolution": "nodenext"
|
||||||
},
|
},
|
||||||
|
"skipLibCheck": true,
|
||||||
"include": ["src/**/*"],
|
"include": ["src/**/*"],
|
||||||
"exclude": ["node_modules", "dist"],
|
"exclude": ["node_modules", "dist"],
|
||||||
"esModuleInterop": true
|
"esModuleInterop": true
|
||||||
|
Loading…
Reference in New Issue
Block a user