From a32e4136cf7069e7f0d4aa1a5763fd9958831eae Mon Sep 17 00:00:00 2001 From: David Estes Date: Fri, 8 Nov 2024 14:18:26 -0700 Subject: [PATCH 1/8] fix: explicit UTC on expected date --- packages/test-vectors/test/vectors.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/test-vectors/test/vectors.test.ts b/packages/test-vectors/test/vectors.test.ts index ac84f3e..e2347e0 100644 --- a/packages/test-vectors/test/vectors.test.ts +++ b/packages/test-vectors/test/vectors.test.ts @@ -26,7 +26,7 @@ import { loadCAR, } from '../src/index.ts' -const EXPECTED_EXPIRED_DATE = new Date(2000, 0).toISOString() +const EXPECTED_EXPIRED_DATE = new Date(Date.UTC(2000, 0, 1, 0)).toISOString(); const verifier = createDID() From f19da9c5d77d1a3ac52d9e2ef6ebaeb924aa8c77 Mon Sep 17 00:00:00 2001 From: David Estes Date: Mon, 11 Nov 2024 15:09:59 -0700 Subject: [PATCH 2/8] wip: update c1 env vars this might be a mistake for CI but the defaults have changed --- packages/jest-environment/src/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/jest-environment/src/index.ts b/packages/jest-environment/src/index.ts index 6409209..1a89e38 100644 --- a/packages/jest-environment/src/index.ts +++ b/packages/jest-environment/src/index.ts @@ -15,8 +15,10 @@ const startContainer = (withContainer as unknown as { default: StartContainer }) type RunningContainer = Awaited> +const DEFAULT_PORT = 5101 + const DEFAULT_ENVIRONMENT = { - CERAMIC_ONE_BIND_ADDRESS: '0.0.0.0:5001', + CERAMIC_ONE_BIND_ADDRESS: '0.0.0.0:5101', CERAMIC_ONE_LOG_FORMAT: 'single-line', CERAMIC_ONE_NETWORK: 'in-memory', CERAMIC_ONE_STORE_DIR: '/', @@ -66,8 +68,8 @@ export default class CeramicEnvironment extends NodeEnvironment { containerName: options.containerName ?? `ceramic-${Math.random().toString(36).slice(6)}`, - internalPort: options.internalPort ?? 5001, - defaultExternalPort: options.defaultExternalPort ?? 5001, + internalPort: options.internalPort ?? DEFAULT_PORT, + defaultExternalPort: options.defaultExternalPort ?? DEFAULT_PORT, externalPort: options.externalPort, connectTimeoutSeconds: options.connectTimeoutSeconds ?? 10, environment, From 3a4c2cb358be70ef2200df009b07fc201e3a19cb Mon Sep 17 00:00:00 2001 From: David Estes Date: Thu, 14 Nov 2024 09:42:29 -0700 Subject: [PATCH 3/8] chore: rework integration tests to pass more ports/options to container and remove jest env overrides seems simple to just use beforeAll/afterAll to set up the client since we know what to expect. the withContainer package didn't allow multiple ports, so modified to do so so we can eventually use 1 image for multiple files if we want or use this for other purposes. in the end, didn't really need it since we only need api or flight, technically as it is, but it isn't super complex and lets us modify it as desired --- packages/jest-environment/LICENSE-APACHE | 5 - packages/jest-environment/LICENSE-MIT | 19 -- packages/jest-environment/README.md | 5 - packages/jest-environment/package.json | 57 ------ packages/jest-environment/src/index.ts | 89 --------- packages/jest-environment/tsconfig.json | 7 - tests/c1-integration/package.json | 16 +- tests/c1-integration/src/index.ts | 100 ++++++++++ tests/c1-integration/src/withContainer.ts | 211 +++++++++++++++++++++ tests/c1-integration/test/document.test.ts | 128 +++++++------ tests/c1-integration/test/model.test.ts | 60 ++++-- 11 files changed, 434 insertions(+), 263 deletions(-) delete mode 100644 packages/jest-environment/LICENSE-APACHE delete mode 100644 packages/jest-environment/LICENSE-MIT delete mode 100644 packages/jest-environment/README.md delete mode 100644 packages/jest-environment/package.json delete mode 100644 packages/jest-environment/src/index.ts delete mode 100644 packages/jest-environment/tsconfig.json create mode 100644 tests/c1-integration/src/index.ts create mode 100644 tests/c1-integration/src/withContainer.ts diff --git a/packages/jest-environment/LICENSE-APACHE b/packages/jest-environment/LICENSE-APACHE deleted file mode 100644 index 14478a3..0000000 --- a/packages/jest-environment/LICENSE-APACHE +++ /dev/null @@ -1,5 +0,0 @@ -Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/packages/jest-environment/LICENSE-MIT b/packages/jest-environment/LICENSE-MIT deleted file mode 100644 index 749aa1e..0000000 --- a/packages/jest-environment/LICENSE-MIT +++ /dev/null @@ -1,19 +0,0 @@ -The MIT License (MIT) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file diff --git a/packages/jest-environment/README.md b/packages/jest-environment/README.md deleted file mode 100644 index 1cb6091..0000000 --- a/packages/jest-environment/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Ceramic Jest environment - -## License - -Dual licensed under MIT and Apache 2 diff --git a/packages/jest-environment/package.json b/packages/jest-environment/package.json deleted file mode 100644 index c37bd3d..0000000 --- a/packages/jest-environment/package.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "name": "jest-environment-ceramic", - "version": "0.1.0", - "private": true, - "author": "3Box Labs", - "license": "(Apache-2.0 OR MIT)", - "keywords": ["ceramic", "jest", "environment"], - "repository": { - "type": "git", - "url": "https://github.com/ceramicstudio/ceramic-sdk", - "directory": "packages/jest-environment" - }, - "type": "module", - "main": "dist/index.js", - "types": "dist/index.d.ts", - "exports": { - ".": "./dist/index.js" - }, - "files": ["dist"], - "engines": { - "node": ">=20" - }, - "sideEffects": false, - "scripts": { - "build:clean": "del dist", - "build:js": "swc src -d ./dist --config-file ../../.swcrc --strip-leading-paths", - "build:types": "tsc --project tsconfig.json --emitDeclarationOnly --skipLibCheck", - "build": "pnpm build:clean && pnpm build:types && pnpm build:js", - "lint": "eslint src --fix", - "test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js", - "test:ci": "pnpm run test --ci --coverage", - "prepare": "pnpm build", - "prepublishOnly": "package-check" - }, - "dependencies": { - "@ceramic-sdk/http-client": "workspace:^", - "@databases/with-container": "^2.1.1", - "jest-environment-node": "^29.7.0" - }, - "jest": { - "extensionsToTreatAsEsm": [".ts"], - "moduleNameMapper": { - "^(\\.{1,2}/.*)\\.js$": "$1" - }, - "transform": { - "^.+\\.(t|j)s$": [ - "@swc/jest", - { - "root": "../.." - } - ] - } - }, - "devDependencies": { - "@jest/environment": "^29.7.0" - } -} diff --git a/packages/jest-environment/src/index.ts b/packages/jest-environment/src/index.ts deleted file mode 100644 index 1a89e38..0000000 --- a/packages/jest-environment/src/index.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { CeramicClient } from '@ceramic-sdk/http-client' -import withContainer from '@databases/with-container' -import type { - EnvironmentContext, - JestEnvironmentConfig, -} from '@jest/environment' -import NodeEnv from 'jest-environment-node' - -type Environment = typeof NodeEnv -const NodeEnvironment = (NodeEnv as unknown as { default: Environment }).default - -type StartContainer = typeof withContainer -const startContainer = (withContainer as unknown as { default: StartContainer }) - .default - -type RunningContainer = Awaited> - -const DEFAULT_PORT = 5101 - -const DEFAULT_ENVIRONMENT = { - CERAMIC_ONE_BIND_ADDRESS: '0.0.0.0:5101', - CERAMIC_ONE_LOG_FORMAT: 'single-line', - CERAMIC_ONE_NETWORK: 'in-memory', - CERAMIC_ONE_STORE_DIR: '/', -} - -export type CeramicGlobal = { - client: CeramicClient - port: number -} - -declare global { - const ceramic: CeramicGlobal -} - -export type EnvironmentOptions = { - debug?: boolean // default to false - image?: string // default to "public.ecr.aws/r5b3e0r5/3box/ceramic-one:latest" - containerName?: string // default to "ceramic-one" - internalPort?: number // default to 5001 - defaultExternalPort?: number // default to 5001 - externalPort?: number - connectTimeoutSeconds?: number // default to 10 - environment?: Record // Ceramic daemon environment variables -} - -export default class CeramicEnvironment extends NodeEnvironment { - #container?: RunningContainer - #options: EnvironmentOptions - - constructor(config: JestEnvironmentConfig, context: EnvironmentContext) { - super(config, context) - this.#options = config.projectConfig - .testEnvironmentOptions as EnvironmentOptions - } - - async setup() { - await super.setup() - - const { environment: envOverrides, ...options } = this.#options - const environment = envOverrides - ? { ...DEFAULT_ENVIRONMENT, ...envOverrides } - : DEFAULT_ENVIRONMENT - - this.#container = await startContainer({ - debug: options.debug ?? false, - image: options.image ?? 'public.ecr.aws/r5b3e0r5/3box/ceramic-one:latest', - containerName: - options.containerName ?? - `ceramic-${Math.random().toString(36).slice(6)}`, - internalPort: options.internalPort ?? DEFAULT_PORT, - defaultExternalPort: options.defaultExternalPort ?? DEFAULT_PORT, - externalPort: options.externalPort, - connectTimeoutSeconds: options.connectTimeoutSeconds ?? 10, - environment, - }) - - const port = this.#container.externalPort - this.global.ceramic = { - client: new CeramicClient({ url: `http://localhost:${port}` }), - port, - } - } - - async teardown(): Promise { - await this.#container?.kill() - await super.teardown() - } -} diff --git a/packages/jest-environment/tsconfig.json b/packages/jest-environment/tsconfig.json deleted file mode 100644 index 34756dd..0000000 --- a/packages/jest-environment/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tsconfig.build.json", - "compilerOptions": { - "outDir": "./dist" - }, - "include": ["src"] -} diff --git a/tests/c1-integration/package.json b/tests/c1-integration/package.json index ca06f80..27fdeb2 100644 --- a/tests/c1-integration/package.json +++ b/tests/c1-integration/package.json @@ -13,22 +13,28 @@ "sideEffects": false, "scripts": { "lint": "eslint src --fix", - "test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js" + "build:clean": "del dist", + "build:js": "swc src -d ./dist --config-file ../../.swcrc --strip-leading-paths", + "build": "pnpm build:clean && pnpm build:js", + "test": "pnpm build && node --experimental-vm-modules ../../node_modules/jest/bin/jest.js" }, "dependencies": { "@ceramic-sdk/events": "workspace:^", "@ceramic-sdk/identifiers": "workspace:^", + "@ceramic-sdk/http-client": "workspace:^", "@ceramic-sdk/model-client": "workspace:^", "@ceramic-sdk/model-handler": "workspace:^", "@ceramic-sdk/model-instance-client": "workspace:^", "@ceramic-sdk/model-instance-handler": "workspace:^", "@ceramic-sdk/model-instance-protocol": "workspace:^", "@ceramic-sdk/model-protocol": "workspace:^", - "@didtools/key-did": "^1.0.0" - }, - "devDependencies": { - "jest-environment-ceramic": "workspace:^" + "@didtools/key-did": "^1.0.0", + "@jest/environment": "^29.7.0", + "@types/cross-spawn": "^6.0.0", + "cross-spawn": "^7.0.5", + "modern-spawn": "^1.0.0" }, + "devDependencies": {}, "jest": { "extensionsToTreatAsEsm": [".ts"], "moduleNameMapper": { diff --git a/tests/c1-integration/src/index.ts b/tests/c1-integration/src/index.ts new file mode 100644 index 0000000..8ae13c1 --- /dev/null +++ b/tests/c1-integration/src/index.ts @@ -0,0 +1,100 @@ +import ContainerWrapper from './withContainer.js' + +const DEFAULT_PORT = 5101 +const DEFAULT_FLIGHT_SQL_PORT = 5102 + +const DEFAULT_ENVIRONMENT = { + CERAMIC_ONE_BIND_ADDRESS: '0.0.0.0:5101', + CERAMIC_ONE_EXPERIMENTAL_FEATURES: 'true', + CERAMIC_ONE_FLIGHT_SQL_BIND_ADDRESS: '0.0.0.0:5102', + CERAMIC_ONE_S3_BUCKET: 'sdkintegrationtests.new', + CERAMIC_ONE_LOG_FORMAT: 'single-line', + CERAMIC_ONE_NETWORK: 'in-memory', + CERAMIC_ONE_STORE_DIR: '/', +} + +export type EnvironmentOptions = { + debug?: boolean // default to false + image?: string // default to "public.ecr.aws/r5b3e0r5/3box/ceramic-one:latest" + containerName?: string // default to "ceramic-one" + apiPort: number // default to 5101 + internalApiPort?: number // default to 5101 + internalFlightSqlPort?: number // default to 5102 + flightSqlPort: number // default to 5102 + externalPort?: number + connectTimeoutSeconds?: number // default to 10 + // defaults to api port if not specified + testPort?: number + environment?: Record // Ceramic daemon environment variables +} + +function delay(ms: number): Promise { + return new Promise((resolve) => setTimeout(resolve, ms)) +} + +export default class CeramicOneContainer { + #container: ContainerWrapper + + private constructor(container: ContainerWrapper) { + this.#container = container + } + + static async healthFn(port): Promise { + try { + const res = await fetch(`http://localhost:${port}/ceramic/version`) + + if (res.status === 200) { + return true + } + return false + } catch (err) { + return false + } + } + + static async isResponding(port: number) { + let retries = 5 + while (retries > 0) { + if (await CeramicOneContainer.healthFn(port)) { + return + } + retries -= 1 + await delay(1000) + } + console.error( + `Failed to verify container was up on port ${port}. tests will fail`, + ) + return + } + + static async startContainer( + options: EnvironmentOptions, + ): Promise { + const container = await ContainerWrapper.startContainer({ + debug: options.debug ?? false, + image: options.image ?? 'public.ecr.aws/r5b3e0r5/3box/ceramic-one:latest', + // TODO: would be nice to have 1 container for all tests rather than 1 each since we get rate errors pulling + // refreshImage: true, // pull new images + containerName: + options.containerName ?? + `ceramic-${Math.random().toString(36).slice(6)}`, + apiPort: options.apiPort ?? DEFAULT_PORT, + internalApiPort: options.internalApiPort ?? DEFAULT_PORT, + flightSqlPort: options.flightSqlPort || DEFAULT_FLIGHT_SQL_PORT, + internalFlightSqlPort: + options.internalFlightSqlPort || DEFAULT_FLIGHT_SQL_PORT, + connectTimeoutSeconds: options.connectTimeoutSeconds ?? 10, + environment: DEFAULT_ENVIRONMENT, + detached: true, + }) + + // we do this because the container connects on the port but the api doesn't respond right away so the tests can fail + // could add/improve `EnvironmentOptions.testConnection` handling but I didn't get something right so just doing this + await CeramicOneContainer.isResponding(options.apiPort) + return new CeramicOneContainer(container) + } + + async teardown(): Promise { + await this.#container.kill() + } +} diff --git a/tests/c1-integration/src/withContainer.ts b/tests/c1-integration/src/withContainer.ts new file mode 100644 index 0000000..d63d629 --- /dev/null +++ b/tests/c1-integration/src/withContainer.ts @@ -0,0 +1,211 @@ +// MIT license sourced from https://github.com/ForbesLindesay/atdatabases/blob/master/packages/with-container/src/index.ts + +import type { ChildProcess } from 'node:child_process' +import { connect } from 'node:net' +import spawn from 'cross-spawn' +import { spawnBuffered } from 'modern-spawn' + +export interface Options { + debug: boolean + image: string + containerName: string + apiPort: number + internalApiPort: number + flightSqlPort: number + internalFlightSqlPort: number + connectTimeoutSeconds: number + testPort?: number + environment?: { [key: string]: string } + /** + * By default, we check if the image already exists + * before pulling it. We only pull if there is no + * existing image. This is faster, but means we don't + * get updates to the image. + */ + refreshImage?: boolean + detached?: boolean + enableDebugInstructions?: string +} + +export async function imageExists(options: Options): Promise { + const stdout = await spawnBuffered( + 'docker', + ['images', '--format', '{{json .}}'], + { + debug: options.debug, + }, + ).getResult('utf8') + const existingImages = stdout + .trim() + .split('\n') + .map((str) => { + try { + return JSON.parse(str) + } catch (ex) { + console.warn(`Unable to parse: ${str}`) + return null + } + }) + .filter((n) => n != null) + const [Repository, Tag] = options.image.split(':') + return existingImages.some( + (i) => i.Repository === Repository && (!Tag || i.Tag === Tag), + ) +} +export async function pullDockerImage(options: Options) { + if ( + !options.refreshImage && + /.+\:.+/.test(options.image) && + (await imageExists(options)) + ) { + console.warn( + `${options.image} already pulled (use 'refreshImage' to refresh)`, + ) + return + } + console.log(`Pulling Docker Image ${options.image}`) + await spawnBuffered('docker', ['pull', options.image], { + debug: options.debug, + }).getResult() +} + +export function startDockerContainer(options: Options) { + const env = options.environment || {} + const envArgs: string[] = [] + for (const key of Object.keys(env)) { + envArgs.push('--env') + envArgs.push(`${key}=${env[key]}`) + } + return spawn( + 'docker', + [ + 'run', + '--platform', + 'linux/x86_64', // our default ceramic-one build + '--name', + options.containerName, + // '-t', // terminate when sent SIGTERM + // '--rm', // automatically remove when container is killed + '-p', // forward appropriate port + `${options.flightSqlPort}:${options.internalFlightSqlPort}`, + '-p', + `${options.apiPort}:${options.internalApiPort}`, + ...(options.detached ? ['--detach'] : []), + // set enviornment variables + ...envArgs, + options.image, + ], + { + stdio: options.debug ? 'inherit' : 'ignore', + }, + ) +} + +export async function waitForDatabaseToStart(options: Options) { + await new Promise((resolve, reject) => { + let finished = false + const timeout = setTimeout(() => { + finished = true + reject( + new Error( + `Unable to connect to database after ${ + options.connectTimeoutSeconds + } seconds.${ + options.enableDebugInstructions + ? ` ${options.enableDebugInstructions}` + : '' + }`, + ), + ) + }, options.connectTimeoutSeconds * 1000) + function test() { + const testPort = options.testPort || options.apiPort + console.log(`Waiting for ${options.containerName} on port ${testPort}...`) + testConnection(testPort).then( + (isConnected) => { + if (finished) { + console.log( + `Connected to ${options.containerName} on port ${testPort}!`, + ) + return + } + if (isConnected) { + finished = true + clearTimeout(timeout) + setTimeout(resolve, 1000) + } else { + setTimeout(test, 500) + } + }, + (err) => { + reject(err) + }, + ) + } + test() + }) +} +async function testConnection(port: number): Promise { + return new Promise((resolve) => { + const connection = connect(port) + .on('error', () => { + resolve(false) + }) + .on('connect', () => { + connection.end() + resolve(true) + }) + }) +} +async function killOldContainers( + options: Pick, +) { + await spawnBuffered('docker', ['kill', options.containerName], { + debug: options.debug, + }) // do not check exit code as there may not be a container to kill + await spawnBuffered('docker', ['rm', options.containerName], { + debug: options.debug, + }) // do not check exit code as there may not be a container to remove +} + +export default class ContainerWrapper { + proc: ChildProcess + opts: Options + + private constructor(proc: ChildProcess, opts: Options) { + this.proc = proc + this.opts = opts + } + + static async startContainer(opts: Options): Promise { + if (Number.isNaN(opts.connectTimeoutSeconds)) { + throw new Error('connectTimeoutSeconds must be a valid integer.') + } + + if (typeof opts.apiPort !== 'number') { + throw new Error('Expected external api port to be a number') + } + if (typeof opts.flightSqlPort !== 'number') { + throw new Error('Expected external flight SQL port to be a number') + } + + await Promise.all([pullDockerImage(opts), killOldContainers(opts)]) + + console.log(`Starting Docker Container ${opts.containerName}`) + const proc = startDockerContainer(opts) + + try { + await waitForDatabaseToStart(opts) + console.log('connected to container successfully!') + } catch (e) { + console.error(`failed to ping container: ${e}`) + throw e + } + + return new ContainerWrapper(proc, opts) + } + + async kill() { + await killOldContainers(this.opts) + } +} diff --git a/tests/c1-integration/test/document.test.ts b/tests/c1-integration/test/document.test.ts index e00eca4..72dd325 100644 --- a/tests/c1-integration/test/document.test.ts +++ b/tests/c1-integration/test/document.test.ts @@ -1,9 +1,5 @@ -/** - * @jest-environment ceramic - * @jest-environment-options {"containerName":"ceramic-test-document","externalPort":5202} - */ - import { signedEventToCAR } from '@ceramic-sdk/events' +import { CeramicClient } from '@ceramic-sdk/http-client' import { StreamID } from '@ceramic-sdk/identifiers' import { createInitEvent as createModel } from '@ceramic-sdk/model-client' import { @@ -18,7 +14,8 @@ import { getModelStreamID, } from '@ceramic-sdk/model-protocol' import { getAuthenticatedDID } from '@didtools/key-did' -import 'jest-environment-ceramic' +import CeramicOneContainer, { type EnvironmentOptions } from '../src' +import ContainerWrapper from '../src/withContainer' const authenticatedDID = await getAuthenticatedDID(new Uint8Array(32)) @@ -38,61 +35,82 @@ const testModel: ModelDefinition = { }, } -test('create model and documents using the model', async () => { - const modelsStore: Record = {} +const OPTIONS: EnvironmentOptions = { + containerName: 'ceramic-test-document', + apiPort: 5211, + flightSqlPort: 5212, +} + +describe('model integration test', () => { + let c1Container: CeramicOneContainer + const client = new CeramicClient({ + url: `http://127.0.0.1:${OPTIONS.apiPort}`, + }) - const context = { - getModelDefinition: async (id) => { - const cid = StreamID.fromString(id).cid.toString() - const state = modelsStore[cid] - if (state == null) { - throw new Error(`State not found for model: ${id}`) - } - return state.content - }, - verifier: authenticatedDID, - } + beforeAll(async () => { + c1Container = await CeramicOneContainer.startContainer(OPTIONS) + }, 10000) + + test('create model and documents using the model', async () => { + const modelsStore: Record = {} + + const context = { + getModelDefinition: async (id) => { + const cid = StreamID.fromString(id).cid.toString() + const state = modelsStore[cid] + if (state == null) { + throw new Error(`State not found for model: ${id}`) + } + return state.content + }, + verifier: authenticatedDID, + } + + const modelEvent = await createModel(authenticatedDID, testModel) + const modelCID = signedEventToCAR(modelEvent).roots[0] + const modelCIDstring = modelCID.toString() + modelsStore[modelCIDstring] = await handleModel( + modelCIDstring, + modelEvent, + context, + ) - const modelEvent = await createModel(authenticatedDID, testModel) - const modelCID = signedEventToCAR(modelEvent).roots[0] - const modelCIDstring = modelCID.toString() - modelsStore[modelCIDstring] = await handleModel( - modelCIDstring, - modelEvent, - context, - ) + await client.registerInterestModel(modelCIDstring) - await ceramic.client.registerInterestModel(modelCIDstring) + const model = getModelStreamID(modelCID) - const model = getModelStreamID(modelCID) + async function createAndPostDocument( + content: Record, + ): Promise { + const event = await createDocument({ + controller: authenticatedDID, + content, + model, + }) + await client.postEventType(DocumentEvent, event) + } - async function createAndPostDocument( - content: Record, - ): Promise { - const event = await createDocument({ - controller: authenticatedDID, - content, - model, - }) - await ceramic.client.postEventType(DocumentEvent, event) - } + await createAndPostDocument({ test: 'one' }) + await createAndPostDocument({ test: 'two' }) - await createAndPostDocument({ test: 'one' }) - await createAndPostDocument({ test: 'two' }) + const feed = await client.getEventsFeed() + expect(feed.events).toHaveLength(2) + const eventID1 = feed.events[0].id + const eventID2 = feed.events[1].id - const feed = await ceramic.client.getEventsFeed() - expect(feed.events).toHaveLength(2) - const eventID1 = feed.events[0].id - const eventID2 = feed.events[1].id + const [event1, event2] = await Promise.all([ + client.getEventType(DocumentEvent, eventID1), + client.getEventType(DocumentEvent, eventID2), + ]) + const [state1, state2] = await Promise.all([ + handleDocument(eventID1, event1, context), + handleDocument(eventID2, event2, context), + ]) + expect(state1.content).toEqual({ test: 'one' }) + expect(state2.content).toEqual({ test: 'two' }) + }) - const [event1, event2] = await Promise.all([ - ceramic.client.getEventType(DocumentEvent, eventID1), - ceramic.client.getEventType(DocumentEvent, eventID2), - ]) - const [state1, state2] = await Promise.all([ - handleDocument(eventID1, event1, context), - handleDocument(eventID2, event2, context), - ]) - expect(state1.content).toEqual({ test: 'one' }) - expect(state2.content).toEqual({ test: 'two' }) + afterAll(async () => { + await c1Container.teardown() + }) }) diff --git a/tests/c1-integration/test/model.test.ts b/tests/c1-integration/test/model.test.ts index 48a875f..4e8acd8 100644 --- a/tests/c1-integration/test/model.test.ts +++ b/tests/c1-integration/test/model.test.ts @@ -1,9 +1,5 @@ -/** - * @jest-environment ceramic - * @jest-environment-options {"containerName":"ceramic-test-model","externalPort":5201} - */ - import { SignedEvent, signedEventToCAR } from '@ceramic-sdk/events' +import { CeramicClient } from '@ceramic-sdk/http-client' import { createInitEvent } from '@ceramic-sdk/model-client' import { type Context, handleEvent } from '@ceramic-sdk/model-handler' import { @@ -12,7 +8,8 @@ import { ModelEvent, } from '@ceramic-sdk/model-protocol' import { getAuthenticatedDID } from '@didtools/key-did' -import 'jest-environment-ceramic' +import CeramicOneContainer, { type EnvironmentOptions } from '../src' +import type ContainerWrapper from '../src/withContainer' const authenticatedDID = await getAuthenticatedDID(new Uint8Array(32)) @@ -30,23 +27,44 @@ const testModel: ModelDefinition = { }, } -test('create model', async () => { - await ceramic.client.registerInterestModel(MODEL_STREAM_ID) +const OPTIONS: EnvironmentOptions = { + containerName: 'ceramic-test-model', + apiPort: 5201, + flightSqlPort: 5202, +} + +describe('model integration test', () => { + let c1Container: CeramicOneContainer + const client = new CeramicClient({ + url: `http://127.0.0.1:${OPTIONS.apiPort}`, + }) + + beforeAll(async () => { + c1Container = await CeramicOneContainer.startContainer(OPTIONS) + }, 10000) + + test('create model', async () => { + await client.registerInterestModel(MODEL_STREAM_ID) + + const createdEvent = await createInitEvent(authenticatedDID, testModel) + const modelCAR = signedEventToCAR(createdEvent) + const modelCID = modelCAR.roots[0].toString() + await client.postEventType(ModelEvent, createdEvent) - const createdEvent = await createInitEvent(authenticatedDID, testModel) - const modelCAR = signedEventToCAR(createdEvent) - const modelCID = modelCAR.roots[0].toString() - await ceramic.client.postEventType(ModelEvent, createdEvent) + const feed = await client.getEventsFeed() + const eventID = feed.events[0].id + expect(eventID).toBe(modelCID) - const feed = await ceramic.client.getEventsFeed() - const eventID = feed.events[0].id - expect(eventID).toBe(modelCID) + const receivedEvent = await client.getEventType(SignedEvent, eventID) + expect(receivedEvent.jws.payload).toBe(createdEvent.jws.payload) - const receivedEvent = await ceramic.client.getEventType(SignedEvent, eventID) - expect(receivedEvent.jws.payload).toBe(createdEvent.jws.payload) + const state = await handleEvent(eventID, receivedEvent, { + verifier: authenticatedDID, + } as unknown as Context) + expect(state.content).toEqual(testModel) + }) - const state = await handleEvent(eventID, receivedEvent, { - verifier: authenticatedDID, - } as unknown as Context) - expect(state.content).toEqual(testModel) + afterAll(async () => { + await c1Container.teardown() + }) }) From 77a924b412aa6901ec6edca2f1a59752418e981f Mon Sep 17 00:00:00 2001 From: David Estes Date: Thu, 14 Nov 2024 13:31:22 -0700 Subject: [PATCH 4/8] chore: remove build from pnpm install and modify pnpm build to actually build this seems more predictable for CI/dev --- .github/workflows/build-test.yml | 2 +- .github/workflows/integration-test.yml | 2 +- package.json | 2 +- packages/events/package.json | 1 - packages/http-client/package.json | 1 - packages/identifiers/package.json | 1 - packages/model-client/package.json | 1 - packages/model-handler/package.json | 1 - packages/model-instance-client/package.json | 1 - packages/model-instance-handler/package.json | 1 - packages/model-instance-protocol/package.json | 1 - packages/model-protocol/package.json | 1 - packages/test-utils/package.json | 1 - packages/test-vectors/package.json | 1 - 14 files changed, 3 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 45dcc0a..57a9b55 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -46,7 +46,7 @@ jobs: ${{ runner.os }}-pnpm-store- - name: Install dependencies and build - run: pnpm install --frozen-lockfile + run: pnpm install --frozen-lockfile && pnpm build - name: Lint run: pnpm run lint:ci diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index 6cefb08..8639466 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -40,7 +40,7 @@ jobs: restore-keys: pnpm-store - name: Install dependencies and build - run: pnpm install --frozen-lockfile + run: pnpm install --frozen-lockfile && pnpm build - name: Test run: cd tests/c1-integration && pnpm run test diff --git a/package.json b/package.json index 261b0c2..1db9c72 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "private": true, "packageManager": "pnpm@9.8.0", "scripts": { - "build": "pnpm --filter \"@ceramic-sdk/*\" build:types && turbo run build:js", + "build": "pnpm --filter \"@ceramic-sdk/*\" build && turbo run build:js", "docs": "typedoc", "lint": "biome check --write apps/* packages/* tests/*", "lint:ci": "biome ci packages/* tests/*", diff --git a/packages/events/package.json b/packages/events/package.json index fdb6291..cf232e7 100644 --- a/packages/events/package.json +++ b/packages/events/package.json @@ -28,7 +28,6 @@ "lint": "eslint src --fix", "test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js", "test:ci": "pnpm run test --ci --coverage", - "prepare": "pnpm build", "prepublishOnly": "package-check" }, "dependencies": { diff --git a/packages/http-client/package.json b/packages/http-client/package.json index 5dc1def..d09ce80 100644 --- a/packages/http-client/package.json +++ b/packages/http-client/package.json @@ -29,7 +29,6 @@ "lint": "eslint src --fix", "test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js", "test:ci": "pnpm run test --ci --coverage", - "prepare": "pnpm build", "prepublishOnly": "package-check" }, "dependencies": { diff --git a/packages/identifiers/package.json b/packages/identifiers/package.json index 0331a08..45a1a2f 100644 --- a/packages/identifiers/package.json +++ b/packages/identifiers/package.json @@ -28,7 +28,6 @@ "lint": "eslint src --fix", "test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js", "test:ci": "pnpm run test --ci --coverage", - "prepare": "pnpm build", "prepublishOnly": "package-check" }, "dependencies": { diff --git a/packages/model-client/package.json b/packages/model-client/package.json index 20628b8..19ca471 100644 --- a/packages/model-client/package.json +++ b/packages/model-client/package.json @@ -28,7 +28,6 @@ "lint": "eslint src --fix", "test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js", "test:ci": "pnpm run test --ci --coverage", - "prepare": "pnpm build", "prepublishOnly": "package-check" }, "dependencies": { diff --git a/packages/model-handler/package.json b/packages/model-handler/package.json index b0996a7..4ae2821 100644 --- a/packages/model-handler/package.json +++ b/packages/model-handler/package.json @@ -29,7 +29,6 @@ "lint": "eslint src --fix", "test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js", "test:ci": "pnpm run test --ci --coverage", - "prepare": "pnpm build", "prepublishOnly": "package-check" }, "dependencies": { diff --git a/packages/model-instance-client/package.json b/packages/model-instance-client/package.json index 96e6fe8..20fe56b 100644 --- a/packages/model-instance-client/package.json +++ b/packages/model-instance-client/package.json @@ -28,7 +28,6 @@ "lint": "eslint src --fix", "test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js", "test:ci": "pnpm run test --ci --coverage", - "prepare": "pnpm build", "prepublishOnly": "package-check" }, "dependencies": { diff --git a/packages/model-instance-handler/package.json b/packages/model-instance-handler/package.json index d4dff0c..fec9f3d 100644 --- a/packages/model-instance-handler/package.json +++ b/packages/model-instance-handler/package.json @@ -29,7 +29,6 @@ "lint": "eslint src --fix", "test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js", "test:ci": "pnpm run test --ci --coverage", - "prepare": "pnpm build", "prepublishOnly": "package-check" }, "dependencies": { diff --git a/packages/model-instance-protocol/package.json b/packages/model-instance-protocol/package.json index bf4861e..ef4a221 100644 --- a/packages/model-instance-protocol/package.json +++ b/packages/model-instance-protocol/package.json @@ -28,7 +28,6 @@ "lint": "eslint src --fix", "test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js", "test:ci": "pnpm run test --ci --coverage", - "prepare": "pnpm build", "prepublishOnly": "package-check" }, "dependencies": { diff --git a/packages/model-protocol/package.json b/packages/model-protocol/package.json index b26b9a5..74679ad 100644 --- a/packages/model-protocol/package.json +++ b/packages/model-protocol/package.json @@ -28,7 +28,6 @@ "lint": "eslint src --fix", "test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js", "test:ci": "pnpm run test --ci --coverage", - "prepare": "pnpm build", "prepublishOnly": "package-check" }, "dependencies": { diff --git a/packages/test-utils/package.json b/packages/test-utils/package.json index 58e4bb2..44e2458 100644 --- a/packages/test-utils/package.json +++ b/packages/test-utils/package.json @@ -28,7 +28,6 @@ "lint": "eslint src --fix", "test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js", "test:ci": "pnpm run test --ci --coverage", - "prepare": "pnpm build", "prepublishOnly": "package-check" }, "dependencies": { diff --git a/packages/test-vectors/package.json b/packages/test-vectors/package.json index fcdad25..e77e129 100644 --- a/packages/test-vectors/package.json +++ b/packages/test-vectors/package.json @@ -30,7 +30,6 @@ "lint": "eslint src --fix", "test": "node --experimental-vm-modules ../../node_modules/jest/bin/jest.js", "test:ci": "pnpm run test --ci --coverage", - "prepare": "pnpm build", "prepublishOnly": "package-check" }, "dependencies": { From e23c965b2e863489d5956ca6b257c050856c7bb9 Mon Sep 17 00:00:00 2001 From: David Estes Date: Thu, 14 Nov 2024 16:35:53 -0700 Subject: [PATCH 5/8] chore: update readme --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index cba8b1f..05d3472 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,17 @@ TypeScript client and utilities for [Ceramic One](https://github.com/ceramicnetw Other packages present in the `packages` folder are for internal use and may not be published to the npm registry. +## Development + +Getting started: + +```sh +pnpm i +pnpm build +pnpm test # run all tests (unit and integration, requires docker to be running) +pnpm test:ci # run only unit tests +``` + ## License Dual licensed under MIT and Apache 2 From 0ebdf2fc308bf2c943567e2096001b0ee338eca2 Mon Sep 17 00:00:00 2001 From: David Estes Date: Fri, 15 Nov 2024 11:59:49 -0700 Subject: [PATCH 6/8] chore: lockfile --- pnpm-lock.yaml | 135 +++++++++++++++++-------------------------------- 1 file changed, 46 insertions(+), 89 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 36873fc..657301f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -19,13 +19,13 @@ importers: version: 0.2.2 '@swc/cli': specifier: ^0.4.0 - version: 0.4.0(@swc/core@1.7.26)(chokidar@3.6.0) + version: 0.4.0(@swc/core@1.7.26(@swc/helpers@0.5.15))(chokidar@3.6.0) '@swc/core': specifier: ^1.7.24 - version: 1.7.26 + version: 1.7.26(@swc/helpers@0.5.15) '@swc/jest': specifier: ^0.2.36 - version: 0.2.36(@swc/core@1.7.26) + version: 0.2.36(@swc/core@1.7.26(@swc/helpers@0.5.15)) '@types/jest': specifier: ^29.5.13 version: 29.5.13 @@ -128,7 +128,7 @@ importers: version: 18.3.0 '@vitejs/plugin-react-swc': specifier: ^3.5.0 - version: 3.7.0(vite@5.4.6(@types/node@22.5.5)(sugarss@4.0.1(postcss@8.4.47))) + version: 3.7.0(@swc/helpers@0.5.15)(vite@5.4.6(@types/node@22.5.5)(sugarss@4.0.1(postcss@8.4.47))) postcss: specifier: ^8.4.47 version: 8.4.47 @@ -235,22 +235,6 @@ importers: specifier: ^6.0.3 version: 6.0.3 - packages/jest-environment: - dependencies: - '@ceramic-sdk/http-client': - specifier: workspace:^ - version: link:../http-client - '@databases/with-container': - specifier: ^2.1.1 - version: 2.1.1 - jest-environment-node: - specifier: ^29.7.0 - version: 29.7.0 - devDependencies: - '@jest/environment': - specifier: ^29.7.0 - version: 29.7.0 - packages/model-client: dependencies: '@ceramic-sdk/events': @@ -549,6 +533,9 @@ importers: '@ceramic-sdk/events': specifier: workspace:^ version: link:../../packages/events + '@ceramic-sdk/http-client': + specifier: workspace:^ + version: link:../../packages/http-client '@ceramic-sdk/identifiers': specifier: workspace:^ version: link:../../packages/identifiers @@ -573,10 +560,18 @@ importers: '@didtools/key-did': specifier: ^1.0.0 version: 1.0.0(typescript@5.6.2)(zod@3.23.8) - devDependencies: - jest-environment-ceramic: - specifier: workspace:^ - version: link:../../packages/jest-environment + '@jest/environment': + specifier: ^29.7.0 + version: 29.7.0 + '@types/cross-spawn': + specifier: ^6.0.0 + version: 6.0.6 + cross-spawn: + specifier: ^7.0.5 + version: 7.0.5 + modern-spawn: + specifier: ^1.0.0 + version: 1.0.0 packages: @@ -814,9 +809,6 @@ packages: cpu: [x64] os: [win32] - '@databases/with-container@2.1.1': - resolution: {integrity: sha512-iHsOn/6ElWuGpcytgNh9ZAvFd78G0ikOMWj0DtMTB4fXVqRA5uYZpLpLv/fvwL895xT7VTbVA6HV3YoY0yuQUg==} - '@didtools/cacao@3.0.1': resolution: {integrity: sha512-vV1JirxqVsBf2dqdvoS/msNN8fabvMfseZB0kf1FG8TbosrHd81+hgDOlQMZit7zJbTk5g3CGkZg3b7iYKkynw==} engines: {node: '>=14.14'} @@ -1626,6 +1618,9 @@ packages: '@swc/counter@0.1.3': resolution: {integrity: sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==} + '@swc/helpers@0.5.15': + resolution: {integrity: sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==} + '@swc/jest@0.2.36': resolution: {integrity: sha512-8X80dp81ugxs4a11z1ka43FPhP+/e+mJNXJSxiNYk8gIX/jPBtY4gQTrKu/KIoco8bzKuPI5lUxjfLiGsfvnlw==} engines: {npm: '>= 7.0.0'} @@ -1838,10 +1833,6 @@ packages: engines: {node: '>=0.4.0'} hasBin: true - address@1.2.2: - resolution: {integrity: sha512-4B/qKCfeE/ODUaAUpSwfzazo5x29WD4r3vXiWsB7I2mSDAihwEqKO+g8GELZUQSSAo5e1XTYh3ZVfLyxBc12nA==} - engines: {node: '>= 10.0.0'} - agent-base@7.1.1: resolution: {integrity: sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA==} engines: {node: '>= 14'} @@ -2129,12 +2120,8 @@ packages: cross-spawn@5.1.0: resolution: {integrity: sha512-pTgQJ5KC0d2hcY8eyL1IzlBPYjTkyH72XRZPnLyKus2mBfNjQs3klqbJU2VILqZryAZUt9JOb3h/mWMy23/f5A==} - cross-spawn@6.0.5: - resolution: {integrity: sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==} - engines: {node: '>=4.8'} - - cross-spawn@7.0.3: - resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} + cross-spawn@7.0.5: + resolution: {integrity: sha512-ZVJrKKYunU38/76t0RMOulHOnUcbU9GbpWKAOZ0mhjr7CX6FVrH+4FrAapSOekrgFQ3f/8gwMEuIft0aKq6Hug==} engines: {node: '>= 8'} cssesc@3.0.0: @@ -2221,11 +2208,6 @@ packages: detect-node-es@1.1.0: resolution: {integrity: sha512-ypdmJU/TbBby2Dxibuv7ZLW3Bs1QEmM7nHjEANfohJLvE0XVujisn1qPJcZxg+qDucsr+bP6fLD1rPS3AhJ7EQ==} - detect-port@1.6.1: - resolution: {integrity: sha512-CmnVc+Hek2egPx1PeTFVta2W78xy2K/9Rkf6cC4T59S50tVnzKj+tnx5mmx5lwvCkujZ4uRrpRSuV+IVs3f90Q==} - engines: {node: '>= 4.0.0'} - hasBin: true - devlop@1.1.0: resolution: {integrity: sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==} @@ -3013,9 +2995,6 @@ packages: resolution: {integrity: sha512-px/KnJAJZf5RuBGcfD+Sp2pAKq0ytz8j+1NehvgIGFkvtvFrDM3T8E4x/JJODXK9WZow8RRGrbA9QQ3hs+pDhA==} os: ['!win32'] - nice-try@1.0.5: - resolution: {integrity: sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==} - node-addon-api@3.2.1: resolution: {integrity: sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==} @@ -3408,10 +3387,6 @@ packages: resolution: {integrity: sha512-LJWA9kSvMolR51oDE6PN3kALBNaUdkxzAGcexw8gjMA8xr5zUqK0JiR3CgARSqanYF3Z1YHvsErb1KDgh+v7Rg==} engines: {node: '>=12'} - semver@5.7.2: - resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==} - hasBin: true - semver@6.3.1: resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==} hasBin: true @@ -3624,6 +3599,9 @@ packages: tslib@2.7.0: resolution: {integrity: sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==} + tslib@2.8.1: + resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} + tsx@4.19.0: resolution: {integrity: sha512-bV30kM7bsLZKZIOCHeMNVMJ32/LuJzLVajkQI/qf92J2Qr08ueLQvW00PUZGiuLPP760UINwupgUj8qrSCPUKg==} engines: {node: '>=18.0.0'} @@ -4226,15 +4204,6 @@ snapshots: '@biomejs/cli-win32-x64@1.9.1': optional: true - '@databases/with-container@2.1.1': - dependencies: - '@types/cross-spawn': 6.0.6 - cross-spawn: 6.0.5 - detect-port: 1.6.1 - modern-spawn: 1.0.0 - transitivePeerDependencies: - - supports-color - '@didtools/cacao@3.0.1(typescript@5.6.2)(zod@3.23.8)': dependencies: '@didtools/codecs': 3.0.0 @@ -5047,10 +5016,10 @@ snapshots: '@stablelib/wipe@1.0.1': {} - '@swc/cli@0.4.0(@swc/core@1.7.26)(chokidar@3.6.0)': + '@swc/cli@0.4.0(@swc/core@1.7.26(@swc/helpers@0.5.15))(chokidar@3.6.0)': dependencies: '@mole-inc/bin-wrapper': 8.0.1 - '@swc/core': 1.7.26 + '@swc/core': 1.7.26(@swc/helpers@0.5.15) '@swc/counter': 0.1.3 commander: 8.3.0 fast-glob: 3.3.2 @@ -5092,7 +5061,7 @@ snapshots: '@swc/core-win32-x64-msvc@1.7.26': optional: true - '@swc/core@1.7.26': + '@swc/core@1.7.26(@swc/helpers@0.5.15)': dependencies: '@swc/counter': 0.1.3 '@swc/types': 0.1.12 @@ -5107,13 +5076,19 @@ snapshots: '@swc/core-win32-arm64-msvc': 1.7.26 '@swc/core-win32-ia32-msvc': 1.7.26 '@swc/core-win32-x64-msvc': 1.7.26 + '@swc/helpers': 0.5.15 '@swc/counter@0.1.3': {} - '@swc/jest@0.2.36(@swc/core@1.7.26)': + '@swc/helpers@0.5.15': + dependencies: + tslib: 2.8.1 + optional: true + + '@swc/jest@0.2.36(@swc/core@1.7.26(@swc/helpers@0.5.15))': dependencies: '@jest/create-cache-key-function': 29.7.0 - '@swc/core': 1.7.26 + '@swc/core': 1.7.26(@swc/helpers@0.5.15) '@swc/counter': 0.1.3 jsonc-parser: 3.3.1 @@ -5320,9 +5295,9 @@ snapshots: '@ungap/structured-clone@1.2.0': {} - '@vitejs/plugin-react-swc@3.7.0(vite@5.4.6(@types/node@22.5.5)(sugarss@4.0.1(postcss@8.4.47)))': + '@vitejs/plugin-react-swc@3.7.0(@swc/helpers@0.5.15)(vite@5.4.6(@types/node@22.5.5)(sugarss@4.0.1(postcss@8.4.47)))': dependencies: - '@swc/core': 1.7.26 + '@swc/core': 1.7.26(@swc/helpers@0.5.15) vite: 5.4.6(@types/node@22.5.5)(sugarss@4.0.1(postcss@8.4.47)) transitivePeerDependencies: - '@swc/helpers' @@ -5339,8 +5314,6 @@ snapshots: acorn@8.12.1: {} - address@1.2.2: {} - agent-base@7.1.1(supports-color@9.4.0): dependencies: debug: 4.3.7(supports-color@9.4.0) @@ -5662,15 +5635,7 @@ snapshots: shebang-command: 1.2.0 which: 1.3.1 - cross-spawn@6.0.5: - dependencies: - nice-try: 1.0.5 - path-key: 2.0.1 - semver: 5.7.2 - shebang-command: 1.2.0 - which: 1.3.1 - - cross-spawn@7.0.3: + cross-spawn@7.0.5: dependencies: path-key: 3.1.1 shebang-command: 2.0.0 @@ -5741,13 +5706,6 @@ snapshots: detect-node-es@1.1.0: {} - detect-port@1.6.1: - dependencies: - address: 1.2.2 - debug: 4.3.6 - transitivePeerDependencies: - - supports-color - devlop@1.1.0: dependencies: dequal: 2.0.3 @@ -5899,7 +5857,7 @@ snapshots: execa@5.1.1: dependencies: - cross-spawn: 7.0.3 + cross-spawn: 7.0.5 get-stream: 6.0.1 human-signals: 2.1.0 is-stream: 2.0.1 @@ -6747,7 +6705,7 @@ snapshots: modern-spawn@1.0.0: dependencies: - cross-spawn: 7.0.3 + cross-spawn: 7.0.5 ms@2.1.2: {} @@ -6778,8 +6736,6 @@ snapshots: node-gyp-build: 4.8.1 optional: true - nice-try@1.0.5: {} - node-addon-api@3.2.1: optional: true @@ -7157,8 +7113,6 @@ snapshots: dependencies: semver: 7.6.3 - semver@5.7.2: {} - semver@6.3.1: {} semver@7.6.3: {} @@ -7337,6 +7291,9 @@ snapshots: tslib@2.7.0: {} + tslib@2.8.1: + optional: true + tsx@4.19.0: dependencies: esbuild: 0.23.1 From 373b2c93dc906896a690509cdb0dd79c24ff492f Mon Sep 17 00:00:00 2001 From: David Estes Date: Fri, 15 Nov 2024 12:07:43 -0700 Subject: [PATCH 7/8] chore: lint --- packages/test-vectors/test/vectors.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/test-vectors/test/vectors.test.ts b/packages/test-vectors/test/vectors.test.ts index e2347e0..c74fe70 100644 --- a/packages/test-vectors/test/vectors.test.ts +++ b/packages/test-vectors/test/vectors.test.ts @@ -26,7 +26,7 @@ import { loadCAR, } from '../src/index.ts' -const EXPECTED_EXPIRED_DATE = new Date(Date.UTC(2000, 0, 1, 0)).toISOString(); +const EXPECTED_EXPIRED_DATE = new Date(Date.UTC(2000, 0, 1, 0)).toISOString() const verifier = createDID() From a634387bbe43f7c48c06d722c4af571753d7aeee Mon Sep 17 00:00:00 2001 From: David Estes Date: Fri, 15 Nov 2024 12:24:00 -0700 Subject: [PATCH 8/8] chore: run integration tests serially avoid tooManyRequests pulling images simulteanously in CI --- tests/c1-integration/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/c1-integration/package.json b/tests/c1-integration/package.json index 27fdeb2..384f34a 100644 --- a/tests/c1-integration/package.json +++ b/tests/c1-integration/package.json @@ -16,7 +16,7 @@ "build:clean": "del dist", "build:js": "swc src -d ./dist --config-file ../../.swcrc --strip-leading-paths", "build": "pnpm build:clean && pnpm build:js", - "test": "pnpm build && node --experimental-vm-modules ../../node_modules/jest/bin/jest.js" + "test": "pnpm build && node --experimental-vm-modules ../../node_modules/jest/bin/jest.js --runInBand" }, "dependencies": { "@ceramic-sdk/events": "workspace:^",