dat-node icon indicating copy to clipboard operation
dat-node copied to clipboard

Implement DatPeers API

Open RangerMauve opened this issue 7 years ago • 15 comments

Closes #3

It's kinda rough, but I based it on the implementation in beaker-core and added an easy interface for it.

I've tested it out with this page and it all seems to be working.

RangerMauve avatar Sep 01 '18 21:09 RangerMauve

Looks good, would you mind adding some automated tests for it? Beaker has some you can use as a reference.

pfrazee avatar Sep 02 '18 22:09 pfrazee

Awesome! I'll try to get on that this week. :D

RangerMauve avatar Sep 04 '18 13:09 RangerMauve

I see the archives.test.js file is empty. Should I use ava for the tests since that's what beaker is using?

RangerMauve avatar Sep 04 '18 16:09 RangerMauve

😅 oh right, I forgot that I haven't gotten any tests into this thing either. What a hypocrite!

Yeah would you mind? ava is what I'd want to use.

pfrazee avatar Sep 04 '18 17:09 pfrazee

Yeah, no prob! I'll just copy the tests from beaker verbatim and convert it to use the dat-node APIs instead of electron/beaker.

RangerMauve avatar Sep 04 '18 17:09 RangerMauve

I've copied over the tests, but something weird is happening. Would you mind looking to see if I have some glaring mistake I'm missing?

When it uses getSessionData() on the first datPeers instance, it reports "right" even though I invoke setSessionData("left") earlier.

It's like the session data is being transferred between the peers, I'm not sure how that can be happening though.

RangerMauve avatar Sep 04 '18 18:09 RangerMauve

Sure I'll check into it. Thanks for putting the tests together!

pfrazee avatar Sep 04 '18 18:09 pfrazee

No rush! I'll take another shot at it later this week. :D

RangerMauve avatar Sep 04 '18 18:09 RangerMauve

I did some debugging and found at least one case of arguments being in the wrong order, https://github.com/beakerbrowser/dat-node/pull/6/files#diff-e658a4aa904bdaccea0046252d2e13d3R83

That didn't solve the issues but I'd look for things like that

pfrazee avatar Sep 07 '18 18:09 pfrazee

K, looking into it a bit today. So far it seems that broadcast just isn't working. Not sure if it's a sending issue, a receiving issue, or me not relaying events properly.

RangerMauve avatar Sep 07 '18 21:09 RangerMauve

So, this is weird. I think it's a timing issue in the tests. When I use dat-node in a REPL, it seems to work fine. But when it runs in the tests, the sessionData isn't being set. :S

RangerMauve avatar Sep 07 '18 21:09 RangerMauve

K, so the first problem was that I was creating a single instance of datEphemeralExtMsg / datSessionDataExtMsg that was shared between both dat-node instances. 🤦‍♂️

Now I can get/set session data properly, but the broadcasting still isn't working. That part might be a timing issue. Gonna look into it more another day.

RangerMauve avatar Sep 07 '18 21:09 RangerMauve

I'm at a bit of a loss here.

When I test it out with the browser it seems to be working OK, but I'm not able to get two instances of dat node in the tests to work.

Any help would be very much appreciated.

RangerMauve avatar Sep 16 '18 19:09 RangerMauve

@RangerMauve sure thing. Just push up your latest code and I'll dig around a bit.

pfrazee avatar Sep 17 '18 17:09 pfrazee

It's pushed. 😁

RangerMauve avatar Sep 17 '18 17:09 RangerMauve