mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2025-04-25 09:52:12 +00:00
fix(test): All tests are working with vitest [DXJ-306] (#291)
This commit is contained in:
parent
9345040b87
commit
58ad3ca6f6
3
packages/core/js-peer/.gitignore
vendored
3
packages/core/js-peer/.gitignore
vendored
@ -19,3 +19,6 @@ node_modules/
|
|||||||
jspm_packages/
|
jspm_packages/
|
||||||
|
|
||||||
.idea
|
.idea
|
||||||
|
|
||||||
|
# workaround to make integration tests work
|
||||||
|
src/marine/worker-script/index.js
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
module Export
|
module Export
|
||||||
|
|
||||||
import SignResult, Sig from "../../../aqua/services.aqua"
|
import SignResult, Sig from "../aqua/services.aqua"
|
||||||
export Sig, DataProvider, callSig
|
export Sig, DataProvider, callSig
|
||||||
|
|
||||||
service DataProvider("data"):
|
service DataProvider("data"):
|
@ -1,7 +1,7 @@
|
|||||||
module Export
|
module Export
|
||||||
|
|
||||||
import Srv from "../../../aqua/single-module-srv.aqua"
|
import Srv from "../aqua/single-module-srv.aqua"
|
||||||
import NodeUtils from "../../../aqua/node-utils.aqua"
|
import NodeUtils from "../aqua/node-utils.aqua"
|
||||||
export happy_path, list_services, file_not_found, service_removed, removing_non_exiting
|
export happy_path, list_services, file_not_found, service_removed, removing_non_exiting
|
||||||
|
|
||||||
service Greeting("greeting"):
|
service Greeting("greeting"):
|
3
packages/core/js-peer/copy-worker-script-workaround.mjs
Normal file
3
packages/core/js-peer/copy-worker-script-workaround.mjs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import { copyFileSync } from 'fs';
|
||||||
|
|
||||||
|
copyFileSync('./dist/marine/worker-script/index.js', './src/marine/worker-script/index.js');
|
@ -1,17 +0,0 @@
|
|||||||
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
|
||||||
module.exports = {
|
|
||||||
extensionsToTreatAsEsm: ['.ts'],
|
|
||||||
"preset": "ts-jest/presets/default-esm",
|
|
||||||
"moduleNameMapper": {
|
|
||||||
"^(\\.{1,2}/.*)\\.js$": "$1"
|
|
||||||
},
|
|
||||||
"transform": {
|
|
||||||
"^.+\\.tsx?$": [
|
|
||||||
"ts-jest",
|
|
||||||
{
|
|
||||||
"useESM": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
@ -11,11 +11,8 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"compile-aqua": "aqua -i ./aqua/ -o ./src/internal/_aqua",
|
"compile-aqua": "fluence aqua -i ./aqua/ -o ./aqua",
|
||||||
"test:smoke": "node ./dist/js-peer/__test__/integration/smokeTest.js",
|
"test": "node ./copy-worker-script-workaround.mjs && vitest run"
|
||||||
"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"
|
|
||||||
},
|
},
|
||||||
"repository": "https://github.com/fluencelabs/fluence-js",
|
"repository": "https://github.com/fluencelabs/fluence-js",
|
||||||
"author": "Fluence Labs",
|
"author": "Fluence Labs",
|
||||||
@ -52,15 +49,13 @@
|
|||||||
"@multiformats/multiaddr": "11.3.0"
|
"@multiformats/multiaddr": "11.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@fluencelabs/aqua": "0.7.7-362",
|
"@fluencelabs/cli": "0.3.9",
|
||||||
"@fluencelabs/aqua-api": "0.9.1-373",
|
"@fluencelabs/aqua-api": "0.9.3",
|
||||||
"@fluencelabs/aqua-lib": "0.6.0",
|
"@fluencelabs/aqua-lib": "0.6.0",
|
||||||
"@fluencelabs/fluence-network-environment": "1.0.13",
|
"@fluencelabs/fluence-network-environment": "1.0.13",
|
||||||
"@types/bs58": "4.0.1",
|
"@types/bs58": "4.0.1",
|
||||||
"@types/uuid": "8.3.2",
|
"@types/uuid": "8.3.2",
|
||||||
"@types/jest": "29.4.0",
|
|
||||||
"@types/debug": "4.1.7",
|
"@types/debug": "4.1.7",
|
||||||
"jest": "29.4.1",
|
"vitest": "0.29.7"
|
||||||
"ts-jest": "next"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { it, describe, expect, test } from 'vitest';
|
||||||
import { aqua2ts, ts2aqua } from '../conversions.js';
|
import { aqua2ts, ts2aqua } from '../conversions.js';
|
||||||
|
|
||||||
const i32 = { tag: 'scalar', name: 'i32' } as const;
|
const i32 = { tag: 'scalar', name: 'i32' } as const;
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { it, describe, expect } from 'vitest';
|
||||||
|
|
||||||
import { handleTimeout } from '../../utils.js';
|
import { handleTimeout } from '../../utils.js';
|
||||||
import { registerHandlersHelper, withPeer } from '../util.js';
|
import { registerHandlersHelper, withPeer } from '../util.js';
|
||||||
|
|
@ -1,3 +1,5 @@
|
|||||||
|
import { it, describe, expect, beforeEach, afterEach } from 'vitest';
|
||||||
|
|
||||||
import { Particle } from '../../Particle.js';
|
import { Particle } from '../../Particle.js';
|
||||||
import { doNothing } from '../../utils.js';
|
import { doNothing } from '../../utils.js';
|
||||||
import { FluencePeer } from '../../FluencePeer.js';
|
import { FluencePeer } from '../../FluencePeer.js';
|
@ -0,0 +1,31 @@
|
|||||||
|
import { it, describe, expect, beforeAll } from 'vitest';
|
||||||
|
|
||||||
|
import * as fs from 'fs';
|
||||||
|
import * as url from 'url';
|
||||||
|
import * as path from 'path';
|
||||||
|
import { compileAqua, withPeer } from '../util.js';
|
||||||
|
|
||||||
|
let aqua: any;
|
||||||
|
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
||||||
|
|
||||||
|
describe('Marine js tests', () => {
|
||||||
|
beforeAll(async () => {
|
||||||
|
const pathToAquaFiles = path.join(__dirname, '../../../../aqua_test/marine-js.aqua');
|
||||||
|
const { services, functions } = await compileAqua(pathToAquaFiles);
|
||||||
|
aqua = functions;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call marine service correctly', async () => {
|
||||||
|
await withPeer(async (peer) => {
|
||||||
|
// arrange
|
||||||
|
const wasm = await fs.promises.readFile(path.join(__dirname, '../data/greeting.wasm'));
|
||||||
|
await peer.registerMarineService(wasm, 'greeting');
|
||||||
|
|
||||||
|
// act
|
||||||
|
const res = await aqua.call(peer, { arg: 'test' });
|
||||||
|
|
||||||
|
// assert
|
||||||
|
expect(res).toBe('Hi, Hi, Hi, test');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -1,53 +0,0 @@
|
|||||||
import * as fs from 'fs';
|
|
||||||
import * as url from 'url';
|
|
||||||
import * as path from 'path';
|
|
||||||
import { compileAqua, withPeer } from '../util.js';
|
|
||||||
|
|
||||||
let aqua: any;
|
|
||||||
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
|
||||||
|
|
||||||
describe('Marine js tests', () => {
|
|
||||||
beforeAll(async () => {
|
|
||||||
const { services, functions } = await compileAqua(path.join(__dirname, '../data/marine-js.aqua'));
|
|
||||||
aqua = functions;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should call marine service correctly', async () => {
|
|
||||||
await withPeer(async (peer) => {
|
|
||||||
// arrange
|
|
||||||
const wasm = await fs.promises.readFile(path.join(__dirname, '../data/greeting.wasm'));
|
|
||||||
await peer.registerMarineService(wasm, 'greeting');
|
|
||||||
|
|
||||||
// act
|
|
||||||
const res = await aqua.call(peer, { arg: 'test' });
|
|
||||||
|
|
||||||
// assert
|
|
||||||
expect(res).toBe('Hi, Hi, Hi, test');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// TODO: console printouts are happening inside web-worker\worker threads.
|
|
||||||
// Find a way to mock functions in background thread
|
|
||||||
it.skip('logging should work', async () => {
|
|
||||||
await withPeer(async (peer) => {
|
|
||||||
// arrange
|
|
||||||
|
|
||||||
jest.spyOn(global.console, 'info').mockImplementation(() => {});
|
|
||||||
|
|
||||||
await peer.start({
|
|
||||||
debug: {
|
|
||||||
marineLogLevel: 'debug',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const wasm = await fs.promises.readFile(path.join(__dirname, '../data/greeting-record.wasm'));
|
|
||||||
await peer.registerMarineService(wasm, 'greeting');
|
|
||||||
|
|
||||||
// act
|
|
||||||
await aqua.call_info(peer, { arg: 'greeting' });
|
|
||||||
|
|
||||||
// assert
|
|
||||||
expect(console.info).toBeCalledTimes(1);
|
|
||||||
expect(console.info).toHaveBeenNthCalledWith(1, '[marine service "greeting"]: info');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,7 +1,10 @@
|
|||||||
|
import { it, describe, expect } from 'vitest';
|
||||||
|
|
||||||
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 } from '../util.js';
|
||||||
import { FluencePeer } from '../../FluencePeer.js';
|
import { FluencePeer } from '../../FluencePeer.js';
|
||||||
|
import { isFluencePeer } from '@fluencelabs/interfaces';
|
||||||
|
|
||||||
describe('Typescript usage suite', () => {
|
describe('Typescript usage suite', () => {
|
||||||
it('should perform test for FluencePeer class correctly', () => {
|
it('should perform test for FluencePeer class correctly', () => {
|
||||||
@ -12,10 +15,10 @@ describe('Typescript usage suite', () => {
|
|||||||
const undefinedVal = undefined;
|
const undefinedVal = undefined;
|
||||||
|
|
||||||
// act
|
// act
|
||||||
const isPeerPeer = FluencePeer.isInstance(peer);
|
const isPeerPeer = isFluencePeer(peer);
|
||||||
const isNumberPeer = FluencePeer.isInstance(number);
|
const isNumberPeer = isFluencePeer(number);
|
||||||
const isObjectPeer = FluencePeer.isInstance(object);
|
const isObjectPeer = isFluencePeer(object);
|
||||||
const isUndefinedPeer = FluencePeer.isInstance(undefinedVal);
|
const isUndefinedPeer = isFluencePeer(undefinedVal);
|
||||||
|
|
||||||
// act
|
// act
|
||||||
expect(isPeerPeer).toBe(true);
|
expect(isPeerPeer).toBe(true);
|
||||||
@ -196,7 +199,7 @@ describe('Typescript usage suite', () => {
|
|||||||
|
|
||||||
expect(isConnected).toBeTruthy();
|
expect(isConnected).toBeTruthy();
|
||||||
},
|
},
|
||||||
{ connectTo: nodes[0], dialTimeoutMs: 100000 },
|
{ relay: nodes[0], connectionOptions: { dialTimeoutMs: 100000 } },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -207,18 +210,7 @@ describe('Typescript usage suite', () => {
|
|||||||
|
|
||||||
expect(isConnected).toBeTruthy();
|
expect(isConnected).toBeTruthy();
|
||||||
},
|
},
|
||||||
{ connectTo: nodes[0], skipCheckConnection: true },
|
{ relay: nodes[0], connectionOptions: { skipCheckConnection: true } },
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('With connection options: checkConnectionTTL', async () => {
|
|
||||||
await withPeer(
|
|
||||||
async (peer) => {
|
|
||||||
const isConnected = await checkConnection(peer);
|
|
||||||
|
|
||||||
expect(isConnected).toBeTruthy();
|
|
||||||
},
|
|
||||||
{ connectTo: nodes[0], checkConnectionTimeoutMs: 1000 },
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -229,7 +221,7 @@ describe('Typescript usage suite', () => {
|
|||||||
|
|
||||||
expect(isConnected).toBeFalsy();
|
expect(isConnected).toBeFalsy();
|
||||||
},
|
},
|
||||||
{ connectTo: nodes[0], defaultTtlMs: 1 },
|
{ relay: nodes[0], defaultTtlMs: 1 },
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -1,10 +1,12 @@
|
|||||||
|
import { it, describe, expect, beforeAll } from 'vitest';
|
||||||
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as url from 'url';
|
import * as url from 'url';
|
||||||
import { KeyPair } from '../../../keypair/index.js';
|
import { KeyPair } from '../../../keypair/index.js';
|
||||||
import { allowServiceFn } from '../../builtins/securityGuard.js';
|
import { allowServiceFn } from '../../builtins/securityGuard.js';
|
||||||
import { Sig } from '../../builtins/Sig.js';
|
import { Sig } from '../../builtins/Sig.js';
|
||||||
import { compileAqua, withPeer } from '../util.js';
|
import { compileAqua, withPeer } from '../util.js';
|
||||||
import { registerServiceImpl } from '../../compilerSupport/registerService.js';
|
import { registerService } from '../../../compilerSupport/registerService.js';
|
||||||
|
|
||||||
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
|
||||||
|
|
||||||
@ -14,7 +16,9 @@ let dataProviderDef: any;
|
|||||||
|
|
||||||
describe('Sig service test suite', () => {
|
describe('Sig service test suite', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const { services, functions } = await compileAqua(path.join(__dirname, '../data/sigService.aqua'));
|
const pathToAquaFiles = path.join(__dirname, '../../../../aqua_test/sigService.aqua');
|
||||||
|
const { services, functions } = await compileAqua(pathToAquaFiles);
|
||||||
|
|
||||||
aqua = functions;
|
aqua = functions;
|
||||||
sigDef = services.Sig;
|
sigDef = services.Sig;
|
||||||
dataProviderDef = services.DataProvider;
|
dataProviderDef = services.DataProvider;
|
||||||
@ -26,12 +30,17 @@ describe('Sig service test suite', () => {
|
|||||||
const customSig = new Sig(customKeyPair);
|
const customSig = new Sig(customKeyPair);
|
||||||
const data = [1, 2, 3, 4, 5];
|
const data = [1, 2, 3, 4, 5];
|
||||||
|
|
||||||
registerServiceImpl(peer, sigDef, 'CustomSig', customSig);
|
registerService({ peer, def: sigDef, serviceId: 'CustomSig', service: customSig });
|
||||||
|
|
||||||
registerServiceImpl(peer, dataProviderDef, 'data', {
|
registerService({
|
||||||
|
peer,
|
||||||
|
def: dataProviderDef,
|
||||||
|
serviceId: 'data',
|
||||||
|
service: {
|
||||||
provide_data: () => {
|
provide_data: () => {
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
customSig.securityGuard = allowServiceFn('data', 'provide_data');
|
customSig.securityGuard = allowServiceFn('data', 'provide_data');
|
||||||
@ -50,12 +59,17 @@ describe('Sig service test suite', () => {
|
|||||||
const customSig = new Sig(customKeyPair);
|
const customSig = new Sig(customKeyPair);
|
||||||
const data = [1, 2, 3, 4, 5];
|
const data = [1, 2, 3, 4, 5];
|
||||||
|
|
||||||
registerServiceImpl(peer, sigDef, 'CustomSig', customSig);
|
registerService({ peer, def: sigDef, serviceId: 'CustomSig', service: customSig });
|
||||||
|
|
||||||
registerServiceImpl(peer, dataProviderDef, 'data', {
|
registerService({
|
||||||
|
peer,
|
||||||
|
def: dataProviderDef,
|
||||||
|
serviceId: 'data',
|
||||||
|
service: {
|
||||||
provide_data: () => {
|
provide_data: () => {
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
customSig.securityGuard = allowServiceFn('wrong', 'wrong');
|
customSig.securityGuard = allowServiceFn('wrong', 'wrong');
|
||||||
@ -69,10 +83,15 @@ describe('Sig service test suite', () => {
|
|||||||
const sig = peer.getServices().sig;
|
const sig = peer.getServices().sig;
|
||||||
|
|
||||||
const data = [1, 2, 3, 4, 5];
|
const data = [1, 2, 3, 4, 5];
|
||||||
registerServiceImpl(peer, dataProviderDef, 'data', {
|
registerService({
|
||||||
|
peer: peer,
|
||||||
|
def: dataProviderDef,
|
||||||
|
serviceId: 'data',
|
||||||
|
service: {
|
||||||
provide_data: () => {
|
provide_data: () => {
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const callAsSigRes = await aqua.callSig(peer, { sigId: 'sig' });
|
const callAsSigRes = await aqua.callSig(peer, { sigId: 'sig' });
|
@ -0,0 +1,61 @@
|
|||||||
|
import { it, describe, expect } from 'vitest';
|
||||||
|
|
||||||
|
import { handleTimeout } from '../../utils.js';
|
||||||
|
import { nodes } from '../connection.js';
|
||||||
|
import { mkTestPeer, registerHandlersHelper } from '../util.js';
|
||||||
|
|
||||||
|
describe('Smoke test', () => {
|
||||||
|
it('Simple call', async () => {
|
||||||
|
// arrange
|
||||||
|
const peer = mkTestPeer();
|
||||||
|
await peer.start({
|
||||||
|
relay: nodes[0],
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await new Promise<string[]>((resolve, reject) => {
|
||||||
|
const script = `
|
||||||
|
(xor
|
||||||
|
(seq
|
||||||
|
(call %init_peer_id% ("load" "relay") [] init_relay)
|
||||||
|
(seq
|
||||||
|
(call init_relay ("op" "identity") ["hello world!"] result)
|
||||||
|
(call %init_peer_id% ("callback" "callback") [result])
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(seq
|
||||||
|
(call init_relay ("op" "identity") [])
|
||||||
|
(call %init_peer_id% ("callback" "error") [%last_error%])
|
||||||
|
)
|
||||||
|
)`;
|
||||||
|
const particle = peer.internals.createNewParticle(script);
|
||||||
|
|
||||||
|
if (particle instanceof Error) {
|
||||||
|
return reject(particle.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
registerHandlersHelper(peer, particle, {
|
||||||
|
load: {
|
||||||
|
relay: () => {
|
||||||
|
return peer.getStatus().relayPeerId;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
callback: {
|
||||||
|
callback: (args: any) => {
|
||||||
|
const [val] = args;
|
||||||
|
resolve(val);
|
||||||
|
},
|
||||||
|
error: (args: any) => {
|
||||||
|
const [error] = args;
|
||||||
|
reject(error);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
peer.internals.initiateParticle(particle, handleTimeout(reject));
|
||||||
|
});
|
||||||
|
|
||||||
|
await peer.stop();
|
||||||
|
|
||||||
|
expect(result).toBe('hello world!');
|
||||||
|
});
|
||||||
|
});
|
@ -1,67 +0,0 @@
|
|||||||
import { handleTimeout } from '../../utils.js';
|
|
||||||
import { nodes } from '../connection.js';
|
|
||||||
import { mkTestPeer, registerHandlersHelper } from '../util.js';
|
|
||||||
|
|
||||||
const smokeTest = async () => {
|
|
||||||
// arrange
|
|
||||||
const peer = mkTestPeer();
|
|
||||||
await peer.start({
|
|
||||||
relay: nodes[0],
|
|
||||||
});
|
|
||||||
|
|
||||||
const result = await new Promise<string[]>((resolve, reject) => {
|
|
||||||
const script = `
|
|
||||||
(xor
|
|
||||||
(seq
|
|
||||||
(call %init_peer_id% ("load" "relay") [] init_relay)
|
|
||||||
(seq
|
|
||||||
(call init_relay ("op" "identity") ["hello world!"] result)
|
|
||||||
(call %init_peer_id% ("callback" "callback") [result])
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(seq
|
|
||||||
(call init_relay ("op" "identity") [])
|
|
||||||
(call %init_peer_id% ("callback" "error") [%last_error%])
|
|
||||||
)
|
|
||||||
)`;
|
|
||||||
const particle = peer.internals.createNewParticle(script);
|
|
||||||
|
|
||||||
if (particle instanceof Error) {
|
|
||||||
return reject(particle.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
registerHandlersHelper(peer, particle, {
|
|
||||||
load: {
|
|
||||||
relay: () => {
|
|
||||||
return peer.getStatus().relayPeerId;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
callback: {
|
|
||||||
callback: (args: any) => {
|
|
||||||
const [val] = args;
|
|
||||||
resolve(val);
|
|
||||||
},
|
|
||||||
error: (args: any) => {
|
|
||||||
const [error] = args;
|
|
||||||
reject(error);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
peer.internals.initiateParticle(particle, handleTimeout(reject));
|
|
||||||
});
|
|
||||||
|
|
||||||
await peer.stop();
|
|
||||||
|
|
||||||
if (result[0] !== 'hello world!') {
|
|
||||||
throw new Error('Expecting "hello wrold!" got ' + result[0]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
smokeTest()
|
|
||||||
.then(() => {
|
|
||||||
console.log('Test passed');
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.error('Test failed: ', err);
|
|
||||||
});
|
|
@ -1,3 +1,4 @@
|
|||||||
|
import { it, describe, expect, beforeAll } from 'vitest';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as url from 'url';
|
import * as url from 'url';
|
||||||
import { compileAqua, withPeer } from '../util.js';
|
import { compileAqua, withPeer } from '../util.js';
|
||||||
@ -7,7 +8,8 @@ let aqua: any;
|
|||||||
|
|
||||||
describe('Srv service test suite', () => {
|
describe('Srv service test suite', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const { services, functions } = await compileAqua(path.join(__dirname, '../data/srv.aqua'));
|
const pathToAquaFiles = path.join(__dirname, '../../../../aqua_test/srv.aqua');
|
||||||
|
const { services, functions } = await compileAqua(pathToAquaFiles);
|
||||||
aqua = functions;
|
aqua = functions;
|
||||||
});
|
});
|
||||||
|
|
@ -1,3 +1,5 @@
|
|||||||
|
import { it, describe, expect, beforeAll, afterAll } from 'vitest';
|
||||||
|
|
||||||
import { mkTestPeer } from '../util.js';
|
import { mkTestPeer } from '../util.js';
|
||||||
|
|
||||||
const peer = mkTestPeer();
|
const peer = mkTestPeer();
|
@ -1,3 +1,5 @@
|
|||||||
|
import { it, describe, expect, test } from 'vitest';
|
||||||
|
|
||||||
import { CallParams } from '@fluencelabs/interfaces';
|
import { CallParams } from '@fluencelabs/interfaces';
|
||||||
import { toUint8Array } from 'js-base64';
|
import { toUint8Array } from 'js-base64';
|
||||||
import { CallServiceData } from '../../../interfaces/commonTypes.js';
|
import { CallServiceData } from '../../../interfaces/commonTypes.js';
|
||||||
|
@ -36,6 +36,10 @@ export const compileAqua = async (aquaFile: string): Promise<CompiledFile> => {
|
|||||||
|
|
||||||
const compilationResult = await api.Aqua.compile(new api.Path(aquaFile), [], undefined);
|
const compilationResult = await api.Aqua.compile(new api.Path(aquaFile), [], undefined);
|
||||||
|
|
||||||
|
if (compilationResult.errors.length > 0) {
|
||||||
|
throw new Error('Aqua compilation failed. Error: ' + compilationResult.errors.join('/n'));
|
||||||
|
}
|
||||||
|
|
||||||
const functions = Object.entries(compilationResult.functions)
|
const functions = Object.entries(compilationResult.functions)
|
||||||
.map(([name, fnInfo]) => {
|
.map(([name, fnInfo]) => {
|
||||||
const callFn = (peer: FluencePeer, args: { [key: string]: any }) => {
|
const callFn = (peer: FluencePeer, args: { [key: string]: any }) => {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { it, describe, expect } from 'vitest';
|
||||||
import { toUint8Array } from 'js-base64';
|
import { toUint8Array } from 'js-base64';
|
||||||
import * as bs58 from 'bs58';
|
import * as bs58 from 'bs58';
|
||||||
import { KeyPair } from '../index.js';
|
import { KeyPair } from '../index.js';
|
||||||
|
1253
pnpm-lock.yaml
generated
1253
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user