Quality assurance

How to Test Web3 Applications

A QA playbook covering wallets, networks, transactions, contracts and failure paths, with scenarios you can reuse.

By the Kensaltensi team · Last updated 27 October 2026 · 7 min read

Testing a Web3 application is not simply web testing with an extra login step. The runtime is partly outside your control, actions are irreversible, and the user's own wallet is part of the system under test. A bug in a typical web app is annoying and fixable; a bug in a contract that holds funds can be permanent. This guide sets out a layered approach and a set of reusable scenarios, so a QA team can build coverage that matches the real risks.

Start with a risk-based test strategy

Because you cannot test everything, rank features by impact and irreversibility. A rough ordering that works for most dApps:

  1. Value and permissions: anything that moves assets, grants approvals, or changes who can do what.
  2. Data integrity: amounts, balances, decimals and what the UI displays versus what is on-chain.
  3. Transaction flow: the full path from click to confirmation, including failure and recovery.
  4. Infrastructure behaviour: RPC failures, indexer lag, network switching.
  5. Everything else: layout, copy, accessibility, performance and ordinary web functionality.

The test layers

LayerPurposeTypical tools
Contract unit testsVerify each function, permission and revert conditionFoundry, Hardhat
Fuzz and invariant testsCheck properties that must always hold, using random inputs and sequencesFoundry, Echidna
Fork testsRun against a copy of real chain state to test interactions with existing contractsFoundry (anvil), Hardhat network forking
Front-end component and E2E testsCheck UI states against a controllable wallet and chainPlaywright, Cypress, with a mocked or scripted provider
Integration and staging on a testnetValidate real wallets, latency, deployment and configurationPublic testnet, faucets, real browser wallets
Non-functionalSecurity, performance under RPC latency, accessibility, monitoringStatic analysers, load tools, axe, alerts

The wallet and network state matrix

The user's wallet can be in many states before your code even runs, and your interface must behave sensibly in each. Build a matrix and test every row:

Wallet stateExpected behaviour
No wallet installedClear explanation with install or alternative-connection options, not a blank page or console error
Wallet installed but lockedConnect prompts for unlock; app does not assume an account exists
Connected, wrong networkExplains which network is needed and offers a switch; blocks transactions until corrected
User switches account mid-sessionApp detects the change, refreshes state and clears anything tied to the previous address
User switches network mid-flowIn-flight flow is cancelled or revalidated; no stale transaction is sent to the wrong chain
User rejects connection or signatureNeutral message, easy retry, no error logged as a failure
Multiple wallets installedCorrect provider chosen; no conflict between extensions
Mobile wallet via deep link or QRSession survives app switching; return path to the browser works

Transaction scenarios

For every action that sends a transaction, cover these cases. They map directly to the lifecycle described in our architecture guide.

  • Happy path: submitted, pending, confirmed. The UI shows each state and the final data matches the chain.
  • Revert: the contract rejects the call. The UI shows a meaningful reason where available and does not claim success.
  • Insufficient funds: not enough native currency for gas, and not enough token balance. Messages differ and both must be clear.
  • Allowance flow: for tokens, the approve step and the action step each succeed, fail or are abandoned independently. Test approve-then-leave and approve-then-change-amount.
  • Pending for a long time: low fee leaves the transaction waiting. The UI should still be usable and offer speed-up or cancel where supported.
  • Dropped or replaced: the transaction vanishes or is replaced by another with the same nonce. The app must not hang forever.
  • Double submission: double click, page refresh during a pending transaction, two browser tabs. No duplicate sends and a sensible recovered state.
  • Reload after sending: if the user refreshes, the app should rediscover the pending or completed transaction rather than losing track of it.
  • Indexer lag: the chain has the update but your API does not yet. The UI should either wait with a clear indicator or reflect the pending change optimistically and reconcile.

Data accuracy tests

A surprising share of serious bugs are numeric. Test amounts as exact integers in the smallest unit, and confirm display formatting separately.

  • Values that exceed the safe integer range of the language (for example 18-decimal amounts above roughly nine quadrillion units).
  • Tokens with different decimals (6, 8, 18) in the same screen.
  • Rounding at display boundaries, such as 0.0000001 tokens, and the maximum or "use all" button.
  • Large and small numbers in different locales, including comma and period decimal separators.
  • Mixed-case and checksummed addresses compare equal, and truncated addresses in the UI still link to the full one.

Testing the contracts themselves

Contract tests should be written alongside the code and should include permission and failure cases, not just success. Beyond hand-written examples, fuzz testing runs a function with many random inputs and checks a property. This example, using the guest-book contract from our smart contracts guide, asserts that signing always increments the counter and records the message:

