mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2024-12-05 02:10:18 +00:00
Compiler support: fix issue with incorrect ttl value in config (#100)
This commit is contained in:
parent
aa21abe465
commit
6e0a8c011f
14
package-lock.json
generated
14
package-lock.json
generated
@ -10,7 +10,7 @@
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@chainsafe/libp2p-noise": "4.0.0",
|
||||
"@fluencelabs/avm": "0.16.6",
|
||||
"@fluencelabs/avm": "0.16.7",
|
||||
"async": "3.2.0",
|
||||
"base64-js": "1.5.1",
|
||||
"bs58": "4.0.1",
|
||||
@ -646,9 +646,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@fluencelabs/avm": {
|
||||
"version": "0.16.6",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.16.6.tgz",
|
||||
"integrity": "sha512-RDNXW/VYAXh+E7B7+S4pTTc/1IcvtlID2xyBs/3TDlxkjbVxM7+vMcFL6cJZOzZZl+3oAWXL3ibDhE5Elcq6ug==",
|
||||
"version": "0.16.7",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.16.7.tgz",
|
||||
"integrity": "sha512-tSbEBRdHTz6PCxLuzEWe3ayZQeDiuJu/Dw0qJmdpYe6eJf0jSwUnAnRaEOv2d0ILnzT1b4us9tCKOhac41YlLg==",
|
||||
"dependencies": {
|
||||
"base64-js": "1.5.1"
|
||||
}
|
||||
@ -8689,9 +8689,9 @@
|
||||
}
|
||||
},
|
||||
"@fluencelabs/avm": {
|
||||
"version": "0.16.6",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.16.6.tgz",
|
||||
"integrity": "sha512-RDNXW/VYAXh+E7B7+S4pTTc/1IcvtlID2xyBs/3TDlxkjbVxM7+vMcFL6cJZOzZZl+3oAWXL3ibDhE5Elcq6ug==",
|
||||
"version": "0.16.7",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.16.7.tgz",
|
||||
"integrity": "sha512-tSbEBRdHTz6PCxLuzEWe3ayZQeDiuJu/Dw0qJmdpYe6eJf0jSwUnAnRaEOv2d0ILnzT1b4us9tCKOhac41YlLg==",
|
||||
"requires": {
|
||||
"base64-js": "1.5.1"
|
||||
}
|
||||
|
@ -20,8 +20,8 @@
|
||||
"author": "Fluence Labs",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@fluencelabs/avm": "0.16.7",
|
||||
"@chainsafe/libp2p-noise": "4.0.0",
|
||||
"@fluencelabs/avm": "0.16.6",
|
||||
"async": "3.2.0",
|
||||
"base64-js": "1.5.1",
|
||||
"bs58": "4.0.1",
|
||||
|
36
src/__test__/unit/compilerSupport.spec.ts
Normal file
36
src/__test__/unit/compilerSupport.spec.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import each from 'jest-each';
|
||||
import { Fluence, FluencePeer } from '../..';
|
||||
import { forTests } from '../../internal/compilerSupport/v2';
|
||||
|
||||
const peer = new FluencePeer();
|
||||
const cfg = { ttl: 1000 };
|
||||
|
||||
describe('Compiler support tests', () => {
|
||||
each`
|
||||
rawArgs | numArgs | expectedArgs | expectedConfig | isExpectedPeerDefault
|
||||
${[]} | ${0} | ${[]} | ${undefined} | ${true}
|
||||
${[cfg]} | ${0} | ${[]} | ${cfg} | ${true}
|
||||
${[peer]} | ${0} | ${[]} | ${undefined} | ${false}
|
||||
${[peer, cfg]} | ${0} | ${[]} | ${cfg} | ${false}
|
||||
${['a']} | ${1} | ${['a']} | ${undefined} | ${true}
|
||||
${['a', cfg]} | ${1} | ${['a']} | ${cfg} | ${true}
|
||||
${[peer, 'a']} | ${1} | ${['a']} | ${undefined} | ${false}
|
||||
${[peer, 'a', cfg]} | ${1} | ${['a']} | ${cfg} | ${false}
|
||||
`.test(
|
||||
//
|
||||
'raw rawArgs: $rawArgs, numArgs: $numArgs. expected args: $expectedArgs, config: $expectedConfig, default peer?: $isExpectedPeerDefault',
|
||||
async ({ rawArgs, numArgs, expectedArgs, expectedConfig, isExpectedPeerDefault }) => {
|
||||
// arrange
|
||||
const testFn = forTests.extractFunctionArgs;
|
||||
|
||||
// act
|
||||
const { peer, config, args } = testFn(rawArgs, numArgs);
|
||||
const isActualPeerDefault = Fluence.getPeer() === peer;
|
||||
|
||||
// assert
|
||||
expect(config).toStrictEqual(expectedConfig);
|
||||
expect(args).toStrictEqual(expectedArgs);
|
||||
expect(isActualPeerDefault).toStrictEqual(isExpectedPeerDefault);
|
||||
},
|
||||
);
|
||||
});
|
@ -420,7 +420,7 @@ export class FluencePeer {
|
||||
const result = runInterpreter(this.getStatus().peerId, this._interpreter, particle, prevData);
|
||||
|
||||
// Do not continue if there was an error in particle interpretation
|
||||
if (isInterpretationSuccessful(result)) {
|
||||
if (!isInterpretationSuccessful(result)) {
|
||||
item.onStageChange({ stage: 'interpreterError', errorMessage: result.errorMessage });
|
||||
return;
|
||||
}
|
||||
@ -575,7 +575,7 @@ export class FluencePeer {
|
||||
}
|
||||
|
||||
function isInterpretationSuccessful(result: InterpreterResult) {
|
||||
return result.retCode !== 0 || result?.errorMessage?.length > 0;
|
||||
return result.retCode === 0;
|
||||
}
|
||||
|
||||
function serviceFnKey(serviceId: string, fnName: string) {
|
||||
|
@ -460,11 +460,11 @@ const extractFunctionArgs = (
|
||||
if (FluencePeer.isInstance(args[0])) {
|
||||
peer = args[0];
|
||||
structuredArgs = args.slice(1, numberOfExpectedArgs + 1);
|
||||
config = args[numberOfExpectedArgs + 2];
|
||||
config = args[numberOfExpectedArgs + 1];
|
||||
} else {
|
||||
peer = Fluence.getPeer();
|
||||
structuredArgs = args.slice(0, numberOfExpectedArgs);
|
||||
config = args[numberOfExpectedArgs + 1];
|
||||
config = args[numberOfExpectedArgs];
|
||||
}
|
||||
|
||||
return {
|
||||
@ -530,3 +530,7 @@ const extractRegisterServiceArgs = (
|
||||
function throwForReq(req: CallServiceData, message: string) {
|
||||
throw new Error(`${message}, serviceId='${req.serviceId}' fnName='${req.fnName}' args='${req.args}'`);
|
||||
}
|
||||
|
||||
export const forTests = {
|
||||
extractFunctionArgs,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user