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

@sovereign-sdk/test

v0.1.13

Published

Testing utilities for Sovereign SDK rollups, including soak testing and transaction generation.

Readme

@sovereign-sdk/test

Testing utilities for Sovereign SDK rollups, including soak testing and transaction generation.

Installation

npm install @sovereign-sdk/test

Usage

The package provides utilities for testing Sovereign SDK rollups, with a focus on soak testing and transaction generation. Soak testing helps verify the stability and performance of your rollup under sustained load by continuously submitting transactions.

Note: Currently, soak tests require a pre-started rollup node to run against. In a future version, we plan to add functionality to manage the rollup process lifecycle (starting, stopping, and monitoring the node) as part of the test framework.

Transaction Generators

Transaction generators are responsible for creating individual test transactions. They implement the TransactionGenerator interface:

import { TransactionGenerator } from "@sovereign-sdk/test/soak";

class MyTransactionGenerator implements TransactionGenerator<YourTypeSpec> {
  async successful(): Promise<GeneratedInput<YourTypeSpec>> {
    // Create a transaction that should succeed
    const unsignedTransaction = {
      // Your transaction details
    };

    const signer = await getSigner();

    return {
      unsignedTransaction,
      signer,
      onSubmitted: async (result) => {
        // Verify transaction results
        // Check events
        // Validate state changes
      },
    };
  }

  async failure(): Promise<GeneratedInput<YourTypeSpec>> {
    // Create a transaction that should fail
    const unsignedTransaction = {
      // Your invalid transaction details
    };

    const signer = await getSigner();

    return {
      unsignedTransaction,
      signer,
      onSubmitted: async (result) => {
        // Verify the transaction failed as expected
        // Check error messages
        // Validate state remains unchanged
      },
    };
  }
}

Generator Strategies

Generator strategies determine how multiple transactions are generated and executed. The package provides a BasicGeneratorStrategy that generates a fixed number of successful transactions:

import { BasicGeneratorStrategy } from "@sovereign-sdk/test/soak";

const generator = new MyTransactionGenerator();
const strategy = new BasicGeneratorStrategy(generator);

// Generate 100 transactions
const transactions = await strategy.generate(100);

You can also create custom strategies by implementing the GeneratorStrategy interface:

import { GeneratorStrategy, Outcome } from "@sovereign-sdk/test/soak";

class CustomStrategy implements GeneratorStrategy<YourTypeSpec> {
  private readonly generators: TransactionGenerator<YourTypeSpec>[];

  constructor(generators: TransactionGenerator<YourTypeSpec>[]) {
    this.generators = generators;
  }

  async generate(amount: number): Promise<InputWithExpectation<YourTypeSpec>[]> {
    const transactions = [];

    for (let i = 0; i < amount; i++) {
      // Choose a generator based on your strategy
      const generator = this.selectGenerator();
      const transaction = await generator.successful();
      transactions.push({
        input: transaction,
        expectedOutcome: Outcome.Success
      });
    }

    return transactions;
  }

  private selectGenerator(): TransactionGenerator<YourTypeSpec> {
    // Implement your selection logic
    return this.generators[Math.floor(Math.random() * this.generators.length)];
  }
}

Running Soak Tests

To run a soak test, create a test runner with your strategy:

import { TestRunner } from "@sovereign-sdk/test/soak";

const rollup = await createStandardRollup<YourTypeSpec>({
  context: { defaultTxDetails },
});

const strategy = new YourStrategy();
const runner = new TestRunner<S>({
  rollup,
  generator: strategy,
  concurrency: 30, // Adjust based on your needs
});

// Start the test
await runner.run();

// Stop when needed
await runner.stop();

Note: The current API requires manual management of the test runner lifecycle (start/stop). In a future version, we plan to simplify this by handling the lifecycle internally, so users won't need to manage these operations in their code.

Example

See the soak-testing example for a complete implementation of a bank transfer soak test.

API Reference

TransactionGenerator

Interface for generating individual test transactions.

abstract class TransactionGenerator<S extends BaseTypeSpec> {
  abstract successful(): Promise<GeneratedInput<S>>;
  abstract failure(): Promise<GeneratedInput<S>>;
}

GeneratorStrategy

Interface for generating batches of test transactions.

interface GeneratorStrategy<S extends BaseTypeSpec> {
  generate(amount: number): Promise<InputWithExpectation<S>[]>;
}

TestRunner

Class for running soak tests.

class TestRunner<S extends BaseTypeSpec> {
  constructor(options: {
    rollup: StandardRollup<S>;
    generator: GeneratorStrategy<S>;
    concurrency: number;
  });

  run(): Promise<void>;
  stop(): Promise<void>;
}