Merge pull request #201 from ssb-ngi-pointer/test-against-190
Add a test where clients are disconnected forcefully
This commit is contained in:
commit
ae1fd47ad9
File diff suppressed because it is too large
Load Diff
|
@ -18,7 +18,7 @@
|
|||
"ssb-keys": "^8.1.0",
|
||||
"ssb-replicate": "^1.3.2",
|
||||
"ssb-room": "^1.3.0",
|
||||
"ssb-room-client": "^0.10.0",
|
||||
"ssb-room-client": "^0.13.0",
|
||||
"tap-spec": "^5.0.0",
|
||||
"tape": "^5.2.2"
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ module.exports = (t, client, roomrpc, exit) => {
|
|||
roomrpc.tunnel.endpoints(),
|
||||
pull.drain(el => {
|
||||
comment(`from roomsrv: ${JSON.stringify(el)}`)
|
||||
}, (err) => {
|
||||
t.comment('endpoints closed', err)
|
||||
})
|
||||
)
|
||||
|
||||
|
|
|
@ -19,10 +19,10 @@ module.exports = (t, sbot, rpc, exit) => {
|
|||
t.error(err, 'tunnel.leave')
|
||||
comment(`tunnel error: ${err}`)
|
||||
comment(`leave value: ${ret}`)
|
||||
comment('left, exiting in 1s')
|
||||
setTimeout(exit, 1000)
|
||||
comment('left, exiting in 3s')
|
||||
setTimeout(exit, 3000)
|
||||
})
|
||||
}, 3000)
|
||||
}, 1000)
|
||||
})
|
||||
|
||||
// announce ourselves to the room/tunnel
|
||||
|
@ -38,6 +38,8 @@ module.exports = (t, sbot, rpc, exit) => {
|
|||
rpc.tunnel.endpoints(),
|
||||
pull.drain(el => {
|
||||
comment(`from roomsrv: ${el}`)
|
||||
}, (err) => {
|
||||
t.comment('endpoints closed', err)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
|
|
@ -133,6 +133,45 @@ func TestModernJSClient(t *testing.T) {
|
|||
ts.wait()
|
||||
}
|
||||
|
||||
// found a nasty `throw err` in the JS stack around pull.drain. lets make sure it stays gone
|
||||
// https://github.com/ssb-ngi-pointer/go-ssb-room/issues/190
|
||||
func TestClientSurvivesShutdown(t *testing.T) {
|
||||
r := require.New(t)
|
||||
|
||||
ts := newRandomSession(t)
|
||||
|
||||
var membersDB = &mockdb.FakeMembersService{}
|
||||
var aliasesDB = &mockdb.FakeAliasesService{}
|
||||
srv := ts.startGoServer(membersDB, aliasesDB)
|
||||
membersDB.GetByFeedReturns(roomdb.Member{ID: 1234}, nil)
|
||||
|
||||
alice := ts.startJSClient("alice", "./testscripts/modern_client.js",
|
||||
srv.Network.GetListenAddr(),
|
||||
srv.Whoami(),
|
||||
)
|
||||
// write the handle to the testrun folder of the bot
|
||||
handleFile := filepath.Join("testrun", t.Name(), "bob", "endpoint_through_room.txt")
|
||||
r.NoError(writeRoomHandleFile(srv.Whoami(), alice, handleFile))
|
||||
|
||||
ts.startJSClient("bob", "./testscripts/modern_client_opening_tunnel.js",
|
||||
srv.Network.GetListenAddr(),
|
||||
srv.Whoami(),
|
||||
)
|
||||
|
||||
// give them time to connect (which would make them pass the test)
|
||||
time.Sleep(8 * time.Second)
|
||||
|
||||
// shut down server (which closes all the muxrpc streams)
|
||||
srv.Close()
|
||||
|
||||
// give the node processes a moment to process what just happend (don't kill them immediatl in wait())
|
||||
// in the buggy case they will crash and exit with error code 1
|
||||
// the error is visible when running the tests with `go test -v`
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
ts.wait()
|
||||
}
|
||||
|
||||
func writeRoomHandleFile(srv, target refs.FeedRef, filePath string) error {
|
||||
var roomHandle bytes.Buffer
|
||||
roomHandle.WriteString("tunnel:")
|
||||
|
|
Loading…
Reference in New Issue