core-3nweb-client-lib 0.50.4 → 0.50.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/core/asmail/inbox/msg-indexing/dataset/v1/sql-db.js +7 -4
- package/build/core/asmail/sending-params/params-from-others.js +4 -1
- package/build/core/keyring/peer-keys/dataset/v2/peer-keys-db.js +1 -2
- package/build/core/storage/common/obj-info-file.js +4 -1
- package/build/tests/caps-api/asmail/specs/send-without-attachments.js +58 -2
- package/build/tests/caps-api/asmail/test-utils.d.ts +2 -0
- package/build/tests/caps-api/asmail/test-utils.js +35 -0
- package/package.json +1 -1
|
@@ -169,16 +169,19 @@ async function fileTSsOfDBShards(dbsFS) {
|
|
|
169
169
|
if (!isFile || !name.endsWith(DB_EXT)) {
|
|
170
170
|
continue;
|
|
171
171
|
}
|
|
172
|
-
const numStr = name.substring(0, DB_EXT.length);
|
|
172
|
+
const numStr = name.substring(0, name.length - DB_EXT.length);
|
|
173
173
|
const fileTS = parseInt(numStr);
|
|
174
174
|
if (isNaN(fileTS)) {
|
|
175
175
|
continue;
|
|
176
176
|
}
|
|
177
177
|
fileTSs.push(fileTS);
|
|
178
178
|
}
|
|
179
|
-
fileTSs.sort();
|
|
179
|
+
fileTSs.sort(compareNumbers);
|
|
180
180
|
return fileTSs;
|
|
181
181
|
}
|
|
182
|
+
function compareNumbers(a, b) {
|
|
183
|
+
return a - b;
|
|
184
|
+
}
|
|
182
185
|
const DB_EXT = '.sqlite';
|
|
183
186
|
const LATEST_DB = `latest${DB_EXT}`;
|
|
184
187
|
const MSG_INDEX_DB_ATTR = `msg-index-db`;
|
|
@@ -267,7 +270,7 @@ async function makeSqliteDBs(dbsFS) {
|
|
|
267
270
|
}
|
|
268
271
|
async function* iterateDBsFromLatestToOldest() {
|
|
269
272
|
yield { db: latest };
|
|
270
|
-
for (let i = (fileTSs.length - 1); i >= 0; i
|
|
273
|
+
for (let i = (fileTSs.length - 1); i >= 0; i -= 1) {
|
|
271
274
|
const fileTS = fileTSs[i];
|
|
272
275
|
if (!fileTS) {
|
|
273
276
|
continue;
|
|
@@ -365,7 +368,7 @@ async function makeSqliteDBs(dbsFS) {
|
|
|
365
368
|
if (!shardTS) {
|
|
366
369
|
return;
|
|
367
370
|
}
|
|
368
|
-
for (let i = fileTSs.length; i >= 0; i
|
|
371
|
+
for (let i = fileTSs.length; i >= 0; i -= 1) {
|
|
369
372
|
const ts = fileTSs[i];
|
|
370
373
|
if (ts < shardTS) {
|
|
371
374
|
fileTSs.slice(i + 1, shardTS);
|
|
@@ -68,7 +68,10 @@ async function makeParamsFromOthers(fs, fileName) {
|
|
|
68
68
|
let paramsWhereUpdated = (numExistingRecs > numRemRecs);
|
|
69
69
|
for (const [address, inP] of Object.entries(onRemote)) {
|
|
70
70
|
const existing = params[address];
|
|
71
|
-
if (existing
|
|
71
|
+
if (!existing) {
|
|
72
|
+
params[address] = inP;
|
|
73
|
+
}
|
|
74
|
+
else if (existing.timestamp < inP.timestamp) {
|
|
72
75
|
params[address] = inP;
|
|
73
76
|
paramsWhereUpdated = true;
|
|
74
77
|
}
|
|
@@ -94,8 +94,7 @@ const queryToCreatePeerKeysDbV2 = [
|
|
|
94
94
|
msgMasterKeyAlg TEXT NOT NULL,
|
|
95
95
|
msgMasterKey BLOB NOT NULL,
|
|
96
96
|
--
|
|
97
|
-
PRIMARY KEY (peerCAddr, recipientKId, peerKId)
|
|
98
|
-
UNIQUE (peerCAddr, recipientKId) ON CONFLICT FAIL
|
|
97
|
+
PRIMARY KEY (peerCAddr, recipientKId, peerKId)
|
|
99
98
|
)
|
|
100
99
|
`,
|
|
101
100
|
`--sql
|
|
@@ -160,9 +160,12 @@ function addArchived(versions, version) {
|
|
|
160
160
|
return false;
|
|
161
161
|
}
|
|
162
162
|
versions.archived.push(version);
|
|
163
|
-
versions.archived.sort();
|
|
163
|
+
versions.archived.sort(compareNumbers);
|
|
164
164
|
return true;
|
|
165
165
|
}
|
|
166
|
+
function compareNumbers(a, b) {
|
|
167
|
+
return a - b;
|
|
168
|
+
}
|
|
166
169
|
function isEmptyVersions(versions) {
|
|
167
170
|
if (versions.current) {
|
|
168
171
|
return false;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2016 - 2018, 2020 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2016 - 2018, 2020, 2026 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -24,7 +24,7 @@ exports.specs = {
|
|
|
24
24
|
description: '.sendMsg',
|
|
25
25
|
its: []
|
|
26
26
|
};
|
|
27
|
-
|
|
27
|
+
let it = {
|
|
28
28
|
expectation: 'send message to existing address and get it'
|
|
29
29
|
};
|
|
30
30
|
it.func = async function (s) {
|
|
@@ -87,4 +87,60 @@ it.func = async function (s) {
|
|
|
87
87
|
await u2_w3n.mail.inbox.removeMsg(msgId); // second call is a noop
|
|
88
88
|
};
|
|
89
89
|
exports.specs.its.push(it);
|
|
90
|
+
it = {
|
|
91
|
+
expectation: 'send lots of messages with sendImmediately flag set true',
|
|
92
|
+
timeout: 20000
|
|
93
|
+
};
|
|
94
|
+
it.func = async function (s) {
|
|
95
|
+
const u1_w3n = s.testAppCapsByUserIndex(0);
|
|
96
|
+
const u2 = s.users[1];
|
|
97
|
+
const u2_w3n = s.testAppCapsByUserIndex(1);
|
|
98
|
+
const totalNumOfTestMsgs = 30;
|
|
99
|
+
const recipient = u2.userId;
|
|
100
|
+
const msgsFromRecipient = (0, test_utils_1.getMsgsFrom)(u2_w3n.mail.inbox, totalNumOfTestMsgs);
|
|
101
|
+
const receivedMsgs = new Array(totalNumOfTestMsgs);
|
|
102
|
+
const watchingInboxOfU2 = (async function () {
|
|
103
|
+
for await (const msg of msgsFromRecipient) {
|
|
104
|
+
const i = msg.jsonBody.testMsgNum;
|
|
105
|
+
receivedMsgs[i] = msg;
|
|
106
|
+
}
|
|
107
|
+
})();
|
|
108
|
+
const idForSendingPrefix = `${Date.now()}`;
|
|
109
|
+
const notifs = [];
|
|
110
|
+
const deliveryProcesses = [];
|
|
111
|
+
for (let i = 0; i < totalNumOfTestMsgs; i += 1) {
|
|
112
|
+
const idForSending = `${idForSendingPrefix}-${i}`;
|
|
113
|
+
const msgNotifs = [];
|
|
114
|
+
notifs.push(msgNotifs);
|
|
115
|
+
const outMsg = {
|
|
116
|
+
msgType: 'mail',
|
|
117
|
+
jsonBody: {
|
|
118
|
+
testMsgNum: i
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
await u1_w3n.mail.delivery.addMsg([recipient], outMsg, idForSending, {
|
|
122
|
+
sendImmediately: true,
|
|
123
|
+
retryRecipient: { numOfAttempts: 2, timeBetweenAttempts: 1000 }
|
|
124
|
+
});
|
|
125
|
+
const msgDeliveryProc = new Promise((resolve, reject) => {
|
|
126
|
+
u1_w3n.mail.delivery.observeDelivery(idForSending, {
|
|
127
|
+
next: p => msgNotifs.push(p),
|
|
128
|
+
complete: resolve,
|
|
129
|
+
error: reject
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
deliveryProcesses.push(msgDeliveryProc);
|
|
133
|
+
}
|
|
134
|
+
await Promise.allSettled(deliveryProcesses);
|
|
135
|
+
await watchingInboxOfU2;
|
|
136
|
+
for (let i = 0; i < totalNumOfTestMsgs; i += 1) {
|
|
137
|
+
const msgDeliveryNotifs = notifs[i];
|
|
138
|
+
expect(msgDeliveryNotifs.length).toBeGreaterThan(0);
|
|
139
|
+
const last = msgDeliveryNotifs[msgDeliveryNotifs.length - 1];
|
|
140
|
+
expect(last.allDone).withContext(`message ${i} should've been sent without errors`).toBe('all-ok');
|
|
141
|
+
const msg = receivedMsgs[i];
|
|
142
|
+
expect(msg.jsonBody.testMsgNum).withContext(`message ${i} should've been received`).toBe(i);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
exports.specs.its.push(it);
|
|
90
146
|
Object.freeze(exports);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SpecIt as GenericSpecIt } from "../../libs-for-tests/spec-module";
|
|
2
2
|
import { MultiUserSetup } from "../../libs-for-tests/setups";
|
|
3
|
+
type InboxService = web3n.asmail.InboxService;
|
|
3
4
|
type commonW3N = web3n.caps.common.W3N;
|
|
4
5
|
/**
|
|
5
6
|
* This function to be run in renderer's context via execExpects
|
|
@@ -9,4 +10,5 @@ type commonW3N = web3n.caps.common.W3N;
|
|
|
9
10
|
export declare function sendTxtMsg(w3n: commonW3N, recipient: string, txtBody: string): Promise<string>;
|
|
10
11
|
export type SpecIt = GenericSpecIt<MultiUserSetup>;
|
|
11
12
|
export declare function throwDeliveryErrorFrom(lastNotif: web3n.asmail.DeliveryProgress): void;
|
|
13
|
+
export declare function getMsgsFrom(inbox: InboxService, numOfMsgsToGet: number): AsyncGenerator<web3n.asmail.IncomingMessage, void, unknown>;
|
|
12
14
|
export {};
|
|
@@ -18,8 +18,10 @@
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.sendTxtMsg = sendTxtMsg;
|
|
20
20
|
exports.throwDeliveryErrorFrom = throwDeliveryErrorFrom;
|
|
21
|
+
exports.getMsgsFrom = getMsgsFrom;
|
|
21
22
|
const assert_1 = require("../../../lib-common/assert");
|
|
22
23
|
const error_1 = require("../../../lib-common/exceptions/error");
|
|
24
|
+
const deferred_1 = require("../../../lib-common/processes/deferred");
|
|
23
25
|
/**
|
|
24
26
|
* This function to be run in renderer's context via execExpects
|
|
25
27
|
* @param recipient
|
|
@@ -58,3 +60,36 @@ function throwDeliveryErrorFrom(lastNotif) {
|
|
|
58
60
|
}
|
|
59
61
|
}
|
|
60
62
|
}
|
|
63
|
+
async function* getMsgsFrom(inbox, numOfMsgsToGet) {
|
|
64
|
+
let msgCounter = 0;
|
|
65
|
+
let expectedMsg = (0, deferred_1.defer)();
|
|
66
|
+
const unsub = inbox.subscribe('message', {
|
|
67
|
+
next: msg => {
|
|
68
|
+
expectedMsg === null || expectedMsg === void 0 ? void 0 : expectedMsg.resolve(msg);
|
|
69
|
+
msgCounter += 1;
|
|
70
|
+
expectedMsg = ((msgCounter < numOfMsgsToGet) ? (0, deferred_1.defer)() : undefined);
|
|
71
|
+
},
|
|
72
|
+
error: err => {
|
|
73
|
+
expectedMsg === null || expectedMsg === void 0 ? void 0 : expectedMsg.reject(err);
|
|
74
|
+
expectedMsg = undefined;
|
|
75
|
+
},
|
|
76
|
+
complete: () => {
|
|
77
|
+
expectedMsg === null || expectedMsg === void 0 ? void 0 : expectedMsg.resolve(undefined);
|
|
78
|
+
expectedMsg = undefined;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
try {
|
|
82
|
+
while (expectedMsg) {
|
|
83
|
+
const msg = await (expectedMsg === null || expectedMsg === void 0 ? void 0 : expectedMsg.promise);
|
|
84
|
+
if (msg) {
|
|
85
|
+
yield msg;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
unsub();
|
|
94
|
+
}
|
|
95
|
+
}
|