From b95b25fd94a0b1ab26c40880609b2dd3a6bcf85d Mon Sep 17 00:00:00 2001 From: Mark Nadal Date: Sun, 24 Jan 2016 08:13:21 -0800 Subject: [PATCH] don't be invalid! --- gun.js | 4 ++-- test/common.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/gun.js b/gun.js index 6dafea69..9850cde8 100644 --- a/gun.js +++ b/gun.js @@ -349,7 +349,7 @@ if(!(meta = (node||{})[Gun._.meta]) || !(meta = meta[Gun._.state]) || !Gun.num.is(meta[field])){ return ctx.err = {err: Gun.log("No state on '" + field + "'!") } } - }) || ctx.err){ return ctx.err = ctx.err || {err: Gun.log("Invalid graph!")}, ctx } + }) || ctx.err){ return ctx.err = ctx.err || {err: Gun.log("Invalid graph!", prime)}, ctx } function emit(at){ Gun.on('operating').emit(gun, at); } @@ -714,7 +714,7 @@ at.soul = opt.key.soul; gun.__.by(opt.key.soul).node = Gun.union.ify(gun, opt.key.soul); // TODO: Check performance? gun.__.by(opt.key.soul).node._['key'] = 'pseudo'; - at.change = Gun.is.node.soul.ify(at.change || gun.__.by(at.soul).node, at.soul, true); + at.change = Gun.is.node.soul.ify(Gun.obj.copy(at.change || gun.__.by(at.soul).node), at.soul, true); // TODO: Check performance? return; } var node = at.change || gun.__.graph[at.soul]; diff --git a/test/common.js b/test/common.js index 1888e582..910e7089 100644 --- a/test/common.js +++ b/test/common.js @@ -3486,6 +3486,21 @@ describe('Gun', function(){ done(); }) }); + + it("no invalid graph", function(done){ + var gun = Gun({wire:{ + put: function(graph){ + expect(Gun.is.graph(graph)).to.be.ok(); + if(done.c){ return } if(done.on){ done(); done.c = 1 } + } + }}).get('example/todo/data/graph'); + gun.on(function renderToDo(val){ + done.on = true; + }); + setTimeout(function(){ + gun.path(Gun.text.random()).put('hoorah'); + },100) + }); }); describe('Streams', function(){