Skip to content

Latest commit

 

History

History
343 lines (253 loc) · 128 KB

testing.md

File metadata and controls

343 lines (253 loc) · 128 KB

Testing

Audience: Contributors writing or running tests.

Status: every layer below exists: the signing core's unit tests, each adapter's tests in its package, the network hook's integration tests, the deploy tests with hardhat-viem, hardhat-ethers and Ignition, the task tests, and the live tests on Sepolia with their transaction matrix.

Testing strategy

Tests form a pyramid. The lower layers are fast and pure; the upper layers exercise real SDKs and real chains.

  1. Unit tests for pure crypto:
    • Vectors for SPKI DER/PEM, JWK with stripped zeros, the wrong curve, and DER strictness.
    • fast-check properties: high-S and low-S DER both normalise and recover to the address; parsing random bytes never succeeds silently; JWK and SPKI encodings convert back and forth without loss.
    • CRC32C vectors.
    • The vendored EIP-712 code checked against the package's verifyTyped.
  2. Unit tests for the signer and adapters:
    • Injected fake SDK clients sign with a local key and return the exact wire formats: AWS SPKI + DER; GCP PEM + DER + CRC (including corrupted CRCs); Azure JWK + r‖s.
    • Assertions on request parameters: MessageType: DIGEST, the ARN taken from GetPublicKey, ES256K with the versioned id, the GCP call options.
    • A fake adapter that returns a signature from the wrong key, and an address-pin mismatch.
    • The adapter's signTransaction (packages/hardhat-kms/test/unit/signer/sign-transaction.test.ts, packages/hardhat-kms/test/unit/viem/sign-transaction-method.test.ts), with the fake in packages/hardhat-kms/test/helpers/fake-tx-adapter.ts, which hashes the unsigned bytes it receives as a parsing service does. For types 0, 1, 2 and 4, through the RPC path and the library account, it gets the core's unsigned bytes, their digest, the type number and the chain id, never signDigest, and the result equals Hardhat's and viem's bytes. A hostile one that signs another body (the same transaction with value raised by one), signs with another key, returns an out-of-range r, or signs bytes it overwrote is refused after the fresh attempt, which also goes through signTransaction, and no nonce is noted; a high-S one is normalized; one that overwrites its copies after signing changes nothing. An adapter without the method signs the same transactions through signDigest.
    • An AbortSignal timeout, driven by an injected clock. The system timers' cancel is checked with Node's mock timers, so no test waits on the clock for it.
    • The signer's debug lines (packages/hardhat-kms/test/unit/signer/debug-log.test.ts): each provider call with its request id and duration, the derived address, the reason for asking for a fresh signature, the adapter method each signature goes to, and the cache's close. A logger reads DEBUG when it is created, so the test sets it before it imports the signer modules. The core's debug-log tests read their lines with test/helpers/debug-lines.ts, which drops the time since the previous line that the logger adds at the end (+12ms, or +-13ms when the clock steps back), so a test never compares it (#525).
    • The signer cache (packages/hardhat-kms/test/unit/signer/key-cache.test.ts): one signer per key, copies of an AWS, Google Cloud or Azure key sharing one signer, a separate signer for keys that differ only in the key id, profile (also for an ARN), region, endpoint, address, timeoutMs, displayId, name, provider, Azure key or vault, and for two configuration variables that hold the same value, one variable name with a different format or default, or a Google Cloud key whose parts differ in one part's format, one signer for copies of a variable with the same format and default, a variable's default absent from the identifier's printed and serialized forms, per-object signers for third-party keys, no identifier read before the provider plugin's error, an unreadable identifier read once by the adapter and again on the next request, a signer created after the last connection closed still closed once by the idle timer, a shared signer kept open until the last connection closes and then closed once, failures not kept, an adapter closed when the signer refuses it, status messages sent to the display it was given, the idle close after the last connection and re-creation on next use, driven by injected timers. packages/hardhat-kms/test/integration/kms-hook-contract.test.ts checks that an adapter refused by the contract check is closed too.
    • Bounded GCP CRC retries, and the Azure managed identity timeout.
    • The AWS adapter's tests are in packages/hardhat-kms-aws/test/unit/adapter.test.ts, with the fake SDK in packages/hardhat-kms-aws/test/helpers/fake-aws-kms.ts.
    • The Azure adapter's tests are in packages/hardhat-kms-azure/test/unit/adapter.test.ts, with the fake SDK in packages/hardhat-kms-azure/test/helpers/fake-key-vault.ts. They cover EC and EC-HSM JWKs, coordinates without leading zeros, wrong key types and curves, disabled, expired and not-yet-valid keys, a lookup or sign response whose kid names another vault, key or version, a signature of the wrong length, and the errors for 401, 403, 404 and a missing credential. packages/hardhat-kms-azure/test/unit/credential.test.ts checks the credential chain's order, the managed identity timeouts, the managed identity left out where it refuses a client id, and the token sharing, with a fake @azure/identity. packages/hardhat-kms-azure/test/integration/managed-identity-exit.test.ts runs the real chain in a child process with no az or azd on PATH and AZURE_POD_IDENTITY_AUTHORITY_HOST pointing at a local endpoint that accepts connections and never answers, and fails unless the process exits on its own within 25 seconds. packages/hardhat-kms-azure/test/unit/history.test.ts checks the kms history reader against a fake query call, with KeySign rows recorded from a real workspace and every id replaced (packages/hardhat-kms-azure/test/fixtures/log-analytics-rows.ts). It covers the mapping of each field; a refused request that Key Vault logs with ResultType Success and HTTP 400; the principal of a user, a user with only an object id and an application, told apart by idtyp or scp; a row whose Id is empty; the exact KQL query; a range filter; truncation counted from the rows returned; the refusals for a missing or malformed kms.audit.azure.workspaceId, Managed HSM and other clouds; the answers for a missing table, 400, 401, 403, 404, 429, 5xx and a partial result; unreadable answers; credential and network errors; and the signal. For KQL injection, it builds the reader on hostile key ids (quotes, backslashes, |, newlines, percent-encoding, ports, user info, other hosts and paths) and checks that each fails before any query, and, for the key ids it accepts, that the query's h"…" literals are exactly the checked host and key name and that the rest of the query is fixed.
    • The Google Cloud adapter's tests are in packages/hardhat-kms-gcp/test/unit/adapter.test.ts, with the fake SDK in packages/hardhat-kms-gcp/test/helpers/fake-gcp-kms.ts. Like Cloud KMS, the fake confirms verifiedDigestCrc32c only when the digestCrc32c it receives matches the digest. The tests corrupt or drop each of pemCrc32c, verifiedDigestCrc32c and signatureCrc32c: two bad answers are retried and pass, a persistent fault fails after four attempts, and an aborted call stops retrying. They also cover a response for another key version, for a version that has the configured one as a prefix, or with an empty or no name (no retry), a digest refused with INVALID_ARGUMENT, UNAVAILABLE with and without a network cause (retried after a pause that an abort ends), a wrong algorithm, the gax timeout with retry: null, the client's fallback: true and its google-gax, and the message for each gRPC status, which never repeats the server's text. packages/hardhat-kms-gcp/test/unit/wire.test.ts covers the Int64Value forms and status codes. The kms history reader's tests are in packages/hardhat-kms-gcp/test/unit/history.test.ts, with masked Cloud Audit Logs entries recorded from a live project in packages/hardhat-kms-gcp/test/fixtures/logging-entries.ts: the mapping of each field, the digest forms, the filter and its escaping, a project named by its number, paging, truncation, the scan budget on a fake clock, throttling, refused reads and the signal. packages/hardhat-kms-gcp/test/integration/history.test.ts runs kms history through the plugin, with the real google-auth-library call against a local Cloud Logging endpoint (test/helpers/logging-server.ts), and checks an abort before the request body is sent, which crashes the process unless the body stream has an error listener. Its sdk-loading.test.ts also checks that kms address on a Google Cloud key loads neither the history reader nor its Cloud Logging call.
  3. Byte equivalence:
    • A deterministic fake backend (RFC6979 with Hardhat's test key) must produce raw transactions and signatures byte-identical to Hardhat's local-accounts.ts vectors: legacy, 2930, 1559, 7702, eth_sign, personal_sign, 712.
    • Differential checks against viem signTransaction and ethers Wallet.signTransaction.
    • The differential fill test described under Transaction filling, run against the Hardhat floor and latest. pnpm run test:hardhat-versions (scripts/test-hardhat-versions.ts) runs two test files, transaction-filler.test.ts and network-hook.test.ts, on the floor of the hardhat peer range and on the newest 3.x release that is at least a day old (or older than minimumReleaseAge, if the project sets one). The one-day hold is deliberate: pnpm's built-in default would install a younger release and add it to minimumReleaseAgeExclude, which this repository never does, so a younger release is held back and tested by the next weekly run. For each version the script sets the hardhat catalog entry in pnpm-workspace.yaml, installs, checks that hardhat-kms resolves it, builds, typechecks and runs the tests, then restores pnpm-workspace.yaml and the lockfile, also on Ctrl-C. A failure names the Hardhat version and the stage that failed (install, build, typecheck or tests); a failing fill test names the fill step. The hardhat-versions.yml workflow runs it weekly, on demand, and on pull requests that change the paths listed in that workflow; it is not a required check.
    • The core's own Hardhat libraries at their floors. pnpm run test:library-floors (scripts/test-library-floors.ts) reads the ranges of @nomicfoundation/hardhat-utils, hardhat-errors and hardhat-zod-utils in the core's package.json, with one floor per major (floorsOf in scripts/version-range.ts: ^4.3.0 || ^5.0.0 gives 4.3.0 and 5.0.0). The first run installs every library's first floor; each further floor gets its own run, with the other libraries at their first floor. A run adds the floors to the core only, as exact versions, so Hardhat and other plugins keep their own copies, as in a user's project. It checks that the core resolves each floor, builds, typechecks the core and its tests, and runs its unit and integration tests, the differential test included, then restores the core's package.json and the lockfile, also on Ctrl-C. The library-floors job of sdk-floors.yml runs it on the workflow's paths, which include the manifests and the lockfile but not the core's source, since nearly every core directory imports these libraries; the release gate requires every job of that workflow on the tagged commit, and dispatches it there when no run exists, so a source change that breaks a floor is caught before the release. If a floor fails, raise it in the same pull request to a version that passes; hardhat-zod-utils starts at 3.0.7: earlier releases have no type in the request schema that kms sign-tx and the filler read. A run adds the floors to the core only, so the hardhat-utils copy that hardhat-zod-utils and hardhat-errors resolve comes from the lockfile; with hardhat-zod-utils 3.0.7 that copy is hardhat-utils 4, which reads "0x" as one zero byte, and the core decodes request data itself for that reason (#614).
  4. Integration tests on a real HRE with edr-simulated and a fake adapter registered through the kms hook:
    • The network hook (packages/hardhat-kms/test/integration/network-hook.test.ts), on an edr-simulated network and an unreachable http network: account listing (own accounts first, pinned addresses without a KMS call, duplicates listed once, KMS addresses only when the downstream call fails); personal_sign, eth_sign and eth_signTypedData_v4 matching Hardhat's local-account vectors; pass-through for other addresses and methods; strict hex and malformed typed data refused before any KMS call; transactions from KMS accounts refused; adapter-creation errors reduced to the error class; two keys for the same account refused; the default-network warning printed once; networks without KMS keys left alone.

    • Override connections (packages/hardhat-kms/test/integration/override-connection.test.ts), with a fake AWS adapter that counts getPublicKey: a plain connection and an override: { timeout } connection to one network get new key objects from Hardhat, sign with one adapter and one getPublicKey call; an override that changes the key's profile gets its own adapter; a key whose configuration variable is unset fails with the same error as creating its adapter directly, and works on the next request once the variable is set.

    • Unknown accounts (packages/hardhat-kms/test/integration/unknown-account.test.ts): eth_sendTransaction, personal_sign and eth_sign from an address that is neither a KMS account nor a local account fail with the KMS address appended, on an edr-simulated network (ProviderError, -32000), on an http network with local accounts (Hardhat's HHE716, whose formattedMessage carries the list for the CLI), on an http network without them (the node's error answer, including Geth's unknown account) and on a network whose from is unknown. The error keeps its class, code and data, shows through viem and ethers, and names no key. A local account's errors, and errors not about the account, stay exactly as on a network without KMS keys. 10, 11 and 12 KMS accounts list all 10, then "and 1 more" and "and 2 more". A plugin listed before hardhat-kms throws a frozen error, partly writable errors and the same error twice: the error comes back as it came, or with the list once. packages/hardhat-kms/test/unit/rpc/unknown-account.test.ts covers which errors match, including Reth's and Anvil's -32602 answers, and the sentence itself.

    • On-chain verification (packages/hardhat-kms/test/integration/ecrecover.test.ts): the fixture project packages/hardhat-kms/test/fixture-projects/ecrecover compiles Recover.sol, which recovers a signer with ecrecover and refuses high-S signatures, as OpenZeppelin's ECDSA does. Through @nomicfoundation/hardhat-viem and @nomicfoundation/hardhat-ethers, messages and typed data signed by a KMS account whose fake KMS returns only high-S signatures must recover to that account on chain, with one KMS signature per request, so a retry cannot hide a signature the plugin failed to normalize. Typed data for another chain is refused.

    • An adapter with signTransaction (packages/hardhat-kms/test/integration/sign-transaction-method.test.ts), on a Prague edr-simulated network: eth_sendTransaction of types 0, 1, 2 and 4, sends and deploys with hardhat-viem, hardhat-ethers and a library account, and kms sign-tx, all through signTransaction; personal_sign through signMessage and the library account's authorization through signDigest. An adapter that signs another body or with another key sends nothing through any of them: the block number and the nonce do not move, and kms sign-tx prints nothing. packages/hardhat-kms/test/integration/kms-hook-contract.test.ts refuses a signTransaction that is not a function and an adapter whose only signing method is signTransaction.

    • Deploys (packages/hardhat-kms/test/integration/deploy.test.ts): the fixture project packages/hardhat-kms/test/fixture-projects/deploy compiles Counter.sol, whose constructor takes arguments and records the deployer as owner, and whose add only the owner can call, so a successful call shows which account sent it. The project's ignition/modules/Counter.ts deploys it and calls add. The KMS keys are not EDR's default accounts, so EDR cannot sign for them; one fake KMS returns only high-S DER signatures and another low-S compact ones, and each test checks the number of KMS signatures, one per transaction. kms.simulatedBalance funds the KMS accounts. The tests cover:

      • hardhat-viem: sendDeploymentTransaction and deployContract with a KMS wallet client, a write, the state read back, and from on the receipts.
      • hardhat-ethers: the same through ethers.getSigner(kmsAddress).
      • Ignition, through @nomicfoundation/hardhat-ignition-viem: ignition.deploy with a KMS defaultSender on a network that also has local accounts; a module that picks the KMS account with m.getAccount(index) next to a contract from the local default sender; the first KMS account as default sender on a network with accounts: []; and the ignition deploy task with defaultSender.
      • Local and KMS accounts on one network: eth_accounts and ethers.getSigners() list EDR's 20 accounts first, then the KMS accounts; one script deploys and writes from a local account and from a KMS account, and the local account cannot write to the KMS account's contract.
      • --kms: a runtime created with { kms: "aws", network } and AWS_KMS_KEY_ID set, a fake adapter for that key, the key funded by kms.simulatedBalance, and a deploy and write through viem from it.
    • Other signing plugins (packages/hardhat-kms/test/integration/ledger.test.ts): hardhat-kms and hardhat-ledger in both plugins orders. The tests check the account lists, that the KMS account's personal_sign and eth_sendTransaction are signed by hardhat-kms, that the Ledger account's requests reach hardhat-ledger's connect step without a device, and that a transaction without from succeeds only with hardhat-ledger listed first (Other signing plugins).

    • hardhat-viem and hardhat-ethers flows: deploy, every transaction type, and signMessage/signTypedData verified on chain with ecrecover.

    • Sends (packages/hardhat-kms/test/integration/send-lock.test.ts): 10 parallel sends from each of two KMS accounts on an edr-simulated network, with an eth_signTransaction among them, are all mined with nonces 0 to 9 per account, under a 60 s guard against a deadlock. Over HTTP to the recording node, whose pending count never moves, sends get consecutive nonces; a broadcast that times out under hardhat-viem reaches the node once and fails with -32000; a retried request after a broadcast without an answer sends the same bytes, without a new KMS signature, and returns the same hash; a node's refusal comes back unchanged. On a simulated network, a reverted send throws Hardhat's SolidityError with its revert data and transaction hash. A network hook that sends from the same KMS account during the fill gets the re-entrancy error at once, while a send from the other account works and the outer send is mined. packages/hardhat-kms/test/unit/rpc/send-guard.test.ts covers the three limits of the lock with a fake clock: the re-entrant send, also after an await and inside a timer; the 120 s wait without progress, and a queue whose holders take 100 s each that never trips it; and the 1025th waiter. Each case checks that no lock is left behind. It also covers the retry cache and the high-water mark (ConnectionSends); the sent records with the mark off after the pending count falls (#489: the falls it sees, each record looked up once per fall, a failed lookup kept as held, a gone record looked up again before its nonce is taken, a reservation that outlives the fall, every hash kept at a nonce, and the 256-hash bound); the nonce reservations of library accounts (clock expiry with no timer, the order in which reset ends them, with a failed one first, and close); library holds (the lock kept until the broadcast, the 60 s limit, owed resets, close, a failed nonce choice, and a second end that leaves a newer hold alone); the 5 s wait warning (at most once per hold and per waiting send, none behind a plugin send, under 5 s or after close) and the 60 s warning; and a test that keeps the order 5 s < 60 s < 120 s. With timers whose cancel does nothing, it checks that a waiter's limit firing after the waiter got the lock leaves the queue alone; with timers that throw, that the send fails and leaves no waiter in the queue; and that closing a send state ends its library holds at once. It checks the exact text canonicalJson writes for each type, and that a replaced retry entry becomes the newest without dropping another. Each library hold test runs on its own chain id, so a test that fails with a hold still open fails the file at once instead of leaving the next test waiting. packages/hardhat-kms/test/unit/rpc/send-lock.test.ts covers the same rules through the network hook with a fake node and fake timers, as Transactions describes. packages/hardhat-kms/test/integration/nonce-fall.test.ts runs the falls of #489 on a real EDR node: after hardhat_dropTransaction below a reservation, the next send takes the dropped nonce and the queued transaction above it stays; after evm_revert to a snapshot that holds a queued transaction, no send takes its nonce; after evm_revert with an own-transport reservation that outlives it, plugin sends below the reservation are mined with no gap; and after evm_revert restores a transaction whose nonce a second send (after a drop) or a caller-nonce replacement took, no send takes that nonce.

    • The nonce model (packages/hardhat-kms/test/unit/rpc/nonce-model.test.ts): fast-check runs sequences of up to 10 steps over the fake node in send-harness.ts, with one account, two connections and both http and edr-simulated networks. Steps cover plugin sends; library sends through either connection or with their own transport (consume, sign, broadcast, reset); accepted, refused and unanswered broadcasts; delayed KMS signatures; the 60 s hold limit; connection close; unansweredPair (an unanswered plugin send, then an unanswered replace, as one step); replace (a send with the caller's nonce replaces the node's transaction unless the node refuses it, on both network types and with any node answer; when accepted, only while no library send holds a nonce, since an accepted caller nonce ends the reservations up to it); and, on edr-simulated only, the falls of #489: drop (a transaction leaves the node: below the pending count, the count falls and the ones above it stay; above it, a queued one goes) and snapshot then revert (the node gets back exactly the transactions of the snapshot, a queued one included). replace, drop, snapshot and revert are skipped while a request is in flight, since that send chose its nonce before. Invalid self-authorizations exercise #435's refusal after nonce selection. Every key's fake adapter has signTransactionOutlivesAbort (#537), and two steps act on one KMS signature after its request was sent: outstandingSend (a plugin send) and librarySignOutstanding (a library send's sign, which a libraryReset may follow). Each takes an outcome: sent hangs until the key's 1 s timeout passes, fails throws at once, as an activity that needs approval does, and refused throws after ctx.requestRefused, which alone frees the nonce. Every signature that completes holds its nonce on its connection until a transaction with it is recorded there, at once after an answered broadcast, or when a lookup finds an unanswered one, since the fake adapters keep a copy, as Turnkey does. signOnly(connection, outcome?) sends eth_signTransaction, whose nonce is checked as a send's (it runs under the send lock). A copy the node accepted counts as recorded even when the node already had another transaction at that nonce, so the outstanding kind concerns only copies that were never broadcast and accepted. Another transaction at a held nonce does not end the hold on edr-simulated: the plugin ends it only once the nonce is mined. The model's node has a mined count, which the mine step raises to the pending count, and latestFails makes its read fail; drop takes only pool transactions, at or above the mined count, and revert restores the mined count of the snapshot. A hold below the mined count is no longer checked, since the plugin ends it at its next nonce choice; a revert can bring that nonce back, a known limit on local networks. The outstanding kind fails when a send on an open connection signs a nonce held there before a transaction with it was recorded on that connection.

      After each step, the model checks nonce ownership, reservations, hold limits and broadcasts after close. Once requests settle, it also checks that an open connection remembers acknowledged broadcasts despite a lagging HTTP pending count. inspectUncertain consumes a nonce through the public library account, with the same lag, and checks the chosen nonce and transaction-hash lookup on that connection. This consumes a modelled reservation; it does not inspect private send state. Its lag stops above the highest counted nonce the connection did not record, since the connection cannot know that one. Simulated networks retain their actual pending count. They record every send, and the nonce choice uses the records only while a reservation lives. After a fall, a nonce below a recorded one is the right choice, so only the recorded nonce itself is a violation. The gap-489 kind checks that, after a fall on edr-simulated, a plugin send signs no nonce above the lowest one at or above the pending count that the node lacks and that no library send was given, taking the highest such bound between the send's start and its broadcast. Their read-only probe waits until there is no library hold: a nonce read ignores a hold, whereas a send must wait for it. Closing intentionally clears a connection's records. Reservations on another connection and own-transport broadcasts are outside the connection's knowledge by design.

      Each property tries thirty-four fixed sequences before 200 random sequences with seed 445. The nightly run in ci-all-os.yml uses 1000 sequences and a random seed (NONCE_MODEL_RUNS, NONCE_MODEL_SEED=random). To replay a failure, run NONCE_MODEL_SEED=<seed> NONCE_MODEL_PATH=<path> NONCE_MODEL_REPLAY_PATH=<replayPath> node --test --test-name-pattern='<property name>' test/unit/rpc/nonce-model.test.ts in packages/hardhat-kms. Omit NONCE_MODEL_REPLAY_PATH for a fixed example, whose counterexample prints an ordinary step array. Two additional fixed cases check that a library broadcast through a second connection is recorded on both connections, with and without an answer. The orderings fixed by #434 have separate violation kinds and fixed regression cases. The two falls from the QA of #488 (a dropped transaction below a reservation, and a revert to a snapshot that holds a queued transaction) a reservation that outlives a revert, and two reverts that restore a transaction whose nonce a later one took (after a queued drop, and after a caller-nonce replacement; the QA of #503) are fixed sequences too, checked for duplicates and gap-489. So are three for #506: an unanswered send, then an unanswered caller-nonce send at another nonce, then a send or a consume while the node's pending count is below the first send's nonce (lagged, or stopped at a reservation's gap). Random sequences of single steps rarely reach that order, so the composite step unansweredPair (no-answer mode, a plugin send, then replace) makes it reachable: without the fixed sequences, 3000 random runs find the bug at the code before #506. Seventeen fixed sequences for #537 put an outstanding signature before plugin sends and consume (on a lagging HTTP node and past the gap on edr-simulated), behind a library hold and its limit, before a held or own-transport library send's reset, and before a replacement and a fall, with a failure that is not a timeout for a plugin send and a held library send, a refused send next to a held one, eth_signTransaction (the signOnly step) after held nonces, a broadcast the node refuses, two unanswered signatures at one nonce that the node drops, an eth_signTransaction while a send's signature is paused and two at once (both fail without the send lock), QA's seed 4242001 counterexample, where a copy the node accepted and then dropped no longer holds its nonce, a stand-in at a held nonce that the node drops, which leaves the nonce held, and one that is mined while the mined count read fails; each has its own test too, and each fails when the hold is removed. The close step checks that closing a connection ends its library hold; teardown advances all limits and checks that no request, hold or lock remains.

    • Chain-id guards.

    • Config errors reported at the exact path.

    • Tasks (packages/hardhat-kms/test/integration/tasks.test.ts), run with hre.tasks.getTask(["kms", <name>]).run(...) (kms sign through its action with an injected terminal) against fake myvault adapters, with standard output captured: kms address prints the EIP-55 address and kms public-key the 65-byte 0x04 key, for a key in kms.keys, an inline kmsAccounts key and a --kms key. The tests also cover a pin that matches and one that does not (both addresses in the error), an unknown name (the known names, no key ids), no keys at all, a name that a kms.keys key and a --kms key share, an address-only adapter with and without a pin, an adapter that reports no identity (the pin is printed with a note on standard error), a name that differs only in case, and adapter status messages, which must reach standard error and leave standard output with the result alone. Each run's adapters must be closed once, also after an error, and stay apart from the network hook's. kms sign signatures must equal Hardhat's personal_sign and EIP-712 vectors or viem's signature with the same key, and recover to the key with viem. Its tests cover 0x input as bytes, --no-hash (exactly 32 bytes; the question, driven through an injected terminal, with y, yes, n, an empty line and closed input; --yes with and without allowRawDigests; each refusal without a terminal, a --kms key, and the digest of a known EIP-7702 authorization whose tuple recovers), typed data from a JSON string or a file, the chain check against --chain, the --network config's chainId, the node's eth_chainId or nothing, and a signer stubbed to return another key's signature, which must not be printed. kms sign-auth has its own file, packages/hardhat-kms/test/integration/tasks-sign-auth.test.ts. Its tuples must equal viem's signAuthorization with the same key, recover with viem's recoverAuthorizationAddress, and pass Hardhat's rpcAuthorizationList schema. It covers each refused flag combination, chain 0 with and without --force, the nonce read from a node (with pending, plus one with --self-broadcast), a malformed node answer, the summary line and the no-code warning on standard error, and stubbed signers that return another key's or a high-S signature. On a Prague edr-simulated network, the printed tuple goes into an eth_sendTransaction from the same key, from another KMS key and from a Hardhat account, and the authority's code must become 0xef0100 followed by the delegate; without --self-broadcast, the same key's transaction must leave the code empty. packages/hardhat-kms/test/integration/tasks-cli.test.ts runs the same tasks through the Hardhat CLI with an adapter that holds an open timer until it is closed: the command must print its result and exit by itself within the helper's 100-second run limit, also when it fails on a pin mismatch after the adapter opened, and a status message must go to standard error. The project lives under the package's gitignored .tmp/, as for the --kms CLI test. A new task adds its cases to both files. kms verify keeps its runtime cases in tasks-verify.test.ts: a match and a mismatch for a message, hex bytes, UTF-8 text and typed data inline or from a file; --address with no adapter opened; --key with only an identity call and a closed adapter, an address-only adapter asked for the address, and an adapter with no identity checked against the pin with a note; v of 0, 1 and EIP-155 values; a high-S signature accepted with a note; and each malformed signature, message, address and typed-data input. Its CLI cases check exit code 0 on a match and 1 on a mismatch or invalid input, and a message after --. kms accounts has its own file, packages/hardhat-kms/test/integration/tasks-accounts.test.ts: the table and the JSON shape; a failing adapter, an unclaimed key and an unset configuration variable, each shown next to its key with a failed result; a pin mismatch with both addresses; an unchecked pin; masked key ids, and --show-ids with its warning; merging without --network, with an also: line and a pin line for every merged config entry, and none with it, where a repeated --kms key gets a note; AWS rows with the same id told apart by region, profile or endpoint, the endpoint shown only with --show-ids; an unknown network; no keys; at most 8 KMS calls at once; and every adapter closed once. For --balances: refused without --network before any key opens; kms.simulatedBalance shown for each key of an edr-simulated network, in the table in ether and in the JSON in wei; a node answer that is not a hex quantity, which fails only that row; a network that cannot be reached; and a connection that fails to open, which fails every row's balance and still checks the keys; and the connection the task opens for the balances closed once, in a passing and a failing run, with a close that throws leaving the result as it was. For --check-sign: one signature per key and no public key read beyond the listing's; the signed message, hardhat-kms check-sign and 64 hex digits, new on each run; neither the r nor the s the adapter returned, nor any 130-hex-digit run, the size of a signature, on standard output, standard error or in the report; a key that refuses to sign, or signs with another key, failing only its row with a failed result; a pin that was not checked becoming a match once the key signs, and failing when the signature recovers to another address; and - in both columns for a key that failed first. The JSON gains balance and signCheck only with their options, and keeps version: 1. A failure whose message spans lines shows on one line under its row, and keeps its newlines in the JSON. tasks-cli.test.ts checks that the CLI exits 1 when a key fails, 0 with --json when every key works, 0 with --balances --check-sign on a simulated network with no signature in the output, and 1 for --balances without --network. packages/hardhat-kms/test/unit/tasks/account-checks.test.ts checks the message, the balance parser and the ether formatting. packages/hardhat-kms/test/unit/config/key-identity.test.ts checks that one AWS alias looked up with a different region, profile or endpoint, an alias and its ARN, two Google Cloud key versions, two Azure keys, and two providers with the same identifier all get different identities, and that an ARN ignores the lookup settings. Its listBypassIdentity cases check the looser match of the --kms list-bypass check (#589): one AWS key id or alias matches across regions, profiles, endpoints, case and ARN forms, but not a key id against an alias; one Azure key matches across case, a trailing slash and a missing version, but not two versions; Google Cloud and Turnkey keys compare as keyIdentity does.

    • kms sign-tx (packages/hardhat-kms/test/integration/tasks-sign-tx.test.ts) runs over HTTP against the recording node (test/helpers/recording-node.ts). For legacy, EIP-2930, EIP-1559 with automatic fees, a contract creation and EIP-7702 with a pre-signed tuple, the task must print to standard output only the bytes eth_signTransaction returns for the same request on a network that has the key as a KMS account, and their keccak-256 hash to standard error. The same holds on a network without the key, without from, with a type that matches the fields, with lowercase, uppercase and checksummed addresses, and with a chainId and a nonce in the file, which are signed as given. A file without to gets the contract-creation note on standard error. The node must never receive eth_sendRawTransaction or eth_sendTransaction. The refusals must leave the KMS without a signature: no --network, a chainId or a network for another chain, a from that is not the key (no node request either, and a --kms key named by its variable, never by its id), the four ways to ask for a blob transaction, a type the fields do not give or that is not supported, unknown fields with the gas and data hints, a mixed-case address with a wrong checksum in to, from, the access list or the authorization list (no key opened, no node request), a quantity that is not 0x hex (no node request), and a file that is missing, not JSON or not one object. On a simulated network, the task's bytes equal eth_signTransaction's, and a new connection accepts the transaction. Each connection to a simulated network is a new chain, so that test cannot show that the task leaves the nonce alone; the recording-node tests, which see every request, show that nothing is sent. A last test pins the task's field list to the keys of Hardhat's runtime request schema, which has type since hardhat-zod-utils 3.0.7. tasks-cli.test.ts runs the task through the CLI on the default network, where standard output must hold only the raw transaction and standard error the hash, and without --network.

    • hardhat run exits (covered for now by the AWS exit test in layer 5). The kms tasks exit by themselves (tasks-cli.test.ts).

    • A test that runs the Hardhat CLI in a child process calls runHardhat from packages/hardhat-kms/test/helpers/hardhat-cli.ts, not spawnSync. The run does not block the test process, so a node in that process can answer it. Hardhat takes 3 s to start on an idle machine and over 40 s on a loaded one, so the helper times the startup apart from the work. A script that prints a READY line gets a startup limit until that line and a separate work limit after it, as in library-send-cli.test.ts. A run with no such line, such as a kms task or a script copied from the docs, gets one limit of 100 s, under the 120 s per-test limit of Node 24 and later (see Test time limits). Runs started in parallel in one project must not build: concurrent hardhat run calls race on Hardhat's compile cache, so pass --no-compile or run them one after another. The helper kills the child at a limit, at a stderr line the test names, or when the test's signal aborts. On Node 22, --test-timeout limits each test file, not each test, and ends a file that runs past it with SIGTERM; the helper's SIGTERM handler then kills the running children, and endWithTestProcess adds a child the test starts itself, such as hardhat node. Its report holds the reason, an exit-13 note when the code is 13, and stdout and stderr, for failure messages.

    • A provider package's test imports the helper by relative path, as packages/hardhat-kms-gcp/test/integration/credentials-cli.test.ts does with ../../../hardhat-kms/test/helpers/hardhat-cli.ts. The import crosses into the core's TypeScript project, so the provider's tsconfig.json adds a reference to ../hardhat-kms beside the one to ../hardhat-kms/tsconfig.build.json, and changes two options: rewriteRelativeImportExtensions: false, because an import path into another project cannot be rewritten, and then emitDeclarationOnly: true, because allowImportingTsExtensions in the base config is only allowed when imports are rewritten or nothing but declarations is emitted (TS5096). Its tsconfig.build.json sets both back, so the published dist/src/ does not change. The same pattern serves tsconfig.live.json. The helper runs the core package's copy of Hardhat, which is the workspace catalog's version, the same one the providers get. test/scripts/hardhat-cli-spawns.test.ts parses every integration test and fails pnpm test when one starts the CLI with spawnSync, execFileSync or execSync.

    • Error messages never contain the injected fake secrets.

  5. Provider packages with their real SDK against a local endpoint:
    • packages/hardhat-kms-aws/test/integration/plugin.test.ts loads @hardhat-kms/aws in an HRE and signs through the real @aws-sdk/client-kms. The SDK talks to a local HTTP server that speaks the KMS JSON 1.1 protocol (packages/hardhat-kms-aws/test/helpers/kms-server.ts). The test checks the X-Amz-Target of each request, that Sign uses the key ARN from GetPublicKey with MessageType: DIGEST, and the region in the SigV4 credential scope. It also checks that the handler passes keys of other providers on, and that listing hardhatKms and hardhatKmsAws together works.
    • packages/hardhat-kms-aws/test/integration/network.test.ts opens a connection with hre.network.create to a network whose kmsAccounts key points at the same local server. It checks that eth_accounts lists the key's address, that personal_sign returns the signature from Hardhat's own local-accounts tests, and that the server saw one GetPublicKey and one Sign. It also runs packages/hardhat-kms-aws/test/fixtures/sign-and-exit.ts in a child process, which signs without closing the connection, and fails unless the process exits by itself.
    • packages/hardhat-kms-aws/test/integration/sdk-loading.test.ts checks that loading a config loads no AWS SDK module and no task action, that kms address, kms public-key and kms sign-tx on another provider's key load no AWS SDK module (kms sign-tx must reach the key's adapter, so its file and --network checks passed), and that creating an AWS adapter does (see SDK loading). The Azure and Google Cloud packages' sdk-loading.test.ts make the same task checks.
    • packages/hardhat-kms-azure/test/integration/plugin.test.ts runs the real @azure/keyvault-keys with a fake HttpClient (packages/hardhat-kms-azure/test/helpers/key-vault-http.ts) that answers the Key Vault REST API in process, including its challenge-based authentication. Key Vault hosts must end in an Azure vault suffix, so the SDK cannot be pointed at a local server; the fake HttpClient is the seam instead. The test checks the request paths, that sign uses ES256K against the version pinned from the first read, and that the adapter reads the kid of the real response. network.test.ts runs Hardhat's personal_sign and eth_signTransaction vectors through the network hook with a fake SDK, including high-S signatures and a signature of the wrong length, and runs test/fixtures/sign-and-exit.ts with the real SDK to check that the process exits by itself. sdk-loading.test.ts checks that no module under @azure/, @azure-rest/ or @typespec/ loads before an Azure key is used, that kms history on another provider's key loads none of them nor the history reader's modules, and that kms history on an Azure key loads the reader and @azure/core-rest-pipeline but not @azure/keyvault-keys. history.test.ts runs kms history through the plugin with the real @azure/core-rest-pipeline query and a fake HttpClient (packages/hardhat-kms-azure/test/helpers/log-analytics-http.ts). It checks the request URL, the bearer token and its scope, the user agent, Prefer: wait=100 and the query; masking without --show-ids and the ids with it; the table; truncation; the empty-history note; a 429 retried after Retry-After and one that stays throttled; a refused read; a missing table; a missing or malformed workspace setting; another provider's key; the version check; and an abort during the query.
    • packages/hardhat-kms-gcp/test/integration/ does the same for Google Cloud, with the real @google-cloud/kms over its REST transport. There is no Cloud KMS emulator, so packages/hardhat-kms-gcp/test/helpers/kms-server.ts serves GetPublicKey and AsymmetricSign over HTTP, checks digestCrc32c as Cloud KMS does, and returns high-S signatures. The SDK reaches it through kmsHandlers(version, sdk), registered at run time, with a client subclass that sets the endpoint and a throwaway service account whose self-signed tokens need no network. The tests check the request paths, the base64 digest and its checksum, a retried corrupted signatureCrc32c and a retried refused digestCrc32c, could not reach Google Cloud KMS (ECONNREFUSED) without the host, that no request follows an abort, the --kms gcp key's resource path, the messages for NOT_FOUND, FAILED_PRECONDITION and PERMISSION_DENIED, the key version state named from each form of Cloud KMS's FAILED_PRECONDITION message, a proxy's HTML or empty 4xx page reported by its HTTP status rather than as FAILED_PRECONDITION, personal_sign and eth_signTransaction against Hardhat's vectors (so the high S is folded), a signature that is not strict DER, and that packages/hardhat-kms-gcp/test/fixtures/sign-and-exit.ts exits by itself.
    • These tests run the SDK version in pnpm-lock.yaml. pnpm run test:sdk-floors (scripts/test-sdk-floors.ts) runs each provider package's tests again with the lowest version of each cloud SDK its range allows, google-gax included: it reads the floor from the range in package.json (the version of its first caret; scripts/version-range.ts lists the forms it accepts and rejects a range that allows another major), installs that exact version, checks the package resolves it, typechecks the package and its tests against it, and restores package.json, pnpm-workspace.yaml and the lockfile afterwards, also on Ctrl-C. The sdk-floors.yml workflow runs it when a provider package, a manifest, the lockfile, pnpm-workspace.yaml or the script changes; it is not a required check. It also tests the core's optional viem peer dependency at the floor of its range: it installs that version as a workspace override, typechecks the core and its tests against it, and runs the library-account tests listed in PEER_FLOOR_TESTS in the script (the viem unit tests, get-account.test.ts, raw-send.test.ts and library-send-cli.test.ts). Then, whether or not the floor tests passed, it installs viem 2.55.11, the release below the floor (PEER_BELOW_FLOOR), and runs test/floors/viem-below-floor.test.ts, which checks that getAccount refuses it before any KMS call. If a floor fails, raise it in the same pull request to a version that passes. The changeset states the new floor; the reason goes in the pull request.
    • Out-of-range installs: pnpm run test:peer-installs (scripts/test-peer-installs.ts) packs hardhat-kms and @hardhat-kms/aws and installs them into scratch projects with npm (with and without --legacy-peer-deps), pnpm, Yarn 1 and Yarn 4 (nodeLinker: node-modules, both through corepack). The cases are viem 2.55.11, viem ~2.54.0, hardhat-kms one patch release ahead of the provider package, a control with everything in range, and an existing project with only hardhat and viem, viem ^2.47.6 (the range Hardhat's viem template uses) and 2.52.2 in its lockfile, to which the add command of each package manager adds the plugin packages. For that last case the script rewrites the viem specifier in package.json and the lockfile; Yarn 4 resolves a hand-edited entry again, so for Yarn 4 it runs yarn set resolution instead. For each it records the install's exit code, the viem that hardhat-kms resolves and what getAccount reports, and compares them with EXPECTED in the script; it fails when an install's exit code, the viem that hardhat-kms resolves or what getAccount reports changes, and does not check the warnings, which come from manual runs of the same installs. The AWS key points at a local HTTP server that answers with an error and the environment has fake AWS credentials, so nothing reaches a cloud; the control passes when that server gets the GetPublicKey request. It also checks that pnpm without allowBuilds stops on the install scripts of esbuild and protobufjs. When it fails because a package manager changed, update EXPECTED, the table in Library accounts and the causes of core.account.viem-too-old and core.provider.version-mismatch. The peer-installs.yml workflow runs it on Linux when the two checks, a published manifest, the root package.json, pnpm-workspace.yaml or the script change, and monthly; it is not a required check.
    • Registry mode: promote.yml runs the same checks on what users install from npm. --from-registry <version> on scripts/check-packages.ts, scripts/consumer-typecheck.ts and scripts/test-peer-installs.ts replaces the packed tarballs with each published package at that version, hardhat-kms@<version>, @hardhat-kms/aws@<version> and so on (scripts/registry.ts, from the list in scripts/release-packages.ts), skips the build and the pack, and fails after any install whose project resolves another hardhat-kms version. check-packages.ts downloads each tarball with npm pack, which checks it against the registry's integrity hash, and runs publint and attw on it. test-peer-installs.ts skips provider-mismatch, which needs a core repacked one patch ahead, and says so in its table. scripts/check-registry-release.ts <version> is the workflow's first registry check, after the live rule, for what no other script covers: the version is stable (no -), published for every package, at their beta dist-tag and not below latest (equal is allowed: a first publish lands on both; a deprecated name placeholder on latest passes unless the package publishes a stable version above the one checked), the published core's gitHead is the commit of tag v<version>, and npm audit signatures in a scratch project with the packages installed verifies a provenance attestation for each. The examples test reads HARDHAT_KMS_EXAMPLES_VERSION: it copies examples/ to a temporary directory with the exact version written into the two plugin dependencies (packages/hardhat-kms-aws/test/helpers/examples-copy.ts), runs npm install in each copy, and runs the build, typecheck and deploy checks there with npm; the lint stays with the workspace run, which has the same sources. --registry <url> (HARDHAT_KMS_EXAMPLES_REGISTRY for the examples) points every install at another registry. pnpm run test:registry-mode (test/scripts/registry-mode.test.ts, the Registry mode (verdaccio) job of registry-mode.yml) exercises the mode without the public registry: it builds and packs the published packages, publishes them to a verdaccio started on a free port with a throwaway user (a first publish lands on latest and beta at once, as on npm), and runs each script and the examples test against it. test-peer-installs.ts runs there with npm and with Yarn 4. verdaccio records each version's publish time, so Yarn 4's age gate applies to the fresh publish: a project without the npmPreapprovedPackages line stops with YN0016, and the script's projects, which have it, install. verdaccio serves no signing keys, so check-registry-release.ts with --registry runs the scratch install against it and skips only npm audit signatures, and ends with "passed the checks that run against" the registry rather than "ready to promote"; no tag v<version> exists for the workspace version, so that run stops at the tag check with its message. The promotion workflow does not pass --registry. Unit tests cover the guards, on recorded npm view and npm audit signatures output (test/scripts/registry-release.test.ts), the option parsing, the installed-version check and the Yarn 4 .yarnrc.yml, which in registry mode exempts the published packages from Yarn's age gate (test/scripts/registry.test.ts), and the copy (packages/hardhat-kms-aws/test/unit/examples-copy.test.ts).
  6. Emulated AWS: packages/hardhat-kms-aws/test/localstack/aws-kms.test.ts starts LocalStack 4.14.0, pinned by digest and bound to a random port on 127.0.0.1, and runs the real @aws-sdk/client-kms through the plugin against keys it creates. Each of 32 signatures must verify and recover to the key; about half come back high-S, and the test fails unless it saw both kinds. An alias moved to another key after the first lookup must keep signing with the first key, a key ARN without a configured region must work, and P-256 and symmetric keys are refused. Real KMS always echoes the key ARN and algorithm and never offers secp256k1 keys for encryption, so the checks on those response fields are covered by the unit tests only. Run it with pnpm run test:localstack, which needs Docker. In CI it runs on Ubuntu only, in the localstack job.
    • The examples: packages/hardhat-kms-aws/test/examples/examples.test.ts runs every project in examples/ against the same pinned LocalStack image. It creates one ECC_SECG_P256K1 key and computes its address from the public key with @noble/curves and @noble/hashes, independently of the plugin. It runs each example unchanged, through pnpm in the example's folder, with AWS_ENDPOINT_URL_KMS, AWS_REGION and test credentials pointing the AWS SDK at LocalStack and AWS_KMS_KEY_ID naming the key. For each example it runs hardhat build, tsc -p . against the example's own strict tsconfig.json, oxlint with examples/oxlint.json (the root rules, type-aware, with no-console off), and pnpm run deploy --network rehearsal, an edr-simulated network with accounts: [] whose only account is the KMS account, funded by kms.simulatedBalance. The deploy script prints Deployer:, Counter:, Owner: and Count: lines; the test requires the deployer and the contract's owner() to be the key's address and the count read back to be 12. For each Ignition module under an example's ignition/modules/, it also starts hardhat node on port 8545, funds the key's address with hardhat_setBalance, runs hardhat ignition deploy on the built-in localhost network with --kms aws and the key's address as --default-sender, and reads owner() and count() back from the node with eth_call. A simulated network keeps no state once the task exits, which is why this step uses a node. Each example's deploy script also runs against a hardhat node started with --chain-id 11155111, which manages Hardhat's 20 default accounts, as anvil or a fork does (#663): on localhost, which lists no KMS key, the script must fail with is not an account of the localhost network and the node's block number must not move; on sepolia, with SEPOLIA_RPC_URL pointing at the node, the deployer and the owner() read back from the node must be the key's address, not the node's first account. A new example must print the same four lines, and pick its sender by the key's address. Run it with pnpm run test:examples, which needs Docker; in CI it runs in the examples job.
    • The examples are pnpm workspace members. Their package.json asks for hardhat-kms and @hardhat-kms/aws with the caret range of the current version, as a project installing from npm would, and linkWorkspacePackages: true in pnpm-workspace.yaml links those ranges to the workspace packages. changeset version rewrites the ranges when it bumps the packages, so a copied example never contains workspace: or catalog:. The new ranges change the lockfile too, so version the packages with pnpm run version-packages, which runs changeset version and then pnpm install --lockfile-only --ignore-scripts; the version pull request then carries a lockfile that pnpm install --frozen-lockfile accepts. Each example also lists its other dependencies with plain version ranges.
  7. Live tests use real cloud keys. Today the AWS, Azure and Google Cloud smoke tests exist. packages/hardhat-kms-gcp/test/live/gcp-kms.live.test.ts, run with pnpm run test:live:gcp, is skipped unless HARDHAT_KMS_LIVE_GCP_KEY holds the full name of an EC_SIGN_SECP256K1_SHA256 key version. It uses the developer's Application Default Credentials, creates nothing, redacts the project, key ring and key names from failures, signs 16 digests with the name and once with the components form, and checks that a missing version fails with a clear message. test:live:gcp also runs packages/hardhat-kms-gcp/test/live/gcp-history.live.test.ts, which needs Data Access audit logs on for Cloud KMS in the key's project and roles/logging.privateLogViewer for the developer. It signs one random digest through the plugin, then runs kms history --json every 10 seconds, for up to 3 minutes, until an AsymmetricSign entry with that digest appears, and checks its version, its hardhat-kms/ user agent, and that no key id reaches the output outside principals. A second test signs nothing and is skipped unless HARDHAT_KMS_LIVE_GCP_PROJECT_NUMBER holds the key's project number (gcloud projects describe <project> --format='value(projectNumber)'). It reads the last 7 days of history with the key named by its project id and by its project number, and checks that both reads list the same entries. The Azure one, packages/hardhat-kms-azure/test/live/azure-key-vault.live.test.ts, run with pnpm run test:live:azure, is skipped unless HARDHAT_KMS_LIVE_AZURE_KEY_ID holds the versioned URL of the current version of a P-256K key. It signs through the plugin's credential chain (az login is enough), creates nothing, redacts the vault, key name and version from failures, and checks that the versioned id, the unversioned id and the components give the same key, and that a version that does not exist fails with 404. The AWS one: packages/hardhat-kms-aws/test/live/aws-kms.live.test.ts, run with pnpm run test:live:aws, is skipped unless HARDHAT_KMS_LIVE_AWS_KEY_ID names an ECC_SECG_P256K1 key with an alias. It uses the developer's own credentials and region, creates nothing, redacts the key id, ARNs and account ids from every failure it reports, and signs through the plugin with the key id, an alias of the key, and the key ARN with AWS_REGION set to another region, where the bare key id must fail with NotFoundException. Beyond the guide's policy, the identity needs kms:DescribeKey on the key and kms:ListAliases, which only accepts the resource *. packages/hardhat-kms-aws/test/live/history.live.test.ts, in the same script, also needs HARDHAT_KMS_LIVE_AWS_HISTORY=1, because it waits up to 15 minutes for CloudTrail, and cloudtrail:LookupEvents. It signs once through the plugin and once with the AWS SDK and the alias, then polls kms history --json for the bare key id every 30 seconds until both events appear: one with the hardhat-kms/ user agent, and one whose requestId is the SDK's $metadata.requestId. It prints only how long that took. packages/hardhat-kms-azure/test/live/history.live.test.ts, in test:live:azure, also needs HARDHAT_KMS_LIVE_AZURE_WORKSPACE_ID, the workspace that the vault's diagnostic setting sends audit events to, and read access to it. It signs once through the plugin and once with the Key Vault SDK, keeping that call's x-ms-request-id, then polls kms history --json every 30 seconds, up to 12 minutes, until both KeySign rows appear: one with the hardhat-kms/ user agent, and one whose requestId is that x-ms-request-id. No row's requestId may be the client's x-ms-client-request-id. The first run (#100) used an administrator identity and the default key policy; checking the guide's least-privilege policy against real KMS is part of #43. The live suite below also runs in GitHub Actions, signed in over OIDC: see Live tests in GitHub Actions. The Turnkey smoke test, packages/hardhat-kms-turnkey/test/live/turnkey.live.test.ts, run with pnpm run test:live:turnkey, has its own section: Turnkey smoke test.
    • The live suite: test/live/sepolia.live.test.ts at the repository root, run with pnpm run test:live, reads the same three key variables and runs once for each provider whose variable is set. It runs on a local fork of Sepolia by default, or on Sepolia itself with HARDHAT_KMS_LIVE_NETWORK=sepolia; the two modes are described after the list of checks. Providers without one are reported as skipped. A developer runs it locally with their own aws, gcloud and az logins, or a maintainer runs it in GitHub Actions; it creates no cloud resources and nothing is stored in the repository. The configured providers run in parallel, each with its own network connection, so the plugin's send lock orders each account's sends. Through hardhat-viem on an http network whose kmsAccounts holds the key, it runs the cases of the transaction matrix in order: it builds test/live/fixture-project and deploys LiveCheck.sol, then sends transfers, deploys, calls with value, reverts, replacements and EIP-7702 delegations across the transaction types, and checks a personal_sign, an eth_sign and an eth_signTypedData_v4 signature on chain. Only the deployer can call LiveCheck.add, so each write that succeeds came from the KMS account. The checks each case makes:

      • Transfers of 1 wei to a fresh random address: its balance at the receipt's block must grow by 1. Self-sends of 1 wei must be mined.
      • A 3-byte contract (PUSH0 PUSH0 RETURN) deployed as a legacy and as an EIP-2930 transaction: the receipt's contractAddress must hold exactly that code.
      • add(1) with 1 wei, which is payable, as a legacy transaction whose v must carry chain id 11155111 (EIP-155), as an EIP-2930 transaction whose access list names the count slot, and as an EIP-1559 transaction. The count and LiveCheck's balance must each grow by 1.
      • Reverts: 4 bytes of an unknown selector to LiveCheck, which has no fallback, with an explicit gas limit, since an estimate would fail. The receipt must have status 0. The next transaction whose nonce the plugin fills must carry the account's transaction count at the revert's block; the test reads that nonce from the node before waiting for the receipt, so a wrong one fails with both numbers instead of a timeout. On Sepolia that transaction is the legacy add(1), and a run in which no such check happened fails.
      • EIP-7702: the account sends a transaction to itself with an explicit nonce, carrying an authorization that delegates it to LiveCheck with that nonce + 1, and calling add(1) with 1 wei on itself, which runs only if the delegation took effect. The account's code must then be the delegation designator for LiveCheck. The transactions go through viem's sendTransaction with authorizationList. The test signs the account's authorizations through the public library account, connection.kms.getAccount(address).signAuthorization, on the provider's connection. Each one names chain id 11155111; the suite never signs an authorization for chain 0, which would be valid on every chain.
      • Sponsoring another key: the account sends 1 wei to the fresh address carrying an authorization from a throwaway key, generated in memory for the run and never printed. The throwaway's code must become the designator for LiveCheck. A second transaction from the account carries the throwaway's authorization of the zero address, and the throwaway must end with no code. The throwaway holds no ETH; the account pays for both.
      • Signatures: LiveCheck rebuilds the EIP-191 digest for personal_sign and for eth_sign, which in Hardhat signs the same digest, and the EIP-712 digest, the typed data's domain with block.chainid and the contract's address, and recovers the signer with ecrecover, refusing high-S signatures.
      • The last case clears the delegation, also after a failure and also when an earlier run left one: an EIP-7702 transaction from the account to itself with 1 wei, whose authorization names the zero address with the transaction's nonce + 1. The account must then have no code. Slot 0 of the account's storage keeps the count the delegated add wrote; clearing the delegation does not reset storage.

      Each transaction's value is read back from the node and must equal what the case sent: 1 wei for the transfers, self-sends, calls, the type 4 call, the sponsored transfer and the clear, and 0 for the others. After the last case, every cell the mode runs must have a receipt from its case with the case's status, sender and type, and each signature its own check (missingCells in test/live/matrix.ts); a missing one fails the run.

      If clearing a delegation fails, for example because a transaction stuck under a rising base fee holds the nonce, the failure says which account may still be delegated and how to clear it with kms sign-auth --self-broadcast. The throwaway key cannot be cleared afterwards, since it existed only in memory; it holds no ETH, and only the KMS account can call add on it.

      Two modes, chosen by HARDHAT_KMS_LIVE_NETWORK (test/live/helpers/mode.ts; any value other than fork or sepolia fails the run at load):

      • Fork mode, the default (unset or fork). Needs anvil, found on PATH or in ~/.foundry/bin. The suite starts anvil --fork-url <proxy> --hardfork prague --no-storage-caching on a free port on 127.0.0.1 (test/live/helpers/anvil.ts) and points every provider's http network at it. Before signing anything, each test checks that web3_clientVersion starts with anvil/ and gives its account 10 ETH with anvil_setBalance. Fork mode runs the live cases and the fork-only cases of the matrix. Only anvil accepts that method, so the run cannot fund or send on a node that is not the fork. The live cases make the same checks as on Sepolia, with the same KMS keys, the same plugin path over http, Sepolia's chain id and each account's real nonce, and the run costs nothing. It proves that each key signs every transaction type, that the EIP-7702 delegation and clear work under the Prague rules, and that the pinned reads and the retry still work against a node that never lags. The 20 gwei cap is not applied, since the fork's ETH is minted. A receipt is awaited for 60 seconds, not 300. If a transaction is still pending after 15 seconds, the test mines one block with evm_mine and says so in a diagnostic: once, under three providers sending at the same time, anvil left a valid transaction pending with no later send to trigger a block. A transaction that is not valid stays out of that block and still fails the test.
      • Sepolia mode (HARDHAT_KMS_LIVE_NETWORK=sepolia). The same checks on the public network, spending real Sepolia ETH. It proves what a single local node cannot: that real nodes accept and mine what the plugin sends. Run it before a release and after any change to signing or sending. The live runs so far caught a legacy transaction priced under a rising base fee and a stale read from a load-balanced RPC; a fork, with one node and its own blocks, reproduces neither. Some bugs also show only on a real client: geth refuses an authorization whose r or s is sent as 32 bytes with a leading zero, while anvil and EDR accept both forms (#140, found by reading geth's hexutil.U256 decoding, not by a live run). It runs only the live cases. Only this mode writes test/live/proof.json, and only when every configured provider passed; pnpm run docs:live-proof (test/live/render-proof.ts) renders Live proof from it.

      No transaction from a fork run reaches Sepolia. Anvil never sends a transaction to its --fork-url, and in this suite that URL is a local proxy (test/live/helpers/rpc-proxy.ts) in front of the Sepolia RPC, as a second line of defence. The proxy forwards only an allow-list of the reads that anvil's fork backend (crates/anvil/src/eth/backend/fork.rs in Foundry) can issue: state, block, transaction, receipt and log reads, eth_call, eth_estimateGas, eth_createAccessList, eth_simulateV1, and the trace_* and debug_* reads that take a hash or a block. Any other method is answered with an error and not forwarded, including eth_sendRawTransaction, eth_callBundle, mev_simBundle, trace_rawTransaction, personal_sendTransaction and wallet_sendCalls. It also refuses a request that holds a hex string of 65 bytes or more, which is the size of a signature, and a body that is not JSON-RPC, including one with a key other than jsonrpc, id, method and params, such as Method, which Go's case-insensitive JSON decoding would read as the method. A batch with one refused request is refused whole. What it forwards is rebuilt from the parsed request, never the text received, so a duplicate method key cannot reach the upstream. The last test of a fork run fails if the proxy refused anything, or if any KMS account's state was not read through it (eth_getAccountInfo, eth_getAccount, eth_getBalance or eth_getTransactionCount), which shows the fork the suite sent through is the one behind the proxy. It prints the forwarded methods and how many evm_mine nudges the run needed. The proxy also records, for each eth_feeHistory it forwards, the upstream's HTTP status and either the JSON-RPC error code or the result's shape (array lengths and value types), and each forward whose upstream fetch failed, by its methods and the error's name and cause code. It keeps no value and no message from an answer, since a message can name the RPC URL. When a provider's fork case fails, the suite prints that record, so a fee read that went wrong upstream shows in the failure (#395). Anvil ends with the test process: on a normal exit and on SIGINT, SIGTERM or SIGHUP the suite kills it, so it cannot outlive the run with the fork's signed transactions; only a SIGKILL of the test process leaves it running. close() sends SIGTERM, then SIGKILL after 5 seconds. A fork run also prints no raw transaction or authorization: both carry Sepolia's chain id and the account's real nonce, so a copy could be broadcast on Sepolia. The suite reports only hashes, and the redaction below removes signed data from failures. A fork run writes no proof, since its hashes exist on no public chain. test/live/mode.test.ts checks the mode switch and the anvil lookup, test/live/rpc-proxy.test.ts checks the proxy against a fake upstream, and test/live/anvil.test.ts kills a parent process holding a stand-in for anvil and checks the stand-in dies too; all three run in pnpm test.

      Two package sources, chosen by HARDHAT_KMS_LIVE_SOURCE (liveSource in test/live/helpers/mode.ts; any value other than source or registry:<exact version> fails the run at load, so a range such as registry:^1.0.0 or a tag such as registry:latest is refused):

      • Source, the default (unset or source). The three live files import the provider plugins from the checkout's src.

      • Registry (HARDHAT_KMS_LIVE_SOURCE=registry:<version>). Each live file copies test/live/fixture-project to a new hardhat-kms-live-registry-* directory under the system temp directory, writes hardhat-kms, @hardhat-kms/aws, @hardhat-kms/gcp and @hardhat-kms/azure at that exact version into its package.json, runs npm install --ignore-scripts --legacy-peer-deps there, and fails unless each of the four packages (Turnkey is not in the live gate), and the core each provider loads, resolves to that version (test/live/helpers/packages.ts). It then imports the providers by package name and uses the copy as the Hardhat project root.

        A resolve hook (module.registerHooks, from Node 22.15; on an older Node the run fails before the install and says so) sends an import of one of the four packages from outside the copy to the copy's node_modules, and an import of their peer dependencies (hardhat, viem) from inside the copy to the workspace's, so Hardhat and viem load once, as in a project that installs them once. The hook records every module it resolves under the checkout's packages/. Each live file ends with registry: ran the published packages and nothing from packages/, which fails if any was loaded, the plugins' hook handlers included, or if a package resolved to another version.

        The copy is removed when the process exits, by a function that refuses any directory the process did not create. npm reads its usual config, so npm_config_registry points the install at another registry and npm_config_offline=true installs from npm's cache only. A Sepolia run in registry mode writes no proof: a proof names the commit it ran, and this run tested a version from npm, not a commit. promote.yml runs fork mode in registry mode when its live-run input is fork (Live tests in GitHub Actions). For example, HARDHAT_KMS_LIVE_SOURCE=registry:0.9.0 pnpm run test:live runs the fork against 0.9.0 from npm.

      In both sources the EIP-7702 authorizations are signed through connection.kms.getAccount, so no live file imports src/internal/. test/live/mode.test.ts checks the source switch, and test/live/packages.test.ts checks the hook against a stand-in scratch project (skipped on Node 22.13, the published floor), the refusal to remove a directory, and that no file in test/live/ imports from packages/ or an internal/ path, except the three src/index.ts imports of the loader's source mode; both run in pnpm test.

      Every receipt must have the status, sender, transaction type and value its case expects. The RPC URL comes from the HARDHAT_KMS_LIVE_SEPOLIA_RPC_URL config variable; without it the suite uses https://ethereum-sepolia-rpc.publicnode.com, which needs no API key. The legacy and EIP-2930 transactions pay a gasPrice of twice the latest base fee or the node's eth_gasPrice, whichever is higher, rounded up to a whole gwei, so a rising base fee cannot strand them; the EIP-1559 and EIP-7702 transactions take the plugin's fees. Before anything is sent, each account must hold the run's floor and, on Sepolia, that gas price must be at most 20 gwei; otherwise its test fails and says which limit it hit. The floor comes from the case table: the sum of the gas budgets of the cases the mode runs, times that gas price (balanceFloor in test/live/matrix.ts). On Sepolia, a receipt that does not arrive within 300 seconds fails the test with the transaction's hash and nonce and the account's mined transaction count, so the transaction can be replaced. Public RPCs balance requests across nodes, and a node behind the others can answer a read with state from before the last write. So every read that checks state after a write (count(), balances, code, the account's slot 0, the signature checks, and the nonce for the explicit-nonce transactions) asks for the block of the latest receipt. A lagging node then answers "block not found" or "header not found" instead of stale state, and test/live/helpers/retry.ts tries the read again, up to 10 times, 2 seconds apart. Waiting for a receipt needs no such pin: viem polls until a node returns the receipt. A lagging node also still counts the latest receipt's transaction as pending, and geth refuses a send from a delegated account that has another pending transaction (in-flight transaction limit reached for delegated accounts), and a send carrying an authorization whose authority has one (authority already reserved). The node broadcast nothing and the plugin keeps no nonce for a refused send, so every send of the suite goes through the same file's retryPoolRefusal, which sends again up to 10 times, 6 seconds apart, and writes a diagnostic for each retry (#685). A run clears its delegations at the end, also after a failure; when a failed clean-up leaves an account delegated anyway, the next run clears it before its first transaction: test/live/helpers/delegation.ts sends the account's authorization of the zero address in a transaction to itself, outside the proof, and the getAccount suite does the same before its self-transfer. The cost of a Sepolia run is under Cost per run. Failures go through test/live/helpers/redact.ts, which removes each key variable and its parts (the AWS key id split on : and /, the GCP project, key ring and key, the Azure vault, key and version), the RPC URL, ARNs, aliases, UUIDs, 12-digit account ids, Azure's key vault '<name>;location=…' form, GCP project numbers, any URL and any /v2/ path. It also removes signed data: any hex string of 65 bytes or more, with or without 0x (raw transactions and signatures), the value of an r or s field, with or without 0x, and 32-byte values in an argument list such as viem's args: (…) or recoverPersonal(…). Transaction hashes and addresses elsewhere stay. test/live/redact.test.ts checks it with made-up identifiers of each kind, test/live/gas.test.ts the gas price, test/live/retry.test.ts both retries, test/live/delegation.test.ts the clean-up of a leftover delegation, and test/live/lock.test.ts the lock that keeps a replacement case away from other providers' sends; all five run in pnpm test. LiveCheck has a receive function, so a plain transfer to the account works even if a delegation were left behind. The transactions of the latest Sepolia run are listed in Live proof.

    • test/live/accounts.live.test.ts, which pnpm run test:live runs after the matrix, reads the same key variables and mode. test:live runs the live files one at a time (--test-concurrency=1), because each fork reads Sepolia through the same public RPC; run together, the forks slowed it until the matrix's requests timed out. For each configured provider it runs kms accounts --json on an http network whose kmsAccounts holds the key, once plainly for the address, then with --balances --check-sign. It expects the address, signCheck: "ok", no balance or signCheck field in the plain run, and no signature in standard output, standard error or the report. In fork mode it starts its own anvil fork behind the recording proxy, checks web3_clientVersion, gives the account 12.345678901234567891 ETH with anvil_setBalance and expects exactly that balance, then fails if the proxy refused anything. In Sepolia mode it expects a decimal balance, since the matrix may be spending from the account at the same time. It sends no transaction and spends nothing in either mode.

    • test/live/get-account.live.test.ts checks connection.kms.getAccount with the same key variables and mode. On the fork it funds the account and a throwaway sponsor with anvil_setBalance, recovers a message and typed data the account signs, sends an EIP-1559 transfer through a viem wallet client built with the account, and has the sponsor send the EIP-7702 authorization the account signed, then checks the account's delegation code. On Sepolia it sends one EIP-1559 transaction of 0 wei from each account to itself.

  8. Mutation testing: Stryker changes the code one small edit at a time (a mutant) and reports each edit that no test catches.
    • What runs: StrykerJS 10 with @stryker-mutator/tap-runner mutates packages/hardhat-kms/src/internal/crypto/, src/internal/signer/ (not signer/types.ts), src/internal/viem/ (not viem/types.ts), src/internal/alchemy/ and five files of src/internal/rpc/: send-guard.ts, dispatcher.ts, transaction-filler.ts, transactions.ts and rpc-data.ts. It runs the core's unit tests against each mutant, each test file in its own node process with Node's type stripping (no tsx, no build). The config is packages/hardhat-kms/stryker.config.json. In the baseline, 57 of the 655 caught mutants were caught by test/unit/tasks/keys.test.ts and test/unit/rpc/transactions.test.ts, outside test/unit/crypto and test/unit/signer, so the run uses every unit test file but one: error-types.test.ts runs tsc on a fixture through paths outside the package, which do not exist in Stryker's sandbox, and runs no code from crypto/ or signer/. Integration tests are not part of the run.
    • Command: pnpm run test:mutation. It is incremental: it reads packages/hardhat-kms/reports/stryker-incremental.json and re-tests only the mutants in changed source files and the mutants covered by changed test files. A change outside those files is not seen: a dependency update, or a change to unmutated source that the mutated code imports, such as errors.ts, error-catalog.ts, rpc/chain-id.ts or rpc/typed-data.ts. Such a change shows only in a full run; pnpm --filter hardhat-kms exec stryker run --force tests every mutant. The HTML report is packages/hardhat-kms/reports/mutation/mutation.html; the clear-text output lists each surviving mutant with its diff, then a score table per file. reports/ and .stryker-tmp/ are gitignored.
    • Three settings in the config need a reason, which sits next to each as a _comment key. tsconfigFile names a file that does not exist: Stryker rewrites tsconfig.json in its sandbox with the typescript package's parseConfigFileTextToJson, which TypeScript 7 does not export, so the run fails. The rewrite only serves Stryker's TypeScript checker, which this setup does not use. plugins names the tap runner: Stryker's default plugin glob only searches the folder next to its own install, where pnpm does not put the runner. Named explicitly, it is imported by package name and resolves through pnpm's hidden hoist (node_modules/.pnpm/node_modules). tap.testFiles leaves out error-types.test.ts, as above.
    • Schedule: .github/workflows/mutation.yml, on Linux only. A plan job reads mutate from the Stryker config and makes one shard per entry that names a single file, called after its directory and file, and one per directory under src/internal/ for the other entries: crypto, signer, viem, alchemy, rpc_send_guard, rpc_dispatcher, rpc_transaction_filler, rpc_transactions and rpc_rpc_data. An exclusion (!) goes to every shard of its directory, and a directory shard leaves out the files that have shards of their own, so no mutant is tested twice. A file entry with other characters in its name than lowercase letters, digits and - runs in its directory's shard. An entry outside src/internal/<directory>/ fails the plan, so a new entry cannot fall outside every shard. Each shard is a job on its own runner that passes its entries to stryker run --mutate, so the slowest shard sets the wall time instead of the sum of all nine. Each shard checks its own score against break, and a score job adds up the shards' JSON reports and checks the total. Everything below applies per shard. Every run that reaches Stryker saves its incremental file in the Actions cache under a new key, stryker-<os>-<shard>-<hash>-<run id>-<attempt>-<pass|fail>, where the hash covers the core's src/ and test/, the Stryker config, pnpm-lock.yaml and the workflow file. Weekly, on Mondays at 03:17 UTC, it first looks up the newest entry for the current hash. If that run passed, it writes "skipped" to the job summary and stops before installing; after a failed run it runs again, so a failure repeats every week until it is fixed. Otherwise it restores the newest incremental file (for this hash, else any) and runs incrementally. GitHub evicts cache entries unused for 7 days, so most weekly runs find no incremental file and test every mutant. On the 1st of each month, and when dispatched with force, it tests every mutant, and its results replace the incremental ones. When the 1st is a Monday, the weekly run skips itself and only the monthly full run tests. The workflow passes --concurrency 2, since the score depends on the worker count (below). Each shard uploads its HTML and JSON report as the mutation-report-<shard> artifact, kept 14 days, and writes its score table to the job summary. Each shard job has a 120-minute limit, well above the slowest shard's expected time, since a shard cancelled at its limit saves no incremental file and would start from scratch the next week. It is not a required check and has no pull_request trigger, so the gate runs after merge: a pull request that leaves survivors does not fail its own checks, it turns the next weekly run red. Run pnpm run test:mutation before opening a pull request that changes crypto/, signer/, viem/ or one of the five mutated files of rpc/; --mutate <file> limits a run to one file.
    • Threshold: thresholds.break in the config. A score below it exits 1 and fails the scheduled run; the run's incremental file is still saved, marked fail, so the next night does not skip. It starts at the baseline rounded down, minus a margin that absorbs timeouts that depend on the machine: floor(score) − max(2, ceil(100 × timeouts / valid mutants)), where valid mutants exclude the ignored ones and the runtime errors. The margin is 2 points unless timeouts make up more than 2% of the mutants. To raise it, a pull request that raises the score sets break the same way from the new CI score. Lowering it needs a reason in the pull request.
    • Equivalent mutants: a mutant that behaves like the original for every input the code can receive cannot be killed. An injectable seam, such as Timers or an adapter, counts as an input within its contract (a Timers never runs a callback inside setTimeout, as real timers never do): a guard that only a misbehaving seam can reach, such as a Timers whose cancel does nothing, is tested with such a seam, not marked. An equivalent mutant is marked in the source with // Stryker disable next-line <Mutator>: <reason>, and the reason says why the edit changes nothing, so a reader can check it, as for type escapes. Stryker reports the mutant as ignored, outside the score. The comment applies to every mutant of that mutator whose node starts on the next line. Babel places a && or || expression at its first operand, so a redundant operand goes last, on its own line, with the comment above it: placed first, the comment would also skip the mutants of the whole condition, such as the one that turns a key comparison into true. Where the equivalent mutant and a killed one are on the same node, for example n < 256 changed to n <= 256 or to n >= 256, the comment skips both, and the pull request lists the killed ones. An unreachable block is marked with // Stryker disable BlockStatement: <reason> before the if and // Stryker restore BlockStatement after it, since its opening brace shares a line with the end of the condition. An else block cannot take a line comment of its own, since a comment before else belongs to the block above it; signer-identity.ts puts the directive in a block comment between else and its brace. Every mutant in src/internal/crypto/, src/internal/signer/ (#169) src/internal/viem/ (#51) src/internal/rpc/send-guard.ts (#205) and src/internal/alchemy/ (#495) is killed, marked, or a runtime error. The 2 runtime errors in crc32c.ts are n-- and k--, which never end the table loops when the module loads; Stryker stops them with its hit count limit, an error rather than a test failure. The third, in viem/inputs.ts, empties the arrow function that builds the table of signed types when the module loads, so the module fails to load. The library account's refusals are tested with their exact messages (test/unit/viem/refusals.test.ts), since a pattern match lets the method name or the field path in a message change unseen.
    • Equivalent mutants in rpc/dispatcher.ts, rpc/transaction-filler.ts and rpc/transactions.ts (#331) are listed here instead of marked in the source, so each counts as a survivor in its shard's score and no disable comment hides a mutant of the same node that a test kills. Every other mutant of the three files is killed. The three listed:
      • dispatcher.ts, rawKmsTransaction: /^0x/i changed to /0x/i. The string has already decoded as a transaction, so it is hex with an optional 0x prefix, and both remove the same characters.
      • transaction-filler.ts, QUANTITY without its ^. It is only tested on values that canonicalAuthorizationSignatures wrote, which match either way, or left alone. A value left alone that ends in a quantity still holds an x after the padding, so Hardhat's schema refuses it with the same message.
      • transactions.ts, lintAuthorizations: yParity === 0 || yParity === 1 changed to true. buildUnsignedTransaction runs first and refuses any other yParity, so the condition is always true there.
    • Machine load changes the result. A mutant that makes a test run past Stryker's timeout counts as caught (# timeout). On an overloaded machine, survivors turn into timeouts: on an 8-core laptop, Stryker's default of 7 workers reported 63 timeouts and 85.41%, against 7 timeouts and 82.54% with --concurrency 2. Compare scores from the CI job, which runs 2 workers (--concurrency 2) on 2 vCPUs. A mutant that leaves a promise unsettled is a timeout too, whatever the load: node:test waits for each test's promise, so the file never ends and Stryker stops it. Most timeouts in send-guard.ts are of this kind, such as a lock that is never handed to the next send. Tests that share a lock key let one failing test leave the next one waiting, which turns a fast failure into a timeout, so each library hold test in send-guard.test.ts uses its own key. A mutant that a test catches only by waiting on a real timer, such as the 60 s limit of a library hold, survives or times out depending on load and on Stryker's per-mutant timeout. Check such an effect at once instead: send-guard.test.ts checks that closing a connection's send state ends its holds right away, rather than waiting for the hold's limit.
    • Baseline after #205 added rpc/send-guard.ts and split the workflow into shards, 2026-10-03 on d5020ec, from a full CI run (run 37131684354) on ubuntu-26.04 with 2 workers per shard: 1897 mutants in 12 files; score 100%; 1793 killed, 44 timeouts, no survivors, none without coverage, 3 runtime errors, 57 ignored. The Stryker step took 14 minutes 10 seconds for crypto, 12 minutes 35 seconds for rpc, 11 minutes 28 seconds for signer and 9 minutes 37 seconds for viem; the run took 19 minutes 38 seconds from start to end, about 50 billable minutes. Of the 44 timeouts, 35 are in send-guard.ts, the same count in two local runs. break is 97: floor(100) − max(2, ceil(100 × 44 / 1837)), with 1837 valid mutants, since the timeouts are 2.40% of them. Before the new tests and markers, a local run of send-guard.ts alone scored 92.68%: 312 killed, 68 timeouts, 29 survived, 1 without coverage.
    • Scores after #331 added the three rpc files, from a forced CI run (run 37668014643) on ubuntu-26.04 with 2 workers per shard: 99.91% over all seven shards (3179 of 3182). rpc_dispatcher 99.88% (809 valid mutants: 779 killed, 29 timeouts, 1 survived), rpc_transaction_filler 99.79% (478: 477 killed, 1 survived) and rpc_transactions 98.04% (51: 50 killed, 1 survived); the other four 100%. Run times vary with the runners: that run took 35 minutes 56 seconds from start to end, with every shard slower than in the previous one, crypto included (32 minutes 30 seconds, against 15 minutes 13 seconds, with no change to its code or tests). The previous run on the same rpc shards (run 37657034427) took 22 minutes 7 seconds, its slowest Stryker step rpc_dispatcher at 21 minutes 25 seconds.
    • Scores of the three files before #331, from a forced local run on 8e333da with 4 workers on an 8-core laptop, 2026-10-07: dispatcher.ts 66.09% (808 mutants: 479 killed, 55 timeouts, 123 survived, 151 without coverage), transaction-filler.ts 87.13% (474: 413 killed, 46 survived, 15 without coverage) and transactions.ts 54.72% (53: 29 killed, 5 survived, 19 without coverage). Most of the new tests are in test/unit/rpc/dispatcher.test.ts, dispatcher-sends.test.ts and debug-log.test.ts, which call dispatch() through test/helpers/dispatch-fixture.ts, a fake node whose every answer a test sets.
    • Reading the report: open mutation.html (or download the artifact) and pick a file; each surviving mutant shows the edit no test caught. Kill it with a test that fails on that edit, or mark it as equivalent, as above.

Test code follows a few conventions:

  • Each test opens a fresh connection with hre.network.create() (connect() is deprecated since Hardhat 3.18; getOrCreate() reuses cached connections, so per-connection state must tolerate reuse).
  • HRE test files run with concurrency:false.
  • Test globs are quoted in scripts, so the shell does not expand them.
  • Helpers live in each package's own test/helpers, because hardhat-test-utils is private.
  • The root test, test:unit and coverage scripts run pnpm run build first, because provider packages import the core from its built dist/.
  • Code that removes a directory with rmSync(..., { recursive: true }) stays out of the real temp directory, and so do its tests. A mutant that replaces the per-run directory with tmpdir() would make the test remove the real temp directory. scripts/pack.ts and test/scripts/pack.test.ts are the model:
    • The code checks the path first and refuses anything outside the directories it created. removePackDirectory removes only a hardhat-kms-pack-* directory directly under os.tmpdir().
    • A test of such code runs it under a temp directory the test creates. In before it sets TMPDIR, TEMP and TMP to that directory and asserts that os.tmpdir() returns it; in after it restores the three variables and removes the directory. TEMP and TMP are for Windows, where os.tmpdir() reads TEMP, then TMP, and ignores TMPDIR.
    • A mutant you make by hand in such code (Stryker does not cover scripts/) runs under the same sandbox: set the three variables in the shell before node --test, for example TMPDIR=$sandbox TEMP=$sandbox TMP=$sandbox node --test test/scripts/pack.test.ts.

Coverage uses c8 on native TypeScript (Node 24), with a threshold of 95% for lines, branches, functions and statements across each package's src/, set in the package's .c8rc.json. Provider adapters are tested with fake SDK clients, so they are held to the same bar. types.ts and type-extensions.ts are excluded.

Deprecated APIs are checked in five places. pnpm run check lints our own code with typescript/no-deprecated. pnpm run docs:check lints the TypeScript snippets of the docs and READMEs with the same rule. pnpm run pkg:check fails on a deprecated package in a published package's production tree, as the lockfile records it. pnpm run test:fresh-install (scripts/check-fresh-install.ts) fails on one in a user's fresh install: it installs each provider package with the core into empty projects with npm and pnpm and empty caches, walks the production tree as Node resolves it, nested copies included, and asks the registry about each version; fresh-install.yml runs it weekly and on pull requests that change a published manifest, and the release workflow runs it in its own fresh-install job, which both publish jobs need. The Node 26.0.0 leg of the CI test job fails any Node process of the tests, Hardhat CLI runs included, that emits a DeprecationWarning not on its allowlist; worker threads are not covered (see Tooling). A test that calls a deprecated API on purpose fails that leg. Set process.noDeprecation around that one call, as the providers' test/helpers/import-recorder.mjs do for the module.register fallback that Node 22.13 needs, or, for a warning a dependency emits, add its code to ALLOWED_WARNINGS in scripts/deprecation-hook.ts with the reason and the upstream link. Each check has its tests in test/scripts/, with fixtures in test/scripts/fixtures/.

Test time limits

The test:unit and test:integration scripts of the published packages run node --test through scripts/node-test.ts, which chooses the --test-timeout value by Node major. The flag means two different things:

  • On Node 24 and later it limits each test. A file may run as long as its tests need.
  • On Node 22 it limits each test file and sets no limit per test. The runner ends a file that runs past the value with SIGTERM, even when every test in it passes.

Node changed the flag in nodejs/node#57672, first released in 24.0.0. The 22.x line does not have the change.

Script Node 24 and later: limit per test Node 22: budget per file
test:unit 30 s 300 s
test:integration 120 s 600 s

The file budget is sized to end a hung file, not to time a test: a file such as tasks-cli.test.ts starts the Hardhat CLI 37 times across its 33 tests and, on a loaded machine, can run for minutes with every test passing. So on Node 22 a hung test is reported as a cancelled file after up to 10 minutes (5 for a unit file), not as a failed test. The same tests run on Node 24 and 26, where the runner cancels the hung test by name at its limit. A test's own timeout option and the limits of the CLI helper apply on every version. In CI the job's 15-minute timeout stays the outer limit.

The localstack, examples and live scripts pass one --test-timeout value on every version, and coverage passes none. CI runs the localstack, examples and coverage jobs on Node 24, and live-tests.yml and the live job of promote.yml run test:live on Node 24; the live scripts also run locally, and on Node 22 their value limits each file. test/scripts/node-test.test.ts runs fixture files through the script with limits of a few seconds: a file whose passing tests together run longer than the per-test limit passes on every version, a slow test is cancelled at the per-test limit on Node 24 and later, and on Node 22 its file is cancelled at the budget.

When the Node floor moves to a release that has the change (24.0.0, or a later 22.x release if the 22.x line ever gets it), delete the file budgets and the script, and put --test-timeout back in the package scripts.

Run the tests on the published floor

The published packages' Node.js floor is engines.node in packages/*/package.json (Supported Node.js versions). Developing in the clone needs Node >= 22.18.0 (root devEngines), because the scripts and hooks run .ts files with plain node, and 22.18.0 is the first 22.x release that strips types without a flag. So on the published floor, pnpm test stops with ERR_PNPM_BAD_RUNTIME_VERSION before it runs anything. To run the suite there anyway, for example to reproduce a failure of the CI Test (Linux, Node 22.13.0) job, set two variables:

nvm install 22.13.0   # installs it if needed and switches to it
pnpm_config_runtime_on_fail=ignore NODE_OPTIONS='--import tsx' pnpm test
nvm use               # back to the Node in .nvmrc
  • pnpm_config_runtime_on_fail=ignore stops pnpm from refusing the runtime. pnpm checks devEngines.runtime on pnpm run and pnpm exec too, not only on pnpm install (runtimeOnFail). It has to be the environment variable: the root scripts call pnpm run and pnpm -r run again, and the --runtime-on-fail=ignore flag does not reach those nested calls, while every child process inherits the variable.
  • NODE_OPTIONS='--import tsx' preloads tsx, a devDependency, into every Node process, so the .ts scripts and test files load on a Node that does not strip types. Without it the first script fails with ERR_UNKNOWN_FILE_EXTENSION.

The CI 22.13.0 legs of .github/workflows/ci.yml and ci-all-os.yml run pnpm test with the same two settings. pnpm_config_runtime_on_fail=warn works too: it runs the suite and prints a [WARN] line at each pnpm call. Set either one for this run only; the development floor stays at 22.18.0.

Live transaction matrix

The live suite's coverage is a table in test/live/matrix.ts: every action (a transfer, a deploy, a call, a revert, a replacement, an EIP-7702 delegation and so on) against every transaction type from 0 to 4, plus personal_sign, eth_signTypedData_v4 and eth_sign. Each cell has exactly one decision, and the same decision applies to each configured provider. A cell that one provider could not run would need its own decision and reason. pnpm run docs:live-proof renders Live proof from a Sepolia run: the table with the decision of each cell, then a transaction hash for each live cell and provider.

test/live/matrix.test.ts runs in pnpm test, with no keys and no network. It fails when:

  • a cell has no decision, more than one, or a decision for a cell that does not exist;
  • a live or fork decision names a case that does not cover the cell, a case covers a cell whose decision does not name it, a case runs in another mode than its decision, or a case sends another type than its cells;
  • a fork, refused or n/a decision has no reason, or a reason that does not fit it: reasons (a), (d), (e) and (h) say why a cell cannot run on Sepolia and may only make it fork, (b), (c), (f) and (g) say why the protocol forbids it and may only make it n/a, and (r) only refused;
  • a unit or refused decision, or the unit test a fork decision also names, points to a file that does not exist or that has no it( or test( call with that literal title. A title in a comment, in it.skip( or it.todo(, or in a call with a skip or todo option does not count.

It also tests the per-run check, the balance floor and the renderer on made-up runs. It also checks the committed proof: test/live/proof.json must be for Sepolia, list AWS, Google Cloud and Azure once each, and have a transaction hash for every live cell of each, and docs/live-proof.md must be the page rendered from it. Only a Sepolia run with all three providers configured, all passing, writes the file, so a run with fewer cannot overwrite a complete proof. The two checks are skipped only while the file is missing and docs/live-proof.md is still the hand-written page from before the matrix. The rendered page says it is rendered from test/live/proof.json, so once it is committed, a missing proof fails.

Decisions

Decision Meaning
live A case runs it on Sepolia and in fork mode.
fork A case runs it only in fork mode. The reason says why it cannot run on Sepolia.
unit Only a unit or integration test covers it. The decision names the file and the test.
refused The plugin refuses it before any request, and a unit test checks the refusal. Blob transactions (type 3) are refused.
n/a The protocol does not allow it. The reason quotes the EIP, for example the null destination that EIP-4844 and EIP-7702 forbid in deploys.

The fork-only cases are the self-sends of types 0 and 1, the reverts of types 0, 1 and 4, the replacements of types 0, 1, 2 and 4, and a local account that sends the KMS key's authorization. A replacement turns automine off with evm_setAutomine, sends a 1 wei self-send, sends a second one with the same nonce and double the fees, mines one block, and checks that only the second was mined. Automine is a setting of the whole node, so a replacement case holds a lock that no other provider's case holds at the same time (test/live/helpers/lock.ts). The local sender is a key generated in memory and funded with anvil_setBalance; the KMS key signs its authorization with the account's current nonce, since another account sends it. The reverting type 4 case delegates the account back to LiveCheck from the 3-byte contract and checks the delegation stays applied, since EIP-7702 does not roll back processed authorizations when execution fails.

Cost per run

A Sepolia run sends 15 transactions per provider. In a fork run on 2026-10-02 the live cases used 1,133,870 gas per provider, of which LiveCheck's deploy is about 667,000. That is about 0.0011 ETH per provider at 1 gwei, and about 0.0034 ETH for the three providers. The legacy and EIP-2930 transactions pay at least twice the base fee, so a run costs more than the 1 gwei figure. The fork-only cases cost nothing.

Add a case

  1. Add the case's id to CASE_IDS and its entry to CASES in test/live/matrix.ts, in the place it should run: its mode, its type, the cells it covers, the status and sender its receipts must have, a gas budget above what its transactions use together, and a title for the docs.
  2. Point each cell it covers at it in DECISIONS, with a reason from REASONS for a fork decision.
  3. Add its step to STEPS in test/live/cases.ts. The typecheck fails until every case has one. Send through ProviderRun.mined, which checks the receipt against the case and records it.
  4. Run pnpm test for the completeness check, then pnpm run test:live in fork mode with every provider.
  5. A new live case changes the proof: run the suite on Sepolia, then pnpm run docs:live-proof, and commit test/live/proof.json with docs/live-proof.md.

Live tests in GitHub Actions

.github/workflows/live-tests.yml runs pnpm run test:live on a GitHub-hosted runner with the AWS, Google Cloud and Azure test keys. The job signs in to the three clouds over OIDC, so the repository holds no cloud credential: no access key, no AZURE_CLIENT_SECRET, no service account key.

.github/workflows/promote.yml has a second job in the same environment, Live tests from npm (fork). It runs only when the workflow's live-run input is fork, after the verify job: it runs the suite in fork mode with HARDHAT_KMS_LIVE_SOURCE=registry:<version>, so it signs with the three test keys through the packages users install. It installs the packages once before the first cloud login, which fills npm's cache, and the suite then installs them again with npm_config_offline=true, so nothing is downloaded with credentials. Both release jobs of that workflow wait for it, and a failed or rejected live job stops the promotion. Releasing describes the workflow.

Triggers

  • Manual dispatch, from the Actions tab or with gh workflow run live-tests.yml -f network=fork. The network input is fork (the default: a local anvil fork of Sepolia, which spends nothing) or sepolia (spends Sepolia ETH and writes test/live/proof.json).
  • The label ci:live on a pull request whose branch is in this repository. Adding it runs that pull request's code, always in fork mode. A later push does not run the tests again: remove the label and add it again, which asks for a new approval of the new code. Any other label starts nothing.
  • On a pull request from a fork, the label runs nothing: GitHub gives such a run no OIDC token and no environment secrets, so a small job writes a notice in the run's summary instead. To test it, a maintainer pushes the reviewed commits to a branch of this repository and dispatches the workflow on that branch.

There is no schedule, and no push, plain pull_request or pull_request_target run.

Who approves

The job runs in the live-tests environment, whose required reviewer is the owner. Every run, dispatched or labelled, waits for that approval before it starts, and so does the live job of a promote.yml run with live-run: fork. An approved run executes the code of its branch with the right to sign with the three test keys, so before approving a label run, read the pull request's diff, including any change to the workflow itself, to the test helpers and to the dependencies. A dependency update changes code the diff does not show, since its diff is mostly the lockfile. Then check the run itself:

  • Its commit, on the run page, must be the pull request head you read. A run is pinned to the commit it was started on: if the branch moved after that, the page shows code the run will not execute. Reject such a run, then remove the label and add it again.
  • It must be a Live tests run that you started, with the label or a dispatch, or the Live tests from npm (fork) job of a Promote run that you dispatched from main with live-run: fork. Any workflow on any branch that names environment: live-tests asks for the same approval; reject every other request.

Approving the promote live job also runs the published packages' dependencies as npm resolves them that day, not the lockfile's. They run with the right to sign with the three test keys, as they would for a user.

Agents never dispatch the workflow, never add ci:live and never approve the environment.

Trust

In live-tests.yml only the live job has id-token: write; in promote.yml, live and latest do. Each workflow's default is permissions: {}. Each cloud trusts one token subject, the immutable form that names the environment: repo:aelmanaa@<owner id>/hardhat-kms@<repository id>:environment:live-tests.

Cloud Trusted identity What it may do
AWS An IAM role whose trust policy checks the audience sts.amazonaws.com and that subject kms:Sign and kms:GetPublicKey on the test key
Google Cloud The subject itself, as a principal of a workload identity pool, with no service account Sign with the test key and read its public key
Azure A user-assigned managed identity with a federated credential for that subject Read the test key and sign with it

A run outside the environment gets a token with another subject, which the three clouds refuse. This holds even when a pull request removes environment: live-tests from the workflow: its run then needs no approval, but it gets no credentials either. The three test keys hold only Sepolia ETH. The azure/login step prints the token's subject in the public log; both ids in it are public (gh api repos/aelmanaa/hardhat-kms shows them) and the subject grants nothing by itself.

The live-tests environment stores identifiers, not credentials. Its secrets are LIVE_AWS_ROLE_ARN, LIVE_GCP_WORKLOAD_IDENTITY_PROVIDER, LIVE_AZURE_CLIENT_ID, LIVE_AZURE_TENANT_ID and the three key variables the suite reads (HARDHAT_KMS_LIVE_AWS_KEY_ID, HARDHAT_KMS_LIVE_GCP_KEY, HARDHAT_KMS_LIVE_AZURE_KEY_ID); its variable LIVE_AWS_REGION gives the AWS region. A HARDHAT_KMS_LIVE_SEPOLIA_RPC_URL secret is optional; without it the suite uses its public RPC. The key variables reach only the step that checks they are set, the balance check and the test step, and the suite's redaction removes them from every failure.

What a run does

  1. Checks out the branch, installs with pnpm install --frozen-lockfile --ignore-scripts and builds, with no dependency cache.
  2. In fork mode, installs anvil from Foundry v1.8.1 with foundry-rs/foundry-toolchain.
  3. Builds test/live/fixture-project, which downloads Solidity 0.8.24 into Hardhat's compiler cache; the suite's own build then finds it there. Steps 1 to 3 are everything the run installs or downloads, and all of it happens before the first cloud login, so no install script and no download runs with credentials.
  4. Fails unless the three key variables are set. The suite skips a provider whose key is empty and still passes, so without this check a missing secret would give a green run that tested fewer providers.
  5. Signs in with aws-actions/configure-aws-credentials, google-github-actions/auth and azure/login (with allow-no-subscriptions, since the identity has a role on one key and none on a subscription).
  6. In Sepolia mode, checks the balances before anything is sent: each of the three accounts must hold the run's floor (balanceFloor in test/live/matrix.ts) at the suite's legacy gas price, and that price must be at most 20 gwei. Otherwise the run fails, naming the provider, the address and how much ETH is missing. The suite checks each account again, but its providers run in parallel, so without this check two of them could spend ETH on a run that cannot write a proof.
  7. Runs pnpm run test:live.
  8. In Sepolia mode, after a passing run, uploads test/live/proof.json as the live-proof artifact, kept 7 days. The workflow never commits it: download it to test/live/proof.json, run pnpm run docs:live-proof and commit both files in a pull request.

Time, concurrency and cost

  • The job's limit is 30 minutes in fork mode and 45 on Sepolia, counted from when the job starts, after the approval.
  • One live-tests.yml run at a time (concurrency group live-tests; a running job is never cancelled), so two Sepolia runs never race on the accounts' nonces. The fork job of promote.yml is outside that group; a fork run sends nothing to Sepolia. GitHub keeps one more run pending in the group; a newer run replaces a pending one, never the one that runs.
  • Standard GitHub-hosted runners are free for public repositories. A fork run spends no ETH; a Sepolia run spends about 0.0034 ETH at 1 gwei, and up to about twenty times that at the 20 gwei cap (see Cost per run). Each run makes a few dozen signing calls per key: AWS KMS charges about $0.15 per 10,000 of them, so a run costs well under a cent there. The Google Cloud HSM and Azure prices per operation were not checked.

Turnkey smoke test

Turnkey has no sandbox or emulator, so the unit and integration tests replace it with a local stub (packages/hardhat-kms-turnkey/test/helpers/turnkey-stub.ts). Only a run against Turnkey's API shows that the stamp, the request shapes, the error mapping and the setup guide's policies work there. The Free plan includes 25 signatures a month, so this test spends few and runs only when dispatched. It is not in the transaction matrix, in test/live/proof.json or in promote.yml's live job (#513).

packages/hardhat-kms-turnkey/test/live/turnkey.live.test.ts, run with pnpm run test:live:turnkey, is skipped unless five variables are set:

Variable What it holds
TURNKEY_API_PRIVATE_KEY The P-256 private key of a non-root API user of the test organization
TURNKEY_ORGANIZATION_ID The test organization's id
HARDHAT_KMS_LIVE_TURNKEY_ADDRESS An account that the setup guide's policies (step 4) let the API user sign with
HARDHAT_KMS_LIVE_TURNKEY_DENIED_ADDRESS An account in the same organization that no policy covers
HARDHAT_KMS_LIVE_TURNKEY_CONSENSUS_ADDRESS An account under a policy that needs 2 approvers

HARDHAT_KMS_LIVE_TURNKEY_SEPOLIA=1 adds the optional Sepolia send below, through HARDHAT_KMS_LIVE_SEPOLIA_RPC_URL or https://ethereum-sepolia-rpc.publicnode.com.

The cases run in order through the plugin, in a Hardhat runtime with a local simulated network (chain 31337) and four keys on the same API key: the allowed account, the same account with transactionSigning: "digest", the denied account and the consensus account. Nothing is sent to a public chain except the optional Sepolia send.

Case Sign requests Confirms
create_api_keys for the API user itself, with a fresh P-256 public key 0 The guide's credential deny policy: Turnkey must answer 403
The same request with a timestampMs 2 hours old 0 A stale request fails as turnkey.service.timestamp
personal_sign 1 Turnkey hashes the EIP-191 preimage, sent as hex without 0x, with HASH_FUNCTION_KECCAK256 to the digest the core expects
eth_signTypedData_v4, with a nested type and a uint256 1 Turnkey's EIP-712 hash (PAYLOAD_ENCODING_EIP712) equals the core's
kms sign --no-hash of a random digest 1 The HASH_FUNCTION_NO_OP path
kms sign-auth for chain 31337, nonce 0 1 An EIP-7702 authorization
kms sign-tx of types 2, 0 and 4, not sent 3 sign_transaction takes the unsigned transaction without 0x, returns it signed with the same fields, and writes a legacy v as EIP-155
kms sign-tx of type 2 with the transactionSigning: "digest" key 1 The transaction's digest as a NO_OP raw payload
kms sign-tx with the denied account 1 turnkey.service.forbidden, from Turnkey's own HTTP 403 (never its message). The 403 carries no turnkeyErrorCode; the note records whether one came. A policy that allows only SIGN_RAW_PAYLOAD answering 403 to a transaction is not tested here: #533 covers it with the eth.tx policies
kms sign --no-hash of a random digest with the consensus account 1 turnkey.activity.approval-needed with a UUID activity id; an approval later yields only a signature of random bytes
Optional: one EIP-1559 transaction of 0 wei from the allowed account to itself, on Sepolia 1 A transaction Turnkey signed is mined. Skipped unless asked for, when the account holds too little ETH, or above a 20 gwei fee

The consensus case prints the first block of the pending activity's id: reject that activity in the Turnkey dashboard after each run (Reject the pending activity). If create_api_keys ends any other way than the expected answer (a clean 403, or turnkey.service.timestamp for the stale request), the key may exist, also when Turnkey added it and the answer was lost. The test then lists the API user's keys with get_api_keys, a query that policies do not restrict ("all users have implicit GET (read) permissions in their own Organization", Policies overview), deletes every key with the throwaway's name (hardhat-kms-smoke-deny-check) or public key, and fails with CREDENTIAL DENY POLICY DID NOT HOLD or CREDENTIAL CHECK INCONCLUSIVE, telling you to check the API user's keys in the dashboard and delete any you did not create. It never prints a key or a key id. Fix the deny policy before any other run.

The harness is packages/hardhat-kms-turnkey/test/live/smoke.ts:

  • A fetch wrapper counts each new body sent to sign_raw_payload or sign_transaction as a signature, including denied and pending ones and the core's fresh attempts. A retry of the same body is not counted again: Turnkey answers it with the same activity. The run sends at most 11 (SIGNATURE_CAP); the 12th is refused before it leaves the process and the case fails with the count. Requests start at least 1.1 seconds apart, for the Free plan's rate limit of 1 a second.
  • A 429 SIGNING_QUOTA_EXCEEDED, reported by the plugin as turnkey.service.quota, ends the run as "quota used up": that case and every later one are skipped, not failed, and the run writes no record.
  • It records, without values: each request's path, HTTP status, Turnkey error code, activity status and latency; for each signature the length of r and s in hex characters, the form of v, whether 0x came back, whether s was high; for each signed transaction its type and, for a legacy one, whether v was EIP-155; and one scrubbed answer per activity status and per error status, with keys and enum values only, to tighten the stub. The record is printed, appended to the job summary, and, when every case passed or was skipped on purpose, written to test/live/turnkey-smoke.json. pnpm run docs:live-proof takes that file's date, commit and count for the Turnkey line of Live proof; proof.json and its check stay those of the three clouds.
  • Failures and the printed record go through liveRedactor, which removes the API private key, the organization id and the derived API public key by value, in any case, the denied and consensus addresses with and without 0x, every UUID (activity and user ids), and every run of 64 or more hex characters. The pinned account stays, since the plugin's errors name it. kms tasks run with their text output dropped, since it would hold signatures and signed transactions.

pnpm test runs the harness offline: packages/hardhat-kms-turnkey/test/unit/live-smoke.test.ts drives the real adapter through the wrapper against the stub (11 signatures pass, the 12th is never sent; a retried body counts once; a quota 429 gives "quota used up" and skips the next case; the redaction removes a planted 64-hex-character API key, a UUID organization id, an activity id and the other two accounts), and test/integration/live-smoke.test.ts runs every case against the stub, which answers for the policies, and expects them to pass with 10 signatures.

Turnkey live findings

What the first run in GitHub Actions saw of Turnkey's API (2026-10-18, turnkey-live.yml), which the stub now copies:

  • A 403 from a policy has no turnkeyErrorCode: the top-level field is an empty string, and its one details entry holds the policy evaluations (policyId, outcome), with no code. The plugin maps a 403 to turnkey.service.forbidden from the status alone, so it never depended on a code. The stub's turnkeyPolicyDenied() answers in this shape.
  • A request whose timestampMs is 2 hours old gets HTTP 400, not 401, with empty details and an empty turnkeyErrorCode. The plugin reads the timestamp from the message, so it still reports turnkey.service.timestamp.

Turnkey smoke test in GitHub Actions

.github/workflows/turnkey-live.yml runs the smoke test on a GitHub-hosted runner. It has a workflow_dispatch trigger only: no schedule, no pull request run, and promote.yml does not run it. Dispatch it from the Actions tab or with:

gh workflow run turnkey-live.yml --ref <branch or tag>
gh workflow run turnkey-live.yml --ref <branch or tag> -f sepolia-send=true

The job runs in the turnkey-live environment, whose required reviewer is the owner, so every run waits for approval; approve only a run you dispatched, on a commit you read. Agents never dispatch it and never approve it. The environment holds:

  • the secrets TURNKEY_API_PRIVATE_KEY and TURNKEY_ORGANIZATION_ID;
  • the variables TURNKEY_ADDRESS (the allowed account), TURNKEY_DENIED_ADDRESS (no policy) and TURNKEY_CONSENSUS_ADDRESS (the 2-approver policy).

A step fails the run when one of the five is empty, since the test would skip itself and pass. The secrets reach that step and the test step only. The job has contents: read and no OIDC token; everything is installed and built before a step gets the key. After a passing run, the job uploads test/live/turnkey-smoke.json as the turnkey-smoke artifact, kept 7 days. The workflow never commits it. Download it, render the page and commit both files in a pull request:

gh run download <run id> -n turnkey-smoke -D test/live
pnpm run docs:live-proof

The API key belongs to a non-root user whose policies allow signing with one test account and deny credential changes, in a test organization on its own email address, so its blast radius is that organization. Give it a 90-day expiry and rotate it as the setup guide shows.

Cost per run: 10 of the Free plan's 25 signatures a month, 11 with sepolia-send, if Turnkey counts the denied and pending requests; the count assumes it does. That leaves room for two runs a month. With sepolia-send, the transaction costs 21,000 gas, about 0.00002 ETH at 1 gwei. The runner is free for a public repository. One run at a time (concurrency group turnkey-live), with a 20-minute limit from the start of the job.