|
|
@ -207,7 +207,7 @@ describe('SwarmPolling', () => {
|
|
|
|
await swarmPolling.start(true);
|
|
|
|
await swarmPolling.start(true);
|
|
|
|
|
|
|
|
|
|
|
|
expect(pollOnceForKeySpy.callCount).to.eq(1);
|
|
|
|
expect(pollOnceForKeySpy.callCount).to.eq(1);
|
|
|
|
expect(pollOnceForKeySpy.firstCall.args).to.deep.eq([ourPubkey, false, [0, 2, 3, 5, 4]]);
|
|
|
|
expect(pollOnceForKeySpy.firstCall.args).to.deep.eq([ourPubkey, false, [0]]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('does run for our pubkey even if activeAt is recent ', async () => {
|
|
|
|
it('does run for our pubkey even if activeAt is recent ', async () => {
|
|
|
@ -219,7 +219,7 @@ describe('SwarmPolling', () => {
|
|
|
|
await swarmPolling.start(true);
|
|
|
|
await swarmPolling.start(true);
|
|
|
|
|
|
|
|
|
|
|
|
expect(pollOnceForKeySpy.callCount).to.eq(1);
|
|
|
|
expect(pollOnceForKeySpy.callCount).to.eq(1);
|
|
|
|
expect(pollOnceForKeySpy.firstCall.args).to.deep.eq([ourPubkey, false, [0, 2, 3, 5, 4]]);
|
|
|
|
expect(pollOnceForKeySpy.firstCall.args).to.deep.eq([ourPubkey, false, [0]]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('legacy group', () => {
|
|
|
|
describe('legacy group', () => {
|
|
|
@ -236,7 +236,7 @@ describe('SwarmPolling', () => {
|
|
|
|
|
|
|
|
|
|
|
|
// our pubkey will be polled for, hence the 2
|
|
|
|
// our pubkey will be polled for, hence the 2
|
|
|
|
expect(pollOnceForKeySpy.callCount).to.eq(2);
|
|
|
|
expect(pollOnceForKeySpy.callCount).to.eq(2);
|
|
|
|
expect(pollOnceForKeySpy.firstCall.args).to.deep.eq([ourPubkey, false, [0, 2, 3, 5, 4]]);
|
|
|
|
expect(pollOnceForKeySpy.firstCall.args).to.deep.eq([ourPubkey, false, [0]]);
|
|
|
|
expect(pollOnceForKeySpy.secondCall.args).to.deep.eq([groupConvoPubkey, true, [-10]]);
|
|
|
|
expect(pollOnceForKeySpy.secondCall.args).to.deep.eq([groupConvoPubkey, true, [-10]]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -262,7 +262,7 @@ describe('SwarmPolling', () => {
|
|
|
|
|
|
|
|
|
|
|
|
// our pubkey will be polled for, hence the 2
|
|
|
|
// our pubkey will be polled for, hence the 2
|
|
|
|
expect(pollOnceForKeySpy.callCount).to.eq(2);
|
|
|
|
expect(pollOnceForKeySpy.callCount).to.eq(2);
|
|
|
|
expect(pollOnceForKeySpy.firstCall.args).to.deep.eq([ourPubkey, false, [0, 2, 3, 5, 4]]);
|
|
|
|
expect(pollOnceForKeySpy.firstCall.args).to.deep.eq([ourPubkey, false, [0]]);
|
|
|
|
expect(pollOnceForKeySpy.secondCall.args).to.deep.eq([groupConvoPubkey, true, [-10]]);
|
|
|
|
expect(pollOnceForKeySpy.secondCall.args).to.deep.eq([groupConvoPubkey, true, [-10]]);
|
|
|
|
getItemByIdStub.restore();
|
|
|
|
getItemByIdStub.restore();
|
|
|
|
getItemByIdStub = TestUtils.stubData('getItemById');
|
|
|
|
getItemByIdStub = TestUtils.stubData('getItemById');
|
|
|
@ -288,9 +288,9 @@ describe('SwarmPolling', () => {
|
|
|
|
await swarmPolling.pollForAllKeys();
|
|
|
|
await swarmPolling.pollForAllKeys();
|
|
|
|
|
|
|
|
|
|
|
|
expect(pollOnceForKeySpy.callCount).to.eq(3);
|
|
|
|
expect(pollOnceForKeySpy.callCount).to.eq(3);
|
|
|
|
expect(pollOnceForKeySpy.firstCall.args).to.deep.eq([ourPubkey, false, [0, 2, 3, 5, 4]]);
|
|
|
|
expect(pollOnceForKeySpy.firstCall.args).to.deep.eq([ourPubkey, false, [0]]);
|
|
|
|
expect(pollOnceForKeySpy.secondCall.args).to.deep.eq([groupConvoPubkey, true, [-10]]);
|
|
|
|
expect(pollOnceForKeySpy.secondCall.args).to.deep.eq([groupConvoPubkey, true, [-10]]);
|
|
|
|
expect(pollOnceForKeySpy.thirdCall.args).to.deep.eq([ourPubkey, false, [0, 2, 3, 5, 4]]);
|
|
|
|
expect(pollOnceForKeySpy.thirdCall.args).to.deep.eq([ourPubkey, false, [0]]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('does run twice if activeAt less than one hour ', async () => {
|
|
|
|
it('does run twice if activeAt less than one hour ', async () => {
|
|
|
@ -307,7 +307,7 @@ describe('SwarmPolling', () => {
|
|
|
|
swarmPolling.addGroupId(groupConvoPubkey);
|
|
|
|
swarmPolling.addGroupId(groupConvoPubkey);
|
|
|
|
await swarmPolling.start(true);
|
|
|
|
await swarmPolling.start(true);
|
|
|
|
expect(pollOnceForKeySpy.callCount).to.eq(2);
|
|
|
|
expect(pollOnceForKeySpy.callCount).to.eq(2);
|
|
|
|
expect(pollOnceForKeySpy.firstCall.args).to.deep.eq([ourPubkey, false, [0, 2, 3, 5, 4]]);
|
|
|
|
expect(pollOnceForKeySpy.firstCall.args).to.deep.eq([ourPubkey, false, [0]]);
|
|
|
|
expect(pollOnceForKeySpy.secondCall.args).to.deep.eq([groupConvoPubkey, true, [-10]]);
|
|
|
|
expect(pollOnceForKeySpy.secondCall.args).to.deep.eq([groupConvoPubkey, true, [-10]]);
|
|
|
|
pollOnceForKeySpy.resetHistory();
|
|
|
|
pollOnceForKeySpy.resetHistory();
|
|
|
|
clock.tick(9000);
|
|
|
|
clock.tick(9000);
|
|
|
@ -322,7 +322,7 @@ describe('SwarmPolling', () => {
|
|
|
|
await sleepFor(10);
|
|
|
|
await sleepFor(10);
|
|
|
|
|
|
|
|
|
|
|
|
expect(pollOnceForKeySpy.callCount).to.eq(2);
|
|
|
|
expect(pollOnceForKeySpy.callCount).to.eq(2);
|
|
|
|
expect(pollOnceForKeySpy.firstCall.args).to.deep.eq([ourPubkey, false, [0, 2, 3, 5, 4]]);
|
|
|
|
expect(pollOnceForKeySpy.firstCall.args).to.deep.eq([ourPubkey, false, [0]]);
|
|
|
|
expect(pollOnceForKeySpy.secondCall.args).to.deep.eq([groupConvoPubkey, true, [-10]]);
|
|
|
|
expect(pollOnceForKeySpy.secondCall.args).to.deep.eq([groupConvoPubkey, true, [-10]]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -352,9 +352,9 @@ describe('SwarmPolling', () => {
|
|
|
|
await sleepFor(10);
|
|
|
|
await sleepFor(10);
|
|
|
|
// we should have two more calls here, so 4 total.
|
|
|
|
// we should have two more calls here, so 4 total.
|
|
|
|
expect(pollOnceForKeySpy.callCount).to.eq(4);
|
|
|
|
expect(pollOnceForKeySpy.callCount).to.eq(4);
|
|
|
|
expect(pollOnceForKeySpy.firstCall.args).to.deep.eq([ourPubkey, false, [0, 2, 3, 5, 4]]);
|
|
|
|
expect(pollOnceForKeySpy.firstCall.args).to.deep.eq([ourPubkey, false, [0]]);
|
|
|
|
expect(pollOnceForKeySpy.secondCall.args).to.deep.eq([groupConvoPubkey, true, [-10]]);
|
|
|
|
expect(pollOnceForKeySpy.secondCall.args).to.deep.eq([groupConvoPubkey, true, [-10]]);
|
|
|
|
expect(pollOnceForKeySpy.thirdCall.args).to.deep.eq([ourPubkey, false, [0, 2, 3, 5, 4]]);
|
|
|
|
expect(pollOnceForKeySpy.thirdCall.args).to.deep.eq([ourPubkey, false, [0]]);
|
|
|
|
expect(pollOnceForKeySpy.getCalls()[3].args).to.deep.eq([groupConvoPubkey, true, [-10]]);
|
|
|
|
expect(pollOnceForKeySpy.getCalls()[3].args).to.deep.eq([groupConvoPubkey, true, [-10]]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -379,7 +379,7 @@ describe('SwarmPolling', () => {
|
|
|
|
// we should have only one more call here, the one for our direct pubkey fetch
|
|
|
|
// we should have only one more call here, the one for our direct pubkey fetch
|
|
|
|
expect(pollOnceForKeySpy.callCount).to.eq(3);
|
|
|
|
expect(pollOnceForKeySpy.callCount).to.eq(3);
|
|
|
|
expect(pollOnceForKeySpy.secondCall.args).to.deep.eq([groupConvoPubkey, true, [-10]]); // this one comes from the swarmPolling.start
|
|
|
|
expect(pollOnceForKeySpy.secondCall.args).to.deep.eq([groupConvoPubkey, true, [-10]]); // this one comes from the swarmPolling.start
|
|
|
|
expect(pollOnceForKeySpy.thirdCall.args).to.deep.eq([ourPubkey, false, [0, 2, 3, 5, 4]]);
|
|
|
|
expect(pollOnceForKeySpy.thirdCall.args).to.deep.eq([ourPubkey, false, [0]]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('multiple runs', () => {
|
|
|
|
describe('multiple runs', () => {
|
|
|
@ -421,10 +421,10 @@ describe('SwarmPolling', () => {
|
|
|
|
// we have 4 calls total. 2 for our direct promises run each 5 seconds, and 2 for the group pubkey active (so run every 5 sec too)
|
|
|
|
// we have 4 calls total. 2 for our direct promises run each 5 seconds, and 2 for the group pubkey active (so run every 5 sec too)
|
|
|
|
expect(pollOnceForKeySpy.callCount).to.eq(4);
|
|
|
|
expect(pollOnceForKeySpy.callCount).to.eq(4);
|
|
|
|
// first two calls are our pubkey
|
|
|
|
// first two calls are our pubkey
|
|
|
|
expect(pollOnceForKeySpy.firstCall.args).to.deep.eq([ourPubkey, false, [0, 2, 3, 5, 4]]);
|
|
|
|
expect(pollOnceForKeySpy.firstCall.args).to.deep.eq([ourPubkey, false, [0]]);
|
|
|
|
expect(pollOnceForKeySpy.secondCall.args).to.deep.eq([groupConvoPubkey, true, [-10]]);
|
|
|
|
expect(pollOnceForKeySpy.secondCall.args).to.deep.eq([groupConvoPubkey, true, [-10]]);
|
|
|
|
|
|
|
|
|
|
|
|
expect(pollOnceForKeySpy.thirdCall.args).to.deep.eq([ourPubkey, false, [0, 2, 3, 5, 4]]);
|
|
|
|
expect(pollOnceForKeySpy.thirdCall.args).to.deep.eq([ourPubkey, false, [0]]);
|
|
|
|
expect(pollOnceForKeySpy.getCalls()[3].args).to.deep.eq([groupConvoPubkey, true, [-10]]);
|
|
|
|
expect(pollOnceForKeySpy.getCalls()[3].args).to.deep.eq([groupConvoPubkey, true, [-10]]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -445,9 +445,9 @@ describe('SwarmPolling', () => {
|
|
|
|
expect(pollOnceForKeySpy.callCount).to.eq(4);
|
|
|
|
expect(pollOnceForKeySpy.callCount).to.eq(4);
|
|
|
|
|
|
|
|
|
|
|
|
// first two calls are our pubkey
|
|
|
|
// first two calls are our pubkey
|
|
|
|
expect(pollOnceForKeySpy.firstCall.args).to.deep.eq([ourPubkey, false, [0, 2, 3, 5, 4]]);
|
|
|
|
expect(pollOnceForKeySpy.firstCall.args).to.deep.eq([ourPubkey, false, [0]]);
|
|
|
|
expect(pollOnceForKeySpy.secondCall.args).to.deep.eq([groupConvoPubkey, true, [-10]]);
|
|
|
|
expect(pollOnceForKeySpy.secondCall.args).to.deep.eq([groupConvoPubkey, true, [-10]]);
|
|
|
|
expect(pollOnceForKeySpy.thirdCall.args).to.deep.eq([ourPubkey, false, [0, 2, 3, 5, 4]]);
|
|
|
|
expect(pollOnceForKeySpy.thirdCall.args).to.deep.eq([ourPubkey, false, [0]]);
|
|
|
|
expect(pollOnceForKeySpy.getCalls()[3].args).to.deep.eq([groupConvoPubkey, true, [-10]]);
|
|
|
|
expect(pollOnceForKeySpy.getCalls()[3].args).to.deep.eq([groupConvoPubkey, true, [-10]]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|