fix: test with libsession compiled with node-api

pull/2620/head
Audric Ackermann 2 years ago
parent 0e286142f1
commit 9d87ca2546

@ -107,7 +107,6 @@
"mic-recorder-to-mp3": "^2.2.2",
"moment": "^2.29.4",
"mustache": "2.3.0",
"nan": "2.14.2",
"node-fetch": "^2.6.7",
"os-locale": "5.0.0",
"p-retry": "^4.2.0",
@ -184,6 +183,7 @@
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"chai-bytes": "^0.1.2",
"cmake-js": "^7.2.1",
"concurrently": "^7.4.0",
"cross-env": "^6.0.3",
"css-loader": "^6.7.2",

@ -1,9 +1,9 @@
import * as BetterSqlite3 from 'better-sqlite3';
import {
ContactsConfigWrapperInsideWorker,
ConvoInfoVolatileWrapperInsideWorker,
UserConfigWrapperInsideWorker,
UserGroupsWrapperInsideWorker,
ContactsConfigWrapperNode,
ConvoInfoVolatileWrapperNode,
UserConfigWrapperNode,
UserGroupsWrapperNode,
} from 'libsession_util_nodejs';
import { compact, isArray, isEmpty, isNumber, isString, map, pick } from 'lodash';
import {
@ -1211,8 +1211,8 @@ function updateToSessionSchemaVersion29(currentVersion: number, db: BetterSqlite
function insertContactIntoContactWrapper(
contact: any,
blockedNumbers: Array<string>,
contactsConfigWrapper: ContactsConfigWrapperInsideWorker | null, // set this to null to only insert into the convo volatile wrapper (i.e. for ourConvo case)
volatileConfigWrapper: ConvoInfoVolatileWrapperInsideWorker,
contactsConfigWrapper: ContactsConfigWrapperNode | null, // set this to null to only insert into the convo volatile wrapper (i.e. for ourConvo case)
volatileConfigWrapper: ConvoInfoVolatileWrapperNode,
db: BetterSqlite3.Database
) {
if (contactsConfigWrapper !== null) {
@ -1296,8 +1296,8 @@ function insertContactIntoContactWrapper(
function insertCommunityIntoWrapper(
community: { id: string; priority: number },
userGroupConfigWrapper: UserGroupsWrapperInsideWorker,
volatileConfigWrapper: ConvoInfoVolatileWrapperInsideWorker,
userGroupConfigWrapper: UserGroupsWrapperNode,
volatileConfigWrapper: ConvoInfoVolatileWrapperNode,
db: BetterSqlite3.Database
) {
const priority = community.priority;
@ -1366,8 +1366,8 @@ function insertLegacyGroupIntoWrapper(
ConversationAttributes,
'id' | 'priority' | 'expireTimer' | 'displayNameInProfile' | 'lastJoinedTimestamp'
> & { members: string; groupAdmins: string }, // members and groupAdmins are still stringified here
userGroupConfigWrapper: UserGroupsWrapperInsideWorker,
volatileInfoConfigWrapper: ConvoInfoVolatileWrapperInsideWorker,
userGroupConfigWrapper: UserGroupsWrapperNode,
volatileInfoConfigWrapper: ConvoInfoVolatileWrapperNode,
db: BetterSqlite3.Database
) {
const {
@ -1546,13 +1546,10 @@ function updateToSessionSchemaVersion30(currentVersion: number, db: BetterSqlite
const blockedNumbers = getBlockedNumbersDuringMigration(db);
const { privateEd25519, publicKeyHex } = keys;
const userProfileWrapper = new UserConfigWrapperInsideWorker(privateEd25519, null);
const contactsConfigWrapper = new ContactsConfigWrapperInsideWorker(privateEd25519, null);
const userGroupsConfigWrapper = new UserGroupsWrapperInsideWorker(privateEd25519, null);
const volatileInfoConfigWrapper = new ConvoInfoVolatileWrapperInsideWorker(
privateEd25519,
null
);
const userProfileWrapper = new UserConfigWrapperNode(privateEd25519, null);
const contactsConfigWrapper = new ContactsConfigWrapperNode(privateEd25519, null);
const userGroupsConfigWrapper = new UserGroupsWrapperNode(privateEd25519, null);
const volatileInfoConfigWrapper = new ConvoInfoVolatileWrapperNode(privateEd25519, null);
/**
* Setup up the User profile wrapper with what is stored in our own conversation

@ -598,7 +598,7 @@ export function openAndMigrateDatabase(filePath: string, key: string) {
if (db) {
db.close();
}
console.log('migrateDatabase: Migration without cipher change failed', error);
console.log('migrateDatabase: Migration without cipher change failed', error.message);
}
// If that fails, we try to open the database with 3.x compatibility to extract the

@ -75,8 +75,13 @@ async function initializeLibSessionUtilWrappers() {
for (let index = 0; index < missingRequiredVariants.length; index++) {
const missingVariant = missingRequiredVariants[index];
window.log.warn('initializeLibSessionUtilWrappers: missingRequiredVariants: ', missingVariant);
window.log.warn(
`initializeLibSessionUtilWrappers: missingRequiredVariants "${missingVariant}"`
);
await GenericWrapperActions.init(missingVariant, privateKeyEd25519, null);
window.log.debug(
`initializeLibSessionUtilWrappers: missingRequiredVariants "${missingVariant}" created`
);
}
}

@ -1,11 +1,10 @@
import { isEmpty, isNull } from 'lodash';
import {
BaseConfigWrapper,
BaseConfigWrapperInsideWorker,
ContactsConfigWrapperInsideWorker,
ConvoInfoVolatileWrapperInsideWorker,
UserConfigWrapperInsideWorker,
UserGroupsWrapperInsideWorker,
BaseConfigWrapperNode,
ContactsConfigWrapperNode,
ConvoInfoVolatileWrapperNode,
UserConfigWrapperNode,
UserGroupsWrapperNode,
} from 'libsession_util_nodejs';
import { ConfigWrapperObjectTypes } from '../../browser/libsession_worker_functions';
@ -23,12 +22,12 @@ function assertUnreachable(_x: never, message: string): never {
/* eslint-disable strict */
// we can only have one of those so don't worry about storing them in a map for now
let userProfileWrapper: UserConfigWrapperInsideWorker | undefined;
let contactsConfigWrapper: ContactsConfigWrapperInsideWorker | undefined;
let userGroupsConfigWrapper: UserGroupsWrapperInsideWorker | undefined;
let convoInfoVolatileConfigWrapper: ConvoInfoVolatileWrapperInsideWorker | undefined;
let userProfileWrapper: UserConfigWrapperNode | undefined;
let contactsConfigWrapper: ContactsConfigWrapperNode | undefined;
let userGroupsConfigWrapper: UserGroupsWrapperNode | undefined;
let convoInfoVolatileConfigWrapper: ConvoInfoVolatileWrapperNode | undefined;
function getUserWrapper(type: ConfigWrapperObjectTypes): BaseConfigWrapperInsideWorker | undefined {
function getUserWrapper(type: ConfigWrapperObjectTypes): BaseConfigWrapperNode | undefined {
switch (type) {
case 'UserConfig':
return userProfileWrapper;
@ -43,9 +42,7 @@ function getUserWrapper(type: ConfigWrapperObjectTypes): BaseConfigWrapperInside
}
}
function getCorrespondingWrapper(
wrapperType: ConfigWrapperObjectTypes
): BaseConfigWrapperInsideWorker {
function getCorrespondingWrapper(wrapperType: ConfigWrapperObjectTypes): BaseConfigWrapperNode {
switch (wrapperType) {
case 'UserConfig':
case 'ContactsConfig':
@ -83,10 +80,7 @@ function assertUserWrapperType(wrapperType: ConfigWrapperObjectTypes): ConfigWra
/**
* This function can be used to initialize a wrapper which takes the private ed25519 key of the user and a dump as argument.
*/
function initUserWrapper(
options: Array<any>,
wrapperType: ConfigWrapperObjectTypes
): BaseConfigWrapper {
function initUserWrapper(options: Array<any>, wrapperType: ConfigWrapperObjectTypes) {
const userType = assertUserWrapperType(wrapperType);
const wrapper = getUserWrapper(wrapperType);
@ -107,17 +101,17 @@ function initUserWrapper(
}
switch (userType) {
case 'UserConfig':
userProfileWrapper = new UserConfigWrapperInsideWorker(edSecretKey, dump);
return userProfileWrapper;
userProfileWrapper = new UserConfigWrapperNode(edSecretKey, dump);
break;
case 'ContactsConfig':
contactsConfigWrapper = new ContactsConfigWrapperInsideWorker(edSecretKey, dump);
return contactsConfigWrapper;
contactsConfigWrapper = new ContactsConfigWrapperNode(edSecretKey, dump);
break;
case 'UserGroupsConfig':
userGroupsConfigWrapper = new UserGroupsWrapperInsideWorker(edSecretKey, dump);
return userGroupsConfigWrapper;
userGroupsConfigWrapper = new UserGroupsWrapperNode(edSecretKey, dump);
break;
case 'ConvoInfoVolatileConfig':
convoInfoVolatileConfigWrapper = new ConvoInfoVolatileWrapperInsideWorker(edSecretKey, dump);
return convoInfoVolatileConfigWrapper;
convoInfoVolatileConfigWrapper = new ConvoInfoVolatileWrapperNode(edSecretKey, dump);
break;
default:
assertUnreachable(userType, `initUserWrapper: Missing case error "${userType}"`);
}
@ -134,7 +128,6 @@ onmessage = async (e: { data: [number, ConfigWrapperObjectTypes, string, ...any]
postMessage([jobId, null, null]);
return;
}
const wrapper = getCorrespondingWrapper(config);
const fn = (wrapper as any)[action];

@ -2011,6 +2011,15 @@ auto-bind@^4.0.0:
resolved "https://registry.yarnpkg.com/auto-bind/-/auto-bind-4.0.0.tgz#e3589fc6c2da8f7ca43ba9f84fa52a744fc997fb"
integrity sha512-Hdw8qdNiqdJ8LqT0iK0sVzkFbzg6fhnQqqfWhBDxcHZvU75+B+ayzTy8x+k5Ix0Y92XOhOUlx74ps+bA6BeYMQ==
axios@^1.3.2:
version "1.3.6"
resolved "https://registry.yarnpkg.com/axios/-/axios-1.3.6.tgz#1ace9a9fb994314b5f6327960918406fa92c6646"
integrity sha512-PEcdkk7JcdPiMDkvM4K6ZBRYq9keuVJsToxm2zQIM70Qqo2WHTdJZMXcG9X+RmRp2VPNUQC8W1RAGbgt6b1yMg==
dependencies:
follow-redirects "^1.15.0"
form-data "^4.0.0"
proxy-from-env "^1.1.0"
babel-plugin-dynamic-import-node@^2.3.3:
version "2.3.3"
resolved "https://registry.yarnpkg.com/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.3.tgz#84fda19c976ec5c6defef57f9427b3def66e17a3"
@ -2517,6 +2526,25 @@ clsx@^1.0.4, clsx@^1.1.1:
resolved "https://registry.yarnpkg.com/clsx/-/clsx-1.1.1.tgz#98b3134f9abbdf23b2663491ace13c5c03a73188"
integrity sha512-6/bPho624p3S2pMyvP5kKBPXnI3ufHLObBFCfgx+LkeR5lg2XYy2hqZqUf45ypD8COn2bhgGJSUE+l5dhNBieA==
cmake-js@^7.2.1:
version "7.2.1"
resolved "https://registry.yarnpkg.com/cmake-js/-/cmake-js-7.2.1.tgz#757c0d39994121b084bab96290baf115ee7712cd"
integrity sha512-AdPSz9cSIJWdKvm0aJgVu3X8i0U3mNTswJkSHzZISqmYVjZk7Td4oDFg0mCBA383wO+9pG5Ix7pEP1CZH9x2BA==
dependencies:
axios "^1.3.2"
debug "^4"
fs-extra "^10.1.0"
lodash.isplainobject "^4.0.6"
memory-stream "^1.0.0"
node-api-headers "^0.0.2"
npmlog "^6.0.2"
rc "^1.2.7"
semver "^7.3.8"
tar "^6.1.11"
url-join "^4.0.1"
which "^2.0.2"
yargs "^17.6.0"
color-convert@^1.9.0, color-convert@^1.9.3:
version "1.9.3"
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
@ -2861,7 +2889,7 @@ date-fns@^2.29.1:
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.29.3.tgz#27402d2fc67eb442b511b70bbdf98e6411cd68a8"
integrity sha512-dDCnyH2WnnKusqvZZ6+jA1O51Ibt8ZMRNkDZdyAyK4YfbDwa/cEmuztzG5pk6hqlp9aSBPYcjOlktquahGwGeA==
debug@4, debug@4.3.4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.2, debug@^4.3.3:
debug@4, debug@4.3.4, debug@^4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.2, debug@^4.3.3:
version "4.3.4"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
@ -3853,6 +3881,11 @@ flatted@^3.1.0:
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.5.tgz#76c8584f4fc843db64702a6bd04ab7a8bd666da3"
integrity sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==
follow-redirects@^1.15.0:
version "1.15.2"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13"
integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==
foreground-child@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/foreground-child/-/foreground-child-2.0.0.tgz#71b32800c9f15aa8f2f83f4a6bd9bff35d861a53"
@ -3894,7 +3927,7 @@ fs-extra@9.0.0:
jsonfile "^6.0.1"
universalify "^1.0.0"
fs-extra@^10.0.0:
fs-extra@^10.0.0, fs-extra@^10.1.0:
version "10.1.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.1.0.tgz#02873cfbc4084dde127eaa5f9905eef2325d1abf"
integrity sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==
@ -5149,6 +5182,11 @@ lodash.isequal@^4.5.0:
resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
integrity sha1-QVxEePK8wwEgwizhDtMib30+GOA=
lodash.isplainobject@^4.0.6:
version "4.0.6"
resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb"
integrity sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==
lodash.merge@^4.6.2:
version "4.6.2"
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
@ -5265,6 +5303,13 @@ mem@^5.0.0:
mimic-fn "^2.1.0"
p-is-promise "^2.1.0"
memory-stream@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/memory-stream/-/memory-stream-1.0.0.tgz#481dfd259ccdf57b03ec2c9632960044180e73c2"
integrity sha512-Wm13VcsPIMdG96dzILfij09PvuS3APtcKNh7M28FsCA/w6+1mjR7hhPmfFNoilX9xU7wTdhsH5lJAm6XNzdtww==
dependencies:
readable-stream "^3.4.0"
merge-stream@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
@ -5464,11 +5509,6 @@ mv@~2:
ncp "~2.0.0"
rimraf "~2.4.0"
nan@2.14.2:
version "2.14.2"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.2.tgz#f5376400695168f4cc694ac9393d0c9585eeea19"
integrity sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ==
nan@^2.14.0:
version "2.15.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.15.0.tgz#3f34a473ff18e15c1b5626b62903b5ad6e665fee"
@ -5539,6 +5579,11 @@ nise@^4.0.1:
just-extend "^4.0.2"
path-to-regexp "^1.7.0"
node-api-headers@^0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/node-api-headers/-/node-api-headers-0.0.2.tgz#31f4c6c2750b63e598128e76a60aefca6d76ac5d"
integrity sha512-YsjmaKGPDkmhoNKIpkChtCsPVaRE0a274IdERKnuc/E8K1UJdBZ4/mvI006OijlQZHCfpRNOH3dfHQs92se8gg==
node-fetch@^2.6.7:
version "2.6.7"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad"
@ -5651,7 +5696,7 @@ npm-run-path@^4.0.0:
dependencies:
path-key "^3.0.0"
npmlog@^6.0.0:
npmlog@^6.0.0, npmlog@^6.0.2:
version "6.0.2"
resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-6.0.2.tgz#c8166017a42f2dea92d6453168dd865186a70830"
integrity sha512-/vBvz5Jfr9dT/aFWd0FIRf+T/Q2WBsLENygUaFUqstqsycmZAP/t5BvFJTK0viFmSUxiUKTUplWy5vt+rvKIxg==
@ -6395,7 +6440,7 @@ rc-util@^4.0.4, rc-util@^4.15.3, rc-util@^4.4.0:
react-lifecycles-compat "^3.0.4"
shallowequal "^1.1.0"
rc@^1.2.8:
rc@^1.2.7, rc@^1.2.8:
version "1.2.8"
resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed"
integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==
@ -6593,6 +6638,15 @@ readable-stream@^2.2.2:
string_decoder "~1.1.1"
util-deprecate "~1.0.1"
readable-stream@^3.4.0:
version "3.6.2"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.2.tgz#56a9b36ea965c00c5a93ef31eb111a0f11056967"
integrity sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==
dependencies:
inherits "^2.0.3"
string_decoder "^1.1.1"
util-deprecate "^1.0.1"
readable-stream@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198"
@ -7760,6 +7814,11 @@ uri-js@^4.2.2:
dependencies:
punycode "^2.1.0"
url-join@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/url-join/-/url-join-4.0.1.tgz#b642e21a2646808ffa178c4c5fda39844e12cde7"
integrity sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA==
use-strict@1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/use-strict/-/use-strict-1.0.1.tgz#0bb80d94f49a4a05192b84a8c7d34e95f1a7e3a0"
@ -8090,7 +8149,7 @@ yargs-parser@^20.2.2:
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee"
integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==
yargs-parser@^21.0.0:
yargs-parser@^21.0.0, yargs-parser@^21.1.1:
version "21.1.1"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35"
integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==
@ -8148,6 +8207,19 @@ yargs@^17.3.1:
y18n "^5.0.5"
yargs-parser "^21.0.0"
yargs@^17.6.0:
version "17.7.1"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.7.1.tgz#34a77645201d1a8fc5213ace787c220eabbd0967"
integrity sha512-cwiTb08Xuv5fqF4AovYacTFNxk62th7LKJ6BL9IGUpTJrWoU7/7WdQGTP2SjKf1dUNBGzDd28p/Yfs/GI6JrLw==
dependencies:
cliui "^8.0.1"
escalade "^3.1.1"
get-caller-file "^2.0.5"
require-directory "^2.1.1"
string-width "^4.2.3"
y18n "^5.0.5"
yargs-parser "^21.1.1"
yauzl@^2.10.0:
version "2.10.0"
resolved "https://registry.yarnpkg.com/yauzl/-/yauzl-2.10.0.tgz#c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9"

Loading…
Cancel
Save