Panic tests for rod & radix.js try / catch (#1269)

* try/catch radix.js

* rod test/panic/chat.js

rod test/panic/holy-grail.js

rod panic tests
This commit is contained in:
Martti Malmi 2022-08-13 21:58:00 +03:00 committed by GitHub
parent d5c8a02980
commit 7123207c66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 253 additions and 50 deletions

View File

@ -62,7 +62,9 @@
return radix;
};
Radix.map = function rap(radix, cb, opt, pre){ pre = pre || []; // TODO: BUG: most out-of-memory crashes come from here.
Radix.map = function rap(radix, cb, opt, pre){
try {
pre = pre || []; // TODO: BUG: most out-of-memory crashes come from here.
var t = ('function' == typeof radix)? radix.$ || {} : radix;
//!opt && console.log("WHAT IS T?", JSON.stringify(t).length);
if(!t){ return }
@ -103,6 +105,7 @@
}
pre.pop();
}
} catch (e) { console.error(e); }
};
if(typeof window !== "undefined"){

View File

@ -85,6 +85,21 @@ describe("Put ACK", function(){
peers.push('http://'+ env.config.IP + ':' + tmp + '/gun');
}
}
if (process.env.ROD_PATH) {
// currently fails because rod doesn't ack
console.log('testing with rod');
const sp = require('child_process').spawn(process.env.ROD_PATH, ['start', '--port', port, '--sled-storage=false', '--peers', peers.join(',').replaceAll('http', 'ws')]);
sp.stdout.on('data', function(data){
console.log(data.toString());
});
sp.stderr.on('data', function(data){
console.log(data.toString());
});
test.done();
return;
}
console.log(port, " connect to ", peers);
var gun = Gun({file: env.i+'data', peers: peers, web: server, axe: false}); // Note: test with AXE on & off.
server.listen(port, function(){

View File

@ -78,6 +78,24 @@ describe("GET GET", function(){
}
}
console.log(port, " connect to ", peers);
if (process.env.ROD_PATH) {
console.log('testing with rod');
var args = ['start', '--port', port, '--sled-storage=false'];
if (peers.length) {
args.push('--peers=' + peers.join(',').replaceAll('http', 'ws'));
}
const sp = require('child_process').spawn(process.env.ROD_PATH, args);
sp.stdout.on('data', function(data){
console.log(data.toString());
});
sp.stderr.on('data', function(data){
console.log(data.toString());
});
test.done();
return;
}
var gun = Gun({file: env.i+'data', peers: peers, web: server});
server.listen(port, function(){
test.done();

View File

@ -74,6 +74,24 @@ describe("Put ACK", function(){
}
}
console.log(port, " connect to ", peers);
if (process.env.ROD_PATH) {
console.log('testing with rod');
var args = ['start', '--port', port, '--sled-storage=false'];
if (peers.length) {
args.push('--peers=' + peers.join(',').replaceAll('http', 'ws'));
}
const sp = require('child_process').spawn(process.env.ROD_PATH, args);
sp.stdout.on('data', function(data){
console.log(data.toString());
});
sp.stderr.on('data', function(data){
console.log(data.toString());
});
test.done();
return;
}
var gun = Gun({file: false, rad: false, localStorage: false, file: env.i+'data', peers: peers, web: server, axe: false});
server.listen(port, function(){
test.done();

View File

@ -86,6 +86,24 @@ describe("Dedup load balancing GETs", function(){
peers.push('http://'+ env.config.IP + ':' + tmp + '/gun');
}
}
if (process.env.ROD_PATH) {
console.log('testing with rod');
var args = ['start', '--port', port, '--sled-storage=false'];
if (peers.length) {
args.push('--peers=' + peers.join(',').replaceAll('http', 'ws'));
}
const sp = require('child_process').spawn(process.env.ROD_PATH, args);
sp.stdout.on('data', function(data){
console.log(data.toString());
});
sp.stderr.on('data', function(data){
console.log(data.toString());
});
test.done();
return;
}
var gun = Gun({peers: peers, web: server, rad: false, radisk: false, file: false, localStorage: false, axe: false});
server.listen(port, function(){
test.done();

View File

@ -59,6 +59,24 @@ describe("Do not connect to self", function(){
// make sure to connect to self/same.
peers.push(self_url);
console.log(port, " connect to ", peers);
if (process.env.ROD_PATH) {
console.log('testing with rod');
var args = ['start', '--port', port, '--sled-storage=false'];
if (peers.length) {
args.push('--peers=' + peers.join(',').replaceAll('http', 'ws'));
}
const sp = require('child_process').spawn(process.env.ROD_PATH, args);
sp.stdout.on('data', function(data){
console.log(data.toString());
});
sp.stderr.on('data', function(data){
console.log(data.toString());
});
test.done();
return;
}
var gun = Gun({file: env.i+'data', peers: peers, web: server, multicast: false});
global.gun = gun;
server.listen(port, function(){

View File

@ -65,6 +65,24 @@ describe("Put ACK", function(){
}
global.peerID = String.fromCharCode(64 + env.i);
console.log(env.i, port, " connect to ", peers);
if (process.env.ROD_PATH) {
console.log('testing with rod');
var args = ['start', '--port', port, '--sled-storage=false'];
if (peers.length) {
args.push('--peers=' + peers.join(',').replaceAll('http', 'ws'));
}
const sp = require('child_process').spawn(process.env.ROD_PATH, args);
sp.stdout.on('data', function(data){
console.log(data.toString());
});
sp.stderr.on('data', function(data){
console.log(data.toString());
});
test.done();
return;
}
// TODO what should gun be when testing on rod?
var gun = Gun({file: env.i+'data', pid: peerID, peers: peers, web: server});
global.gun = gun;
server.listen(port, function(){

View File

@ -78,6 +78,24 @@ describe("Dedup load balancing GETs", function(){
var tmp = (env.config.port + (i + 1));
peers.push('http://'+ env.config.IP + ':' + tmp + '/gun');
}
if (process.env.ROD_PATH) {
console.log('testing with rod');
var args = ['start', '--port', port, '--sled-storage=false'];
if (peers.length) {
args.push('--peers=' + peers.join(',').replaceAll('http', 'ws'));
}
const sp = require('child_process').spawn(process.env.ROD_PATH, args);
sp.stdout.on('data', function(data){
console.log(data.toString());
});
sp.stderr.on('data', function(data){
console.log(data.toString());
});
test.done();
return;
}
var gun = Gun({file: env.i+'data', peers: peers, web: server});
server.listen(port, function(){
test.done();

View File

@ -86,19 +86,50 @@ describe("Mob test.", function(){
relays.each(function(client){
tests.push(client.run(function(test){
var env = test.props;
test.async();
try{ require('fs').unlinkSync(env.i+'data') }catch(e){}
try{ require('gun/lib/fsrm')(env.i+'data') }catch(e){}
var server = require('http').createServer(function(req, res){
res.end("I am "+ env.i +"!");
});
var port = env.config.port + env.i;
var Gun; try{ Gun = require('gun') }catch(e){ console.log("GUN not found! You need to link GUN to PANIC. Nesting the `gun` repo inside a `node_modules` parent folder often fixes this.") }
test.async();
var peers = [], i = env.config.relays;
while(i--){ // make sure to connect to self/same.
var tmp = (env.config.port + (i + 1));
peers.push('http://'+ env.config.IP + ':' + tmp + '/gun');
}
if (process.env.ROD_PATH) {
console.log('testing with rod');
var args = ['start', '--port', port, '--sled-storage=false'];
if (peers.length) {
args.push('--peers=' + peers.join(',').replaceAll('http', 'ws'));
}
const sp = require('child_process').spawn(process.env.ROD_PATH, args);
sp.stdout.on('data', function(data){
console.log(data.toString());
});
sp.stderr.on('data', function(data){
console.log(data.toString());
});
test.done();
return;
}
try {
require('fs').unlinkSync(env.i + 'data')
} catch (e) {
}
try {
require('gun/lib/fsrm')(env.i + 'data')
} catch (e) {
}
var server = require('http').createServer(function (req, res) {
res.end("I am " + env.i + "!");
});
var Gun;
try {
Gun = require('gun')
} catch (e) {
console.log("GUN not found! You need to link GUN to PANIC. Nesting the `gun` repo inside a `node_modules` parent folder often fixes this.")
}
console.log(port, " connect to ", peers);
var gun = Gun({file: env.i+'data', peers: peers, web: server, mob: 3, multicast: false});
global.gun = gun;

View File

@ -84,6 +84,22 @@ describe("Load test "+ config.browsers +" browser(s) across "+ config.relays +"
var env = test.props;
// As a result, we have to manually pass it scope.
test.async();
if (process.env.ROD_PATH) {
try {
const sp = require('child_process').spawn(process.env.ROD_PATH, ['start', '--port', env.config.port + env.i, '--sled-storage=false']);
sp.stdout.on('data', function(data){
console.log(data.toString());
});
sp.stderr.on('data', function(data){
console.log(data.toString());
});
test.done();
} catch (e) {
console.log(e);
}
return;
}
// Clean up from previous test.
try{ require('fs').unlinkSync(env.i+'data.json') }catch(e){}
var server = require('http').createServer(function(req, res){

View File

@ -51,12 +51,26 @@ describe("The Holy Grail Test!", function(){
it("GUN started!", function(){
return relay.run(function(test){
var env = test.props;
var port = env.config.port + env.i;
test.async();
if (process.env.ROD_PATH) {
console.log('testing with rod');
const sp = require('child_process').spawn(process.env.ROD_PATH, ['start', '--port', port, '--sled-storage=false']);
sp.stdout.on('data', function(data){
console.log(data.toString());
});
sp.stderr.on('data', function(data){
console.log(data.toString());
});
test.done();
return;
}
try{ require('fs').unlinkSync(env.i+'data') }catch(e){}
try{ require('fs').unlinkSync((env.i+1)+'data') }catch(e){}
try{ require('gun/lib/fsrm')(env.i+'data') }catch(e){}
try{ require('gun/lib/fsrm')((env.i+1)+'data') }catch(e){}
var port = env.config.port + env.i;
var server = require('http').createServer(function(req, res){
res.end("I am "+ env.i +"!");
});
@ -186,10 +200,25 @@ describe("The Holy Grail Test!", function(){
it("GUN spawned!", function(){
return spawn.run(function(test){
var env = test.props;
var port = env.config.port + env.i;
test.async();
if (process.env.ROD_PATH) {
console.log('testing with rod');
const sp = require('child_process').spawn(process.env.ROD_PATH, ['start', '--port', port, '--sled-storage=false']);
sp.stdout.on('data', function(data){
console.log(data.toString());
});
sp.stderr.on('data', function(data){
console.log(data.toString());
});
test.done();
return;
}
try{ require('fs').unlinkSync(env.i+'data') }catch(e){}
try{ require('gun/lib/fsrm')(env.i+'data') }catch(e){}
var port = env.config.port + env.i;
var server = require('http').createServer(function(req, res){
res.end("I am "+ env.i +"!");
});
@ -287,3 +316,4 @@ describe("The Holy Grail Test!", function(){
});
});
});