// Foundry: property-style test with random inputs
function testFuzz_signIncrementsCount(string calldata message) public {
    vm.assume(bytes(message).length > 0);
    uint256 before = book.entryCount();

    vm.prank(alice);
    book.sign(message);

    assertEq(book.entryCount(), before + 1);
    assertEq(book.lastMessage(alice), message);
}

function test_RevertWhen_NonOwnerResets() public {
    vm.prank(alice);
    vm.expectRevert(GuestBook.NotOwner.selector);
    book.reset();
}

Invariant tests go further: they call random sequences of functions and check that a rule always holds, for example "the sum of all balances equals the total supply" or "the contract can never hold less than it owes". These tests often find bugs that example-based tests miss. Run tests on a fork of the real network whenever your contract interacts with existing protocols or tokens, so you test against real behaviour rather than a simplified mock. Fork environments also let you impersonate accounts and move time forward, which makes it possible to test vesting, cool-down periods and expiry without waiting.

Automating the front end

Real browser wallets are slow and hard to automate, so for most end-to-end tests it is better to inject a controllable provider. The following Playwright test replaces window.ethereum before the page loads and simulates the user rejecting a transaction, which is one of the most frequently mishandled states:

// playwright test: inject a controllable wallet before the page loads
import { test, expect } from "@playwright/test";

test("shows a friendly message when the user rejects the signature", async ({ page }) => {
  await page.addInitScript(() => {
    window.ethereum = {
      isMetaMask: true,
      request: async ({ method }) => {
        if (method === "eth_requestAccounts") return ["0xAb5801a7D398351b8bE11C439e05C5B3259aeC9B"];
        if (method === "eth_chainId") return "0xaa36a7";               // Sepolia
        if (method === "eth_sendTransaction") {
          const err = new Error("User rejected the request.");
          err.code = 4001;                                             // EIP-1193 user rejection
          throw err;
        }
        throw new Error("Unmocked method: " + method);
      },
      on: () => {},
      removeListener: () => {},
    };
  });

  await page.goto("/");
  await page.getByRole("button", { name: "Connect wallet" }).click();
  await page.getByRole("button", { name: "Sign guest book" }).click();

  await expect(page.getByText("You cancelled the request")).toBeVisible();
  await expect(page.getByText("Transaction failed")).toHaveCount(0);   // rejection is not an error
});

Use the same technique to simulate a wrong network (return a different chain ID), a slow response, or an RPC error. Reserve true wallet-in-the-loop automation and a short scripted manual pass for the final testnet staging run, where you verify that real wallets and real latency behave as expected.

Non-functional testing

  • Performance: measure page behaviour with slow or failing RPC responses, not just a fast local node. Check how many RPC calls a page makes on load.
  • Security: run static analysis on contracts, review signature requests for clarity (users should be able to understand what they are signing), and check that no secret keys or provider API keys appear in front-end bundles.
  • Accessibility: wallet modals, transaction status messages and error banners must be reachable by keyboard and announced by screen readers.
  • Observability: verify that alerts fire for indexer lag, a dropping RPC success rate, and failed transactions from backend senders.

A bug-report template that engineers can use

Blockchain bugs are hard to reproduce without the right details. Ask testers to include:

  • Network and chain ID, and whether it was a testnet, fork or mainnet
  • Wallet type and version, and browser or device
  • Wallet address involved (testnet only for shared tickets)
  • Transaction hash, block number and the explorer link
  • Exact steps, including any prior approvals or state
  • Expected versus actual, and a screenshot or recording
  • Whether the contract state, the indexer or only the UI is wrong

Release exit criteria

Before a release that touches contracts or value flows, you should be able to answer yes to each of these: all failure-path scenarios above pass; fuzz and invariant tests ran for a meaningful number of iterations; fork tests cover every external protocol dependency; the testnet deployment matches the planned mainnet configuration; and there is a rehearsed plan for pausing or rolling back the feature if something goes wrong.

Key takeaways

  • Test the failure paths first. Rejection, wrong network, reverts and dropped transactions are normal events in Web3.
  • Use layers: contract unit and fuzz tests, fork-based integration tests, front-end tests with a controllable provider, then staging on a testnet.
  • Money-handling code needs exact-arithmetic tests with large values, different decimals and rounding boundaries.
  • Record transaction hash, network, address and block number in every bug report so engineers can reproduce it.
  • Automate what is deterministic; keep a short, scripted manual pass with real wallets on a testnet for each release.

Related guides

Further reading

About this guide. Written by the Kensaltensi engineering and QA team for educational purposes. Examples are illustrative, and standards evolve, so check the primary sources above before relying on a detail in production. If you spot an error or an out-of-date statement, email hello@kensaltensi.org and we will review and correct it.