Skip to content

Commit

Permalink
chore: setup test
Browse files Browse the repository at this point in the history
  • Loading branch information
Gozala committed Apr 2, 2024
1 parent 6fa7797 commit eaf2453
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
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

0 comments on commit eaf2453

Please sign in to comment.