RangerMauve / dat-gateway

Visit https://github.com/garbados/dat-gateway/ instead
19 stars 4 forks source link

added websocket peers test #2

Closed chrisekelley closed 6 years ago

chrisekelley commented 6 years ago

I added axios to the devDependencies to make it a tad easier to test w/ promises. The new code now waits for the request for the download to complete before opening the socket.

RangerMauve commented 6 years ago

Awesome! Last little nit pick and I think it'll be good to go. :D

RangerMauve commented 6 years ago

Wait, crap I was wrong! The socket needs to be wrapped in a promise. :( Sorry!

Something like

socket = etc..

return new Promise((resolve, reject) => {
  socket.once('data' (etc) => {
    try {
      assert(whatever)
    } catch(e) {
     reject(e)
    }
    resolve()
  })
})
chrisekelley commented 6 years ago

I added delay after all as well as the promise. These tests are so inconsistent - sometimes they work, sometimes not. Feels like the moon is in full effect... But anyway, this time they did work:

  dat-gateway
    ✓ should exist
    ✓ should handle requests (3187ms)
    ✓ should handle requests for dead addresses (3036ms)
    ✓ should proactively deleted expired archives (12007ms)
    ✓ should handle websockets for replication (3011ms)
    ✓ should open a websocket to /peers (5303ms)

  6 passing (40s)
RangerMauve commented 6 years ago

Would you be up for becoming a collaborator on this repo so you could merge stuff yourself?

chrisekelley commented 6 years ago

Sure, yeah, that would be great!

RangerMauve commented 6 years ago

Cool! I sent you an invite. It should be sent to your github email.