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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@archethicjs/ae-contract-test

v1.0.14

Published

Testing suite for WebAssembly smart contract for Archethic Public Blockchain.

Readme

ae-contract-test

Testing suite for WebAssembly smart contract for Archethic Public Blockchain.

The framework simplifies the WASM execution environement by simulating the interaction in/out between WASM and the host application.

Features

  • Call abstraction: call WASM method as Javascript function call
  • Ease of mocking: Simplify I/O mock function call (i.e Chain request, HTTP, etc.)
  • Lifecycle abstraction: Simulate contract deployment and upgrade
  • Account mangement: Direct interaction with wallet & network to ease testing & deployment

Getting Started

Prerequisites

  • Node.js
  • npm

Installation

npm install @archethicjs/ae-contract-test

Usage

  1. Configure the environement

Create archethic.config.js file to define configuration for account & network interaction:

{
   endpoint: 'https://testnet.archethic.net',
   seed: 'PRIVATE_SEED',
   upgradeAddress: 'Address allowed to make code upgrade'
}
  1. Write a test

Create a file in tests/index.spec.ts

import { readFileSync } from "fs";
import { getContract } from "@archethic/contract-testing";
import { Balance } from "@archethic/as-contract-sdk";
import { Address, Result, Transaction, TransactionType } from "@archethic/contract-testing/types";

describe("init", () => {
  it("should deploy the contract and initialize the state", async () => {
    const wasmBuffer = readFileSync("./dist/contract.wasm");

    const contract = await getContract(wasmBuffer, {
      transaction: {
        data: {
          content: "5",
        },
      } as Transaction
    });
    expect(contract.state).toStrictEqual({ counter: 25 });
  });
});

describe("onUpgrade", () => {
  it("should mutate the contract's state with new contract logic", async () => {
    const wasmBuffer = readFileSync("./dist/contract.wasm");
    const contract = await getContract(wasmBuffer);
    expect(contract.state.counter).toBe(0);
    const newContract = await contract.upgrade(wasmBuffer);
    expect(newContract.state.counter).toBe(10);
  });
});

describe("inc", () => {
  it("should increment without state", async () => {
    const wasmBuffer = readFileSync("./dist/contract.wasm");
    const contract = await getContract(wasmBuffer);
    const result = contract.inc({ value: 2 });
    expect(result?.state.counter).toBe(2);
  });

  it("should increment with state", async () => {
    const wasmBuffer = readFileSync("./dist/contract.wasm");
    const contract = await getContract(wasmBuffer);

    const result = contract.inc({ state: { counter: 2 } });
    expect(result?.state.counter).toBe(3);
  });

  it("should raise an error when the state is negative", async () => {
    const wasmBuffer = readFileSync("./dist/contract.wasm");
    const contract = await getContract(wasmBuffer);
    expect(() => {
      contract.inc({ state: { counter: -2 } });
    }).toThrow("state cannot be negative");
  });
});

Development

The test framework used several modules:

  • accounts: Manage accounts and interaction with wallet
  • config: Manage test configuration
  • connection: Manage blockchain connection
  • contract_factory: Abstract WASM contract instance & function calls

Contribution

Thank you for considering to help out with the source code. We welcome contributions from anyone and are grateful for even the smallest of improvement.

Please to follow this workflow:

  1. Fork it!
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Licence

AGPL