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} */
|
||||
module.exports = {
|
||||
extensionsToTreatAsEsm: ['.ts'],
|
||||
testPathIgnorePatterns: ['dist'],
|
||||
"preset": "ts-jest/presets/default-esm",
|
||||
"moduleNameMapper": {
|
||||
"^(\\.{1,2}/.*)\\.js$": "$1"
|
||||
@ -12,6 +13,10 @@ module.exports = {
|
||||
"useESM": true
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
tsConfig: {
|
||||
skipLibCheck: true
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -13,7 +13,7 @@
|
||||
"build": "tsc",
|
||||
"compile-aqua": "aqua -i ./aqua/ -o ./src/internal/_aqua",
|
||||
"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:integration": "NODE_OPTIONS=--experimental-vm-modules pnpm jest --testPathPattern=src/__test__/integration"
|
||||
},
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { Particle } from '../../Particle.js';
|
||||
import { doNothing } from '../../utils.js';
|
||||
import {createClient} from "../../../../../../client/js-client.node";
|
||||
import {FluencePeer} from "../../FluencePeer";
|
||||
import { FluencePeer } from '../../FluencePeer.js';
|
||||
import {mkTestNode} from "../util.js";
|
||||
|
||||
|
||||
let peer: FluencePeer;
|
||||
|
||||
@ -13,7 +14,7 @@ describe('Sig service test suite', () => {
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
peer = createClient();
|
||||
peer = await mkTestNode();
|
||||
await peer.start();
|
||||
});
|
||||
|
||||
|
@ -1,14 +1,13 @@
|
||||
import { nodes } from '../connection.js';
|
||||
import { checkConnection, doNothing, handleTimeout } from '../../utils.js';
|
||||
import {registerHandlersHelper, mkTestPeer, withPeer, withConnectedPeer} from '../util.js';
|
||||
import {FluencePeer} from "../../FluencePeer";
|
||||
import {createClient} from "../../../../../../client/js-client.node";
|
||||
import {registerHandlersHelper, mkTestPeer, withPeer, withConnectedPeer, mkTestNode} from '../util.js';
|
||||
import {FluencePeer} from "../../FluencePeer.js";
|
||||
|
||||
describe('Typescript usage suite', () => {
|
||||
|
||||
describe('Should expose correct peer status', () => {
|
||||
it('Should expose correct status for uninitialized peer', () => {
|
||||
const peer = createClient();
|
||||
it('Should expose correct status for uninitialized peer', async () => {
|
||||
const peer = await mkTestNode();
|
||||
const status = peer.getStatus();
|
||||
|
||||
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', () => {
|
||||
|
||||
let somePeer: any;
|
||||
|
||||
beforeAll(async () => {
|
||||
somePeer = await createClient();
|
||||
somePeer = await mkTestNode();
|
||||
await somePeer.start();
|
||||
}, 10000);
|
||||
|
||||
|
@ -12,8 +12,9 @@ import { marineLogFunction } from '../utils.js';
|
||||
import { MarineBackgroundRunner } from '../../marine/worker/index.js';
|
||||
import { MarineBasedAvmRunner } from '../avm.js';
|
||||
import { nodes } from './connection.js';
|
||||
import {WorkerLoaderFromFs} from '../../marine/deps-loader/node.js';
|
||||
import {createClient} from "../../../../../client/js-client.node";
|
||||
import {WasmLoaderFromNpm, WorkerLoaderFromFs} from '../../marine/deps-loader/node.js';
|
||||
import {defaultNames} from "../../../../../client/js-client.node/src/index.js";
|
||||
import {WorkerLoader} from "../../marine/worker-script/workerLoader.js";
|
||||
|
||||
export const registerHandlersHelper = (
|
||||
peer: FluencePeer,
|
||||
@ -58,6 +59,16 @@ export const compileAqua = async (aquaFile: string): Promise<CompiledFile> => {
|
||||
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 = () => {
|
||||
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) => {
|
||||
const p = createClient()
|
||||
const p = await mkTestNode()
|
||||
try {
|
||||
console.log("connecting to: ")
|
||||
console.log(config)
|
||||
|
@ -20,7 +20,7 @@ import { Buffer } from 'buffer';
|
||||
import { CallServiceData, CallServiceResult, CallServiceResultType, ResultCodes } from '../interfaces/commonTypes.js';
|
||||
import { ParticleExecutionStage } from './Particle.js';
|
||||
import { LogFunction } from '@fluencelabs/marine-js/dist/types';
|
||||
import {FluencePeer} from "./FluencePeer";
|
||||
import {FluencePeer} from "./FluencePeer.js";
|
||||
|
||||
export const MakeServiceCall =
|
||||
(fn: (args: any[]) => CallServiceResultType) =>
|
||||
|
@ -4,6 +4,7 @@
|
||||
"outDir": "./dist",
|
||||
"moduleResolution": "nodenext"
|
||||
},
|
||||
"skipLibCheck": true,
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist"],
|
||||
"esModuleInterop": true
|
||||
|
Loading…
Reference in New Issue
Block a user