Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: setup test #1353

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions packages/w3up-client/test/memuse.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import * as Test from './test.js'
import * as Result from '../src/result.js'
import { randomCAR } from './helpers/random.js'

/**
* @type {Test.Suite}
*/
export const testMem = {
'test usage': async (
assert,
{ client, mail, connect, grantAccess, plansStorage }
) => {
const space = await client.createSpace('test')

const email = '[email protected]'
const login = client.login(email)
const message = await mail.take()
assert.deepEqual(message.to, email)
await grantAccess(message)
const account = await login

Result.try(await account.provision(space.did()))
await space.save()

const car = await randomCAR(50_000_000)
const before = process.memoryUsage()
console.log(before)

// @ts-expect-error
const link = await client.uploadCAR(car, { pieceHasher: null })

const after = process.memoryUsage()

console.log({
rss: after.rss - before.rss,
heapTotal: after.heapTotal - before.heapTotal,
heapUsed: after.heapUsed - before.heapUsed,
external: after.external - before.external,
arrayBuffers: after.arrayBuffers - before.arrayBuffers,
})
},
}

Test.test({ MemoryUse: testMem })
2 changes: 2 additions & 0 deletions packages/w3up-client/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { StoreMemory } from '@web3-storage/access/stores/store-memory'
import * as Context from '@web3-storage/upload-api/test/context'
import * as Client from '@web3-storage/w3up-client'
import * as assert from 'assert'
import * as http from 'http'

/**
* @typedef {Omit<typeof assert, 'ok'> & {ok(value:unknown, message?:string):void}} Assert
Expand Down Expand Up @@ -33,6 +34,7 @@ export const test = (suite) => {

export const setup = async () => {
const context = await Context.createContext({
http,
assert,
})

Expand Down
Loading