*Remove peer1 connection listener after broadcast
This commit is contained in:
parent
ce1854de83
commit
fcfdd51908
7
test.js
7
test.js
|
@ -34,13 +34,12 @@ test('Broadcast through several peers', (t) => {
|
||||||
|
|
||||||
function maybeFlood() {
|
function maybeFlood() {
|
||||||
if (peer1.peers.size === 2) {
|
if (peer1.peers.size === 2) {
|
||||||
flood1.broadcast(data)
|
flood1.broadcast(data);
|
||||||
|
peer1.removeListener("connection", maybeFlood);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
peer1.on('connection', () => {
|
peer1.on("connection", maybeFlood);
|
||||||
maybeFlood()
|
|
||||||
})
|
|
||||||
|
|
||||||
t.teardown(() => {
|
t.teardown(() => {
|
||||||
[peer1, peer2, peer3].forEach((item) => item.destroy())
|
[peer1, peer2, peer3].forEach((item) => item.destroy())
|
||||||
|
|
Loading…
Reference in New Issue