amark / gun

An open source cybersecurity protocol for syncing decentralized graph data.
https://gun.eco/docs
Other
18.03k stars 1.16k forks source link

a few more tests for book #1275

Open nsreed opened 2 years ago

nsreed commented 2 years ago

A few new tests and a little more test tooling for book.

A few failures that are interesting:

I believe these bugs encompass most of the failures in the tests, and I've tried to add FIXMEs in the tests that most effectively illustrate them. Some of the TODOs are for me. Again, I plan on cleaning this file up at some point but the test failures aren't doing much good sitting on my machine and I'm not 100% sure when I'll be able to get back to it.

amark commented 2 years ago

I saw this with @Prometheus also, so can confirm the first 2 also. I don't understand the 3rd thing tho?

Note to others: Book + the RAD updates are being coded on a "rebuild the plane while flying" path. We're first testing whether parts "fit" together, even when we know they don't work. If the scaffold fits, it does nothing / behaves incorrectly at first, but then we filling in the engine. Its like replacing a black box system.

nsreed commented 2 years ago

An approximate summary of the third issue:

rad('a', 'a');
rad('b', 'b'); // NOTE: I am waiting for each write callback before proceeding, this is just more brief
rad('a', cb); // retrieves 'a' correctly
rad('b', cb); // retrieves undefined

If I use a new rad for the reads, the values are retrieved correctly.

rad('a', 'a');
rad('b', 'b');
rad = Radisk(opt);
rad('a', cb); // retrieves 'a' correctly
rad('b', cb); // retrieves 'b' correctly

Or, if the values are large enough to split into their own file, they are both retrieved correctly.

rad('a', ''.padEnd(1000000, 'a'));
rad('b', ''.padEnd(1000000, 'b'));
rad('a', cb); // retrieves 'aaaaaa....' correctly
rad('b', cb); // retrieves 'bbbbb....' correctly

So it seems like the in-memory data vs. the on-disk data have some disagreements, but surprisingly to me the on-disk data is more correct.

amark commented 2 years ago

oof.

nsreed commented 2 years ago

Not sure if it matters, but might be important:

rad('a', 'a');
rad = Radisk(opt); // create a new RAD instance for second write
rad('b', 'b');
rad('a', cb); // retrieves 'a' correctly
rad('b', cb); // retrieves undefined

Thought I might be able to get the second write to work by re-reading what's on disk, but no.

amark commented 1 year ago

I'm back from a bunch of conferences... let's resume / catch up. DM me on twitter some times to do a screen call.