npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@attocash/commons-test

v6.7.1-patch.1

Published

Test utilities and mock Atto node and worker services for JavaScript and TypeScript integrations.

Readme

@attocash/commons-test

npm version license

Test utilities for Atto JavaScript and TypeScript integrations.

@attocash/commons-test provides local mock services for applications that use the individual Atto Commons JavaScript packages. It starts a real Atto node container with a MySQL container and a real Work Server container, then exposes their mapped URLs so your tests can use the normal node, worker, wallet, and monitor clients.

Install

npm install --save-dev @attocash/commons-test
npm install @attocash/commons-core @attocash/commons-node @attocash/commons-node-remote
npm install @attocash/commons-worker @attocash/commons-worker-remote @attocash/commons-wallet

This package is published as ESM and includes TypeScript declarations.

Requirements

  • Node.js 18 or newer is recommended.
  • Docker or Podman must be installed and running.
  • The test process must be allowed to pull and run containers.
  • Use ESM imports. In Node.js files, use .mjs or set "type": "module".

Node.js examples that use the Atto clients should expose require for the underlying runtime:

import {createRequire} from 'node:module'

globalThis.require = createRequire(import.meta.url)

What It Provides

  • AttoNodeMockAsyncBuilder: starts a local Atto node backed by MySQL.
  • AttoWorkerMockAsyncBuilder: starts a local Work Server.
  • baseUrl properties that plug directly into AttoNodeClientAsyncBuilder and AttoWorkerAsyncBuilder.
  • A generated local genesis transaction so tests can start with a funded account.
  • Builder options for container names, images, MySQL settings, and custom genesis transactions.

Quick Example

import {createRequire} from 'node:module'
import {
  AttoAmount,
  AttoMnemonic,
  AttoUnit,
  toAttoIndex,
  toPrivateKey,
  toSeedAsync,
} from '@attocash/commons-core'
import {AttoNodeClientAsyncBuilder} from '@attocash/commons-node-remote'
import {AttoWorkerAsyncBuilder} from '@attocash/commons-worker-remote'
import {AttoWalletAsyncBuilder} from '@attocash/commons-wallet'
import {
  AttoNodeMockAsyncBuilder,
  AttoWorkerMockAsyncBuilder,
} from '@attocash/commons-test'

globalThis.require = createRequire(import.meta.url)

const mnemonic = AttoMnemonic.generate()
const seed = await toSeedAsync(mnemonic)
const genesisPrivateKey = toPrivateKey(seed, toAttoIndex(0))

const nodeMock = await new AttoNodeMockAsyncBuilder(genesisPrivateKey).build()
const workerMock = await new AttoWorkerMockAsyncBuilder().build()

try {
  await nodeMock.start()
  await workerMock.start()

  const nodeClient = new AttoNodeClientAsyncBuilder(nodeMock.baseUrl).build()
  const worker = new AttoWorkerAsyncBuilder(workerMock.baseUrl).build()

  const wallet = new AttoWalletAsyncBuilder(nodeClient, worker)
    .signerProviderSeed(seed)
    .build()

  const sender = toAttoIndex(0)
  const receiver = toAttoIndex(1)

  await wallet.openAccount(sender)
  await wallet.openAccount(receiver)

  const receiverAddress = await wallet.getAddress(receiver)
  const amount = AttoAmount.from(AttoUnit.ATTO, '1')
  const transaction = await wallet.sendByIndex(sender, receiverAddress, amount, null)

  console.log(`Published ${transaction.hash}`)
} finally {
  nodeMock.close()
  workerMock.close()
}

Custom Images and Names

Use builder methods when a test suite needs pinned images, isolated container names, or custom MySQL settings.

const nodeMock = await new AttoNodeMockAsyncBuilder(genesisPrivateKey)
  .name('atto-node-test')
  .image('ghcr.io/attocash/node:live')
  .mysqlImage('mysql:8.4')
  .dbName('node')
  .dbUser('root')
  .dbPassword('root')
  .build()

const workerMock = await new AttoWorkerMockAsyncBuilder()
  .name('atto-worker-test')
  .image('ghcr.io/attocash/work-server:cpu')
  .build()

Lifecycle

Always close mocks in finally or your test framework's teardown hook.

let nodeMock
let workerMock

beforeAll(async () => {
  nodeMock = await new AttoNodeMockAsyncBuilder(genesisPrivateKey).build()
  workerMock = await new AttoWorkerMockAsyncBuilder().build()

  await nodeMock.start()
  await workerMock.start()
})

afterAll(() => {
  nodeMock?.close()
  workerMock?.close()
})

baseUrl is available only after start() has completed.

Full Example

The repository includes a runnable JavaScript example that uses @attocash/commons-test with the individual Atto Commons packages to start mock services, create a wallet, open accounts, send transactions, and listen to monitors:

API Summary

| Export | Purpose | |------------------------------|-------------------------------------------------------------------------------| | AttoNodeMockAsyncBuilder | Builds a node mock backed by an Atto node container and a MySQL container. | | AttoNodeMockAsync | Starts, closes, and exposes the node mock baseUrl and genesisTransaction. | | AttoWorkerMockAsyncBuilder | Builds a Work Server mock container. | | AttoWorkerMockAsync | Starts, closes, and exposes the worker mock baseUrl. | | AttoNodeMockConfiguration | Configuration object for lower-level Kotlin/JVM use. |

Documentation

License

BSD 3-Clause