mirror of
https://github.com/fluencelabs/fluence-js.git
synced 2024-12-04 18:00:18 +00:00
trying to reproduce dashboard bug
This commit is contained in:
parent
7577170780
commit
187710b12e
13
package-lock.json
generated
13
package-lock.json
generated
@ -29,6 +29,7 @@
|
||||
"uuid": "8.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@fluencelabs/fluence-network-environment": "1.0.10",
|
||||
"@types/jest": "^26.0.22",
|
||||
"jest": "^26.6.3",
|
||||
"ts-jest": "^26.5.4",
|
||||
@ -653,6 +654,12 @@
|
||||
"base64-js": "1.5.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@fluencelabs/fluence-network-environment": {
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/fluence-network-environment/-/fluence-network-environment-1.0.10.tgz",
|
||||
"integrity": "sha512-aaWZDDFIIasSTgdFdw1KEz+boZMSn7pXffUENZNLX4DrP11rC3AEX4c8GnIJQbWqGsouOFZOPna2DSG6o2rLNQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@istanbuljs/load-nyc-config": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
|
||||
@ -8694,6 +8701,12 @@
|
||||
"base64-js": "1.5.1"
|
||||
}
|
||||
},
|
||||
"@fluencelabs/fluence-network-environment": {
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmjs.org/@fluencelabs/fluence-network-environment/-/fluence-network-environment-1.0.10.tgz",
|
||||
"integrity": "sha512-aaWZDDFIIasSTgdFdw1KEz+boZMSn7pXffUENZNLX4DrP11rC3AEX4c8GnIJQbWqGsouOFZOPna2DSG6o2rLNQ==",
|
||||
"dev": true
|
||||
},
|
||||
"@istanbuljs/load-nyc-config": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz",
|
||||
|
@ -44,6 +44,7 @@
|
||||
"jest": "^26.6.3",
|
||||
"ts-jest": "^26.5.4",
|
||||
"typedoc": "^0.21.9",
|
||||
"typescript": "^4.0.0"
|
||||
"typescript": "^4.0.0",
|
||||
"@fluencelabs/fluence-network-environment": "1.0.10"
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import { checkConnection, doNothing, handleTimeout } from '../../internal/utils'
|
||||
import { Particle } from '../../internal/Particle';
|
||||
import { registerHandlersHelper } from '../util';
|
||||
|
||||
import { krasnodar } from "@fluencelabs/fluence-network-environment";
|
||||
|
||||
const anotherPeer = new FluencePeer();
|
||||
|
||||
describe('Typescript usage suite', () => {
|
||||
@ -458,6 +460,295 @@ describe('Typescript usage suite', () => {
|
||||
'Particle is expected to be sent to only the single peer (relay which client is connected to)',
|
||||
);
|
||||
});
|
||||
|
||||
it('Fold: return variable in callback', async () => {
|
||||
// arrange
|
||||
const peer = new FluencePeer();
|
||||
await peer.start({ connectTo: krasnodar[0] });
|
||||
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
const script = `
|
||||
(seq
|
||||
(seq
|
||||
(seq
|
||||
(call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-)
|
||||
(call %init_peer_id% ("getDataSrv" "outer") [] outer)
|
||||
)
|
||||
(call -relay- ("op" "noop") [])
|
||||
)
|
||||
(seq
|
||||
(call -relay- ("kad" "neighborhood") [-relay-] neighbors)
|
||||
(fold neighbors n
|
||||
(par
|
||||
(seq
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(call n ("kad" "neighborhood") [n [] []] neighbors2)
|
||||
)
|
||||
(par
|
||||
(seq
|
||||
(call -relay- ("op" "noop") [])
|
||||
(call %init_peer_id% ("op" "return") [neighbors2])
|
||||
)
|
||||
(null)
|
||||
)
|
||||
)
|
||||
(next n)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
`;
|
||||
const particle = Particle.createNew(script);
|
||||
|
||||
let outer = ["1", "2", "3", "4", "5"];
|
||||
let returns = 0;
|
||||
registerHandlersHelper(peer, particle, {
|
||||
getDataSrv: {
|
||||
"-relay-": _ => {
|
||||
return peer.getStatus().relayPeerId;
|
||||
},
|
||||
"outer": _ => {
|
||||
return outer;
|
||||
}
|
||||
},
|
||||
op: {
|
||||
return: (args) => {
|
||||
console.log("got op return: ", JSON.stringify(args));
|
||||
returns += 1;
|
||||
// if (returns == 5) {
|
||||
// resolve(undefined);
|
||||
// }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
peer.internals.initiateParticle(particle, handleTimeout(reject));
|
||||
});
|
||||
|
||||
await promise;
|
||||
|
||||
await peer.stop();
|
||||
});
|
||||
|
||||
it('Fold: incompatible results bug', async () => {
|
||||
// arrange
|
||||
const peer = new FluencePeer();
|
||||
await peer.start({ connectTo: krasnodar[0] });
|
||||
|
||||
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", "2", "3", "4", "5"];
|
||||
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);
|
||||
// }
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
peer.internals.initiateParticle(particle, handleTimeout(reject));
|
||||
});
|
||||
|
||||
await promise;
|
||||
|
||||
await peer.stop();
|
||||
});
|
||||
|
||||
it('Fold: dashboard', async () => {
|
||||
// arrange
|
||||
const peer = new FluencePeer();
|
||||
await peer.start({ connectTo: krasnodar[0] });
|
||||
|
||||
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)
|
||||
)
|
||||
)
|
||||
(null)
|
||||
)
|
||||
(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", "2", "3", "4", "5"];
|
||||
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": {
|
||||
"collectPeerInfo": _ => { console.log("collectPeerInfo") },
|
||||
"logNeighs": args => { console.log("logNeighs", JSON.stringify(args)) }
|
||||
},
|
||||
"errorHandlingSrv": { "error": args => { console.log("errorHandlingSrv", JSON.stringify(args)) } }
|
||||
});
|
||||
|
||||
peer.internals.initiateParticle(particle, handleTimeout(reject));
|
||||
});
|
||||
|
||||
await promise;
|
||||
|
||||
await peer.stop();
|
||||
});
|
||||
});
|
||||
|
||||
async function callIncorrectService(peer: FluencePeer): Promise<string[]> {
|
||||
|
Loading…
Reference in New Issue
Block a user