in-process message passing needs to clean itself of flags for now

This commit is contained in:
Mark Nadal 2021-01-24 02:50:35 -08:00
parent 77e310bacc
commit c6e230d1d2
2 changed files with 14 additions and 9 deletions

View File

@ -2,6 +2,8 @@
## 0.2020.x
`>0.2020.520` may break in-process `gun1` `gun2` message passing. Check `test/common.js` "Check multi instance message passing" for a hint and/or complain on community chat.
- No breaking changes to core API.
- Storage adapter `put` event breaking change (temporary?), RAD is official now and storage adapters should be RAD plugins instead of GUN adapters.
- GUN soul format changed from being a random UUID to being a more predictable graph path (of where initially created) to support even better offline behavior. This means `null`ing & replacing an object will not create a new but re-merge.

View File

@ -3252,7 +3252,7 @@ describe('Gun', function(){
},10);
});
it.only('multiple times partial', function(done){
it('multiple times partial', function(done){
Gun.statedisk({ alias: { mark: { pub: {_:{'#':'PUB'}, pub: 'asdf', alias: 'mark', born: 1 } } } }, 'mult/times/part', function(){
var gun = Gun();
var app = gun.get('mult/times/part');
@ -3335,11 +3335,11 @@ describe('Gun', function(){
var list = app.get('list');
var check = {};
gun.get('user').get('alice').put({name:'Alice', email:'alice@example.com'})
gun.get('user').get('bob').put({name:'Bob', email:'bob@example.com'})
gun.get('user').get('carl').put({name:'Carl', email:'carl@example.com'})
gun.get('useromo').get('alice').put({name:'Alice', email:'alice@example.com'})
gun.get('useromo').get('bob').put({name:'Bob', email:'bob@example.com'})
gun.get('useromo').get('carl').put({name:'Carl', email:'carl@example.com'})
gun.get('user').once().map(v => {
gun.get('useromo').once().map(v => {
//console.log('this gets called', v);
return v
}).once((v, k) => {
@ -3403,22 +3403,25 @@ describe('Gun', function(){
list.get('message').put('hello world'); // outputs "message: hello world"
list.get('message').put(null); // throws Uncaught TypeError: Cannot read property '#' of null
});
return;
it('Check multi instance message passing', function(done){
it.only('Check multi instance message passing', function(done){
// NOTICE: The behavior of this test changed from v0.2020.520 to version after.
try{ require('fs').unlinkSync('bdata') }catch(e){}
try{ require('fs').unlinkSync('ddata') }catch(e){}
Gun.on('opt', function(ctx){
ctx.on('out', function(msg){
this.to.next(msg);
var onGun = ctx;
var tmp = {}; Object.keys(msg).forEach(function(k){ tmp[k] = msg[k] }); delete tmp.out; delete tmp._; msg = tmp; // copy message.
if(onGun.$ === b) {
if(d){
//console.log("b can send to d....", Gun.obj.copy(msg));
//console.log("b can send to d....", JSON.parse(JSON.stringify(msg)));
msg.$ = d;
d.on("in", msg);
}
} else if(onGun.$ === d){
//console.log("d sends to b....", Gun.obj.copy(msg));
//console.log("d sends to b....", JSON.parse(JSON.stringify(msg)));
msg.$ = b;
b.on("in", msg);
}
});