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

alkahest-test-env

v0.0.1

Published

Test environment setup for Alkahest protocol testing

Readme

alk-test-env

A comprehensive test environment setup package for Alkahest protocol testing.

Installation

npm install alk-test-env
# or
yarn add alk-test-env
# or
bun add alk-test-env

Usage

import { setupTestEnvironment, teardownTestEnvironment } from 'alk-test-env';

// In your test files
let testContext;

beforeAll(async () => {
  testContext = await setupTestEnvironment();
});

afterAll(async () => {
  await teardownTestEnvironment(testContext);
});

// Use testContext.aliceClient, testContext.bobClient, etc. in your tests

What's Included

This package provides:

  • Complete test environment setup with Anvil (local Ethereum node)
  • Pre-deployed contracts including all Alkahest obligations, arbiters, and utilities
  • Mock tokens (ERC20, ERC721, ERC1155) for testing
  • Test accounts (Alice, Bob) with funded balances
  • Alkahest clients ready to use with both HTTP and WebSocket transports
  • Utility functions for token testing and address comparison

API

setupTestEnvironment()

Sets up a complete test environment and returns a TestContext object containing:

  • anvil: The Anvil instance
  • testClient: Extended test client with token utilities
  • alice, bob: Test account addresses
  • aliceClient, bobClient: Alkahest clients for test accounts
  • aliceClientWs, bobClientWs: WebSocket-enabled Alkahest clients
  • addresses: All deployed contract addresses
  • mockAddresses: Mock token contract addresses
  • anvilInitState: Initial blockchain state for test resets

teardownTestEnvironment(context)

Cleans up the test environment by stopping the Anvil instance.

Utility Functions

  • compareAddresses(a, b): Compare Ethereum addresses (case-insensitive)
  • createTokenTestExtension(): Create token testing extensions for viem clients

Example

import { setupTestEnvironment, teardownTestEnvironment } from 'alk-test-env';
import { parseEther } from 'viem';

describe('My Alkahest Tests', () => {
  let testContext;

  beforeAll(async () => {
    testContext = await setupTestEnvironment();
  });

  afterAll(async () => {
    await teardownTestEnvironment(testContext);
  });

  test('should create an ERC20 escrow', async () => {
    const { aliceClient, bobClient, mockAddresses } = testContext;
    
    // Alice creates an escrow to trade her ERC20 tokens
    const { attested } = await aliceClient.erc20.permitAndBuyWithErc20(
      {
        address: mockAddresses.erc20A,
        value: parseEther('100'),
      },
      {
        arbiter: testContext.addresses.trivialArbiter,
        demand: '0x',
      },
      0n, // no expiration
    );

    expect(attested.uid).toBeDefined();
  });
});

Dependencies

This package depends on:

  • alkahest-ts: The main Alkahest protocol client
  • @viem/anvil: Local Ethereum node for testing
  • viem: Ethereum client library

License

MIT