Skip to content

Commit

Permalink
tests: fixing up tests and clean up
Browse files Browse the repository at this point in the history
- fixed linting
- removing unnecessary test files
- adding seek tests for `getClaims`
- agent adds self to gestalt graph on start up.
- updated worker test
- fixing tests
- fixed bin tests
- fixing bin tests
- fixing agent tests
- fixing client tests
- fixing vaults tests
- fixing notification tests
- fixes to `Discovery`
- updating logger and DB dependencies
- gestalts model testing
- fixing discovery tests
- updating nodes tests
- updated identities tests to use fast-check
- fixing identities tests
  • Loading branch information
tegefaulkes committed Dec 7, 2022
1 parent 4af9169 commit b399b1a
Show file tree
Hide file tree
Showing 238 changed files with 7,237 additions and 6,619 deletions.
4 changes: 2 additions & 2 deletions benches/suites/keys/key_generation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ async function main() {
b.add('generate root asymmetric keypair', () => {
generate.generateKeyPair();
}),
b.add('generate deterministic root keypair', () => {
generate.generateDeterministicKeyPair(code);
b.add('generate deterministic root keypair', async () => {
await generate.generateDeterministicKeyPair(code);
}),
b.add('generate 256 bit symmetric key', () => {
generate.generateKey();
Expand Down
6 changes: 3 additions & 3 deletions benches/suites/keys/keyring_lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ async function main() {
keysPath: `${dataDir}/keys`,
password: 'password',
logger,
fresh: true
fresh: true,
});
await keyRing.stop();
};
Expand All @@ -36,13 +36,13 @@ async function main() {
const keyRing = await KeyRing.createKeyRing({
keysPath: `${dataDir}/keys`,
password: 'password',
logger
logger,
});
await keyRing.stop();
return async () => {
// Due to password hashing this is intended to be slow
await keyRing.start({
password: 'password'
password: 'password',
});
await keyRing.stop();
};
Expand Down
8 changes: 4 additions & 4 deletions benches/suites/keys/password_hashing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ async function main() {
'password',
undefined,
password.passwordOpsLimits.min,
password.passwordMemLimits.min
password.passwordMemLimits.min,
);
}),
b.add('password hashing - interactive', () => {
password.hashPassword(
'password',
undefined,
password.passwordOpsLimits.interactive,
password.passwordMemLimits.interactive
password.passwordMemLimits.interactive,
);
}),
b.add('password hashing - moderate', () => {
password.hashPassword(
'password',
undefined,
password.passwordOpsLimits.moderate,
password.passwordMemLimits.moderate
password.passwordMemLimits.moderate,
);
}),
b.add('password hashing - sensitive', () => {
password.hashPassword(
'password',
undefined,
password.passwordOpsLimits.sensitive,
password.passwordMemLimits.sensitive
password.passwordMemLimits.sensitive,
);
}),
...suiteCommon,
Expand Down
27 changes: 15 additions & 12 deletions benches/suites/keys/x509.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,21 @@ async function main() {
x509.certFromASN1(certASN1);
};
}),
b.add('certificate serialization & deserialization to ASN1 buffer', async () => {
const cert = await x509.generateCertificate({
certId: certIdGenerator(),
subjectKeyPair,
issuerPrivateKey: issuerKeyPair.privateKey,
duration: 1000,
});
return () => {
const certASN1 = x509.certToASN1(cert);
x509.certFromASN1(certASN1);
};
}),
b.add(
'certificate serialization & deserialization to ASN1 buffer',
async () => {
const cert = await x509.generateCertificate({
certId: certIdGenerator(),
subjectKeyPair,
issuerPrivateKey: issuerKeyPair.privateKey,
duration: 1000,
});
return () => {
const certASN1 = x509.certToASN1(cert);
x509.certFromASN1(certASN1);
};
},
),
...suiteCommon,
);
return summary;
Expand Down
9 changes: 7 additions & 2 deletions benches/suites/workers/worker_keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ async function main() {
const logger = new Logger(`worker_overhead bench`, LogLevel.WARN, [
new StreamHandler(),
]);
const workerManager = await workersUtils.createWorkerManager({ cores, logger });
const workerManager = await workersUtils.createWorkerManager({
cores,
logger,
});
let summary: Summary;
try {
summary = await b.suite(
Expand Down Expand Up @@ -56,7 +59,9 @@ async function main() {
issuerPrivateKey: subjectKeyPair.privateKey.buffer,
duration: 1000,
});
return keysUtils.certFromASN1(Buffer.from(result) as CertificateASN1)!;
return keysUtils.certFromASN1(
Buffer.from(result) as CertificateASN1,
)!;
});
};
}),
Expand Down
7 changes: 4 additions & 3 deletions benches/suites/workers/worker_overhead.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import b from 'benny';
import crypto from 'crypto';
import Logger, { LogLevel, StreamHandler } from '@matrixai/logger';
import * as workersUtils from '@/workers/utils';
import { summaryName, suiteCommon } from '../../utils';
Expand All @@ -9,10 +8,12 @@ async function main() {
const logger = new Logger(`worker_overhead bench`, LogLevel.WARN, [
new StreamHandler(),
]);
const workerManager = await workersUtils.createWorkerManager({ cores, logger });
const workerManager = await workersUtils.createWorkerManager({
cores,
logger,
});
// 1 MiB worth of data is the ballpark range of data to be worth parallelising
// 1 KiB of data is still too small
const bytes = crypto.randomBytes(1024 * 1024);
const summary = await b.suite(
summaryName(__filename),
b.add('call overhead', async () => {
Expand Down
46 changes: 23 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
"ts-node": "ts-node",
"ts-node-inspect": "node --require ts-node/register --inspect",
"test": "jest",
"lint": "eslint '{src,tests,scripts,benches}/**/*.{js,ts,json}'",
"lintfix": "eslint '{src,tests,scripts,benches}/**/*.{js,ts,json}' --fix",
"lint": "eslint '{src,tests,scripts}/**/*.{js,ts,json}' 'benches/**/*.ts'",
"lintfix": "eslint '{src,tests,scripts}/**/*.{js,ts,json}' 'benches/**/*.ts' --fix",
"lint-shell": "find ./src ./tests ./scripts -type f -regextype posix-extended -regex '.*\\.(sh)' -exec shellcheck {} +",
"docs": "shx rm -rf ./docs && typedoc --gitRevision master --tsconfig ./tsconfig.build.json --out ./docs src",
"bench": "shx rm -rf ./benches/results && ts-node ./benches",
Expand All @@ -82,10 +82,10 @@
"@matrixai/async-cancellable": "^1.0.2",
"@matrixai/async-init": "^1.8.2",
"@matrixai/async-locks": "^3.2.0",
"@matrixai/db": "^5.0.3",
"@matrixai/errors": "^1.1.5",
"@matrixai/db": "^5.1.0",
"@matrixai/errors": "^1.1.6",
"@matrixai/id": "^3.3.3",
"@matrixai/logger": "^3.0.0",
"@matrixai/logger": "^3.1.0",
"@matrixai/resources": "^1.1.4",
"@matrixai/timer": "^1.0.0",
"@matrixai/workers": "^1.3.6",
Expand Down
Loading

0 comments on commit b399b1a

Please sign in to comment.