alternative to test

This commit is contained in:
vms 2021-12-01 22:04:35 +03:00
parent 187710b12e
commit c2165ed137
9 changed files with 42262 additions and 13 deletions

14
package-lock.json generated
View File

@ -10,7 +10,7 @@
"license": "Apache-2.0",
"dependencies": {
"@chainsafe/libp2p-noise": "4.0.0",
"@fluencelabs/avm": "0.16.0-restriction-operator.9",
"@fluencelabs/avm": "0.17.4",
"async": "3.2.0",
"base64-js": "1.5.1",
"bs58": "4.0.1",
@ -647,9 +647,9 @@
}
},
"node_modules/@fluencelabs/avm": {
"version": "0.16.0-restriction-operator.9",
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.16.0-restriction-operator.9.tgz",
"integrity": "sha512-34vJqo8TIho5H2+WhEAJOa6WxAPiS+c7Z3WKmRZVi+GAsZN3Hv2NiuiCFNFBmPRoD+juzHe4Dmv5cF7HZc6O6w==",
"version": "0.17.4",
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.17.4.tgz",
"integrity": "sha512-VKD/XaEDXsP0eEgpbncBCsLyHbGDh+f7b96KbYoHld25r3C7mgEbbEVImKLaHGDUiR7ylPBxrtQhNL9MpgKwxA==",
"dependencies": {
"base64-js": "1.5.1"
}
@ -8694,9 +8694,9 @@
}
},
"@fluencelabs/avm": {
"version": "0.16.0-restriction-operator.9",
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.16.0-restriction-operator.9.tgz",
"integrity": "sha512-34vJqo8TIho5H2+WhEAJOa6WxAPiS+c7Z3WKmRZVi+GAsZN3Hv2NiuiCFNFBmPRoD+juzHe4Dmv5cF7HZc6O6w==",
"version": "0.17.4",
"resolved": "https://registry.npmjs.org/@fluencelabs/avm/-/avm-0.17.4.tgz",
"integrity": "sha512-VKD/XaEDXsP0eEgpbncBCsLyHbGDh+f7b96KbYoHld25r3C7mgEbbEVImKLaHGDUiR7ylPBxrtQhNL9MpgKwxA==",
"requires": {
"base64-js": "1.5.1"
}

View File

@ -21,7 +21,7 @@
"license": "Apache-2.0",
"dependencies": {
"@chainsafe/libp2p-noise": "4.0.0",
"@fluencelabs/avm": "0.16.0-restriction-operator.9",
"@fluencelabs/avm": "0.17.4",
"async": "3.2.0",
"base64-js": "1.5.1",
"bs58": "4.0.1",

View File

@ -0,0 +1,138 @@
import { Multiaddr } from 'multiaddr';
import { nodes } from '../connection';
import { Fluence, FluencePeer, setLogLevel } from '../../index';
import { checkConnection, doNothing, handleTimeout } from '../../internal/utils';
import { Particle } from '../../internal/Particle';
import { registerHandlersHelper } from '../util';
import { testNet } from "@fluencelabs/fluence-network-environment";
const anotherPeer = new FluencePeer();
async function main() {
// arrange
const peer = new FluencePeer();
await peer.start({ connectTo: testNet[0], avmLogLevel: "trace" });
const promise = new Promise((resolve, reject) => {
const script = `
(xor
(seq
(seq
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
(call %init_peer_id% ("getDataSrv" "clientId") [] clientId)
)
(xor
(par
(seq
(call -relay- ("kad" "neighborhood") [clientId [] []] neighbors)
(call %init_peer_id% ("op" "noop") [])
)
(fold neighbors n
(par
(seq
(call -relay- ("op" "noop") [])
(xor
(seq
(seq
(call n ("kad" "neighborhood") [n [] []] neighbors2)
(par
(seq
(call -relay- ("op" "noop") [])
(xor
(call %init_peer_id% ("callbackSrv" "logNeighs") [neighbors2])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1])
)
)
(null)
)
)
(fold neighbors2 n2
(seq
(seq
(seq
(call -relay- ("op" "noop") [])
(xor
(seq
(seq
(seq
(seq
(seq
(call n2 ("peer" "identify") [] ident)
(call n2 ("dist" "list_blueprints") [] blueprints)
)
(call n2 ("dist" "list_modules") [] modules)
)
(call n2 ("srv" "list") [] services)
)
(call -relay- ("op" "noop") [])
)
(xor
(call %init_peer_id% ("callbackSrv" "collectPeerInfo") [n2 ident services blueprints modules])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2])
)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3])
)
)
(call -relay- ("op" "noop") [])
)
(next n2)
)
)
)
(seq
(call -relay- ("op" "noop") [])
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 4])
)
)
)
(next n)
)
)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 5])
)
)
(call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 6])
)
`;
const particle = Particle.createNew(script);
let outer = ["1"];
let returns = 0;
registerHandlersHelper(peer, particle, {
getDataSrv: {
"-relay-": _ => {
return peer.getStatus().relayPeerId;
},
"clientId": _ => {
return peer.getStatus().peerId;
},
"outer": _ => {
return outer;
}
},
op: {
return: (args) => {
console.log("got op return: ", JSON.stringify(args));
returns += 1;
// if (returns == 5) {
// resolve(undefined);
// }
}
},
"callbackSrv": {
"logNeighs": args => {}
},
});
peer.internals.initiateParticle(particle, handleTimeout(reject));
});
await promise;
await peer.stop();
}
main()

View File

@ -5,7 +5,7 @@ import { checkConnection, doNothing, handleTimeout } from '../../internal/utils'
import { Particle } from '../../internal/Particle';
import { registerHandlersHelper } from '../util';
import { krasnodar } from "@fluencelabs/fluence-network-environment";
import { krasnodar, testNet } from "@fluencelabs/fluence-network-environment";
const anotherPeer = new FluencePeer();
@ -534,7 +534,7 @@ describe('Typescript usage suite', () => {
it('Fold: incompatible results bug', async () => {
// arrange
const peer = new FluencePeer();
await peer.start({ connectTo: krasnodar[0] });
await peer.start({ connectTo: testNet[0], avmLogLevel: "info" });
const promise = new Promise((resolve, reject) => {
const script = `
@ -621,7 +621,7 @@ describe('Typescript usage suite', () => {
`;
const particle = Particle.createNew(script);
let outer = ["1", "2", "3", "4", "5"];
let outer = ["1"];
let returns = 0;
registerHandlersHelper(peer, particle, {
getDataSrv: {
@ -643,7 +643,10 @@ describe('Typescript usage suite', () => {
// resolve(undefined);
// }
}
}
},
"callbackSrv": {
"logNeighs": args => { console.log("logNeighs", JSON.stringify(args)) }
},
});
peer.internals.initiateParticle(particle, handleTimeout(reject));

View File

@ -52,6 +52,9 @@ export type AvmLoglevel = LogLevel;
const DEFAULT_TTL = 7000;
let file_name = 1;
let interpreter_run = 1;
/**
* Configuration used when initiating Fluence Peer
*/
@ -594,6 +597,12 @@ function runInterpreter(
particle.logTo('debug', 'Sending particle to interpreter');
log.debug('prevData: ', dataToString(prevData));
log.debug('data: ', dataToString(particle.data));
let fs = require('fs');
let nn = `\n\ninterpreter run #${interpreter_run}:\n\n\n`;
fs.appendFileSync("./trace_instr.out", nn)
interpreter_run += 1;
const interpreterResult = interpreter.invoke(
particle.script,
prevData,
@ -611,7 +620,24 @@ function runInterpreter(
if (isInterpretationSuccessful(interpreterResult)) {
log.debug('Interpreter result: ', toLog);
} else {
log.error('Interpreter failed: ', toLog);
/*
log.error('Interpreter failed_____: ', toLog);
log.error('prevData: ', dataToString(prevData));
log.error('data: ', dataToString(particle.data));
*/
let str_1 = `Interpreter failed: ${JSON.stringify(toLog, null, 4)}\n\n`;
let str_2 = `prevData: ${JSON.stringify(dataToString(prevData), null, 4)}\n\n`;
let str_3 = `data: ${JSON.stringify(dataToString(particle.data), null, 4)}\n\n`;
const fs = require('fs');
let ff = `./${file_name}.out`;
fs.writeFileSync(ff, str_1 + str_2 + str_3);
file_name += 1;
process.exit(1);
// setTimeout(() => process.exit(1), 20000);
}
return interpreterResult;
}

View File

@ -20,8 +20,12 @@ import { CallServiceData, CallServiceResult, CallServiceResultType, ResultCodes
import { AvmLoglevel, FluencePeer } from './FluencePeer';
import { Particle, ParticleExecutionStage } from './Particle';
let fs = require('fs');
export const createInterpreter = (logLevel: AvmLoglevel): Promise<AirInterpreter> => {
const logFn = (level: AvmLogLevel, msg: string) => {
let msg_n = `${msg}\n`;
fs.appendFileSync("./trace_instr.out", msg_n);
/*
switch (level) {
case 'error':
log.error(msg);
@ -40,6 +44,8 @@ export const createInterpreter = (logLevel: AvmLoglevel): Promise<AirInterpreter
log.log(msg);
break;
}
*/
};
return AirInterpreter.create(logLevel, logFn);
};

3
trace.out Normal file
View File

@ -0,0 +1,3 @@
[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "undefined".] {
code: 'ERR_UNHANDLED_REJECTION'
}

41595
trace_instr.out Normal file

File diff suppressed because it is too large Load Diff

478
trace_log.out Normal file
View File

@ -0,0 +1,478 @@
> xor
> seq
> seq
> call
> call
> xor
> par
> seq
> call
> call
> fold
> par
> seq
> call
> xor
> seq
> seq
> call
> par
> seq
> call
> xor
> call
> null
> fold
> seq
> seq
> seq
> call
> xor
> seq
> seq
> seq
> seq
> seq
> call
> next
> par
> seq
> call
> xor
> seq
> seq
> call
> par
> seq
> call
> xor
> call
> null
> fold
> seq
> seq
> seq
> call
> xor
> seq
> seq
> seq
> seq
> seq
> call
> next
> par
> seq
> call
> xor
> seq
> seq
> call
> par
> seq
> call
> xor
> call
> null
> fold
> seq
> seq
> seq
> call
> xor
> seq
> seq
> seq
> seq
> seq
> call
> next
> par
> seq
> call
> xor
> seq
> seq
> call
> par
> seq
> call
> null
> fold
> seq
> seq
> seq
> call
> next
> par
> seq
> call
> xor
> seq
> seq
> call
> par
> seq
> call
> xor
> call
> null
> fold
> seq
> seq
> seq
> call
> xor
> seq
> seq
> seq
> seq
> seq
> call
> next
> par
> seq
> call
> xor
> seq
> seq
> call
> par
> seq
> call
> xor
> call
> null
> fold
> seq
> seq
> seq
> call
> xor
> seq
> seq
> seq
> seq
> seq
> call
> next
> par
> seq
> call
> xor
> seq
> seq
> call
> par
> seq
> call
> xor
> call
> null
> fold
> seq
> seq
> seq
> call
> xor
> seq
> seq
> seq
> seq
> seq
> call
> call
> call
> call
> call
> next
> par
> seq
> call
> xor
> seq
> seq
> call
> par
> seq
> call
> xor
> call
> null
> fold
> seq
> seq
> seq
> call
> xor
> seq
> seq
> seq
> seq
> seq
> call
> next
> par
> seq
> call
> xor
> seq
> seq
> call
> par
> seq
> call
> xor
> call
> null
> fold
> seq
> seq
> seq
> call
> xor
> seq
> seq
> seq
> seq
> seq
> call
> next
> par
> seq
> call
> xor
> seq
> seq
> call
> par
> seq
> call
> xor
> call
> null
> fold
> seq
> seq
> seq
> call
> xor
> seq
> seq
> seq
> seq
> seq
> call
> next
> par
> seq
> call
> xor
> seq
> seq
> call
> par
> seq
> call
> xor
> call
> null
> fold
> seq
> seq
> seq
> call
> xor
> seq
> seq
> seq
> seq
> seq
> call
> call
> call
> call
> call
> xor
> call
> next
> par
> seq
> call
> xor
> seq
> seq
> call
> par
> seq
> call
> xor
> call
> null
> fold
> seq
> seq
> seq
> call
> xor
> seq
> seq
> seq
> seq
> seq
> call
> next
> par
> seq
> call
> xor
> seq
> seq
> call
> par
> seq
> call
> xor
> call
> null
> fold
> seq
> seq
> seq
> call
> xor
> seq
> seq
> seq
> seq
> seq
> call
> next
> par
> seq
> call
> xor
> seq
> seq
> call
> par
> seq
> call
> xor
> call
> null
> fold
> seq
> seq
> seq
> call
> xor
> seq
> seq
> seq
> seq
> seq
> call
> next
> par
> seq
> call
> xor
> seq
> seq
> call
> next
> par
> seq
> call
> xor
> seq
> seq
> call
> par
> seq
> call
> xor
> call
> null
> fold
> seq
> seq
> seq
> call
> xor
> seq
> seq
> seq
> seq
> seq
> call
> next
> par
> seq
> call
> xor
> seq
> seq
> call
> par
> seq
> call
> xor
> call
> null
> fold
> seq
> seq
> seq
> call
> xor
> seq
> seq
> seq
> seq
> seq
> call
> next
> par
> seq
> call
> xor
> seq
> seq
> call
> par
> seq
> call
> xor
> call
> null
> fold
> seq
> seq
> seq
> call
> xor
> seq
> seq
> seq
> seq
> seq
> call
> next
> par
> seq
> call
> xor
> seq
> seq
> call
> next
> par
> seq
> call
> xor
> seq
> seq
> call
> next