Skip to main content

Module: testing

The @aztec/accounts/testing export provides utility methods for testing, in particular in a Sandbox environment.

Use the createAccount and createAccounts methods to create new sample accounts for testing, or use getInitialTestAccountsWallets to obtain a list of wallets for the Sandbox pre-seeded accounts.

Variables

INITIAL_TEST_ACCOUNT_SALTS

Const INITIAL_TEST_ACCOUNT_SALTS: Fr[]


INITIAL_TEST_ENCRYPTION_KEYS

Const INITIAL_TEST_ENCRYPTION_KEYS: Fq[]


INITIAL_TEST_SECRET_KEYS

Const INITIAL_TEST_SECRET_KEYS: Fr[]


INITIAL_TEST_SIGNING_KEYS

Const INITIAL_TEST_SIGNING_KEYS: Fq[] = INITIAL_TEST_ENCRYPTION_KEYS

Functions

createAccount

createAccount(pxe): Promise<AccountWalletWithSecretKey>

Deploys and registers a new account using random private keys and returns the associated Schnorr account wallet. Useful for testing.

Parameters

NameTypeDescription
pxePXEPXE.

Returns

Promise<AccountWalletWithSecretKey>

  • A wallet for a fresh account.

createAccounts

createAccounts(pxe, numberOfAccounts?, secrets?): Promise<AccountWalletWithSecretKey[]>

Creates a given number of random accounts using the Schnorr account wallet.

Parameters

NameTypeDefault valueDescription
pxePXEundefinedPXE.
numberOfAccountsnumber1How many accounts to create.
secretsFr[][]Optional array of secrets to use for the accounts. If empty, random secrets will be generated.

Returns

Promise<AccountWalletWithSecretKey[]>

The created account wallets.

Throws

If the secrets array is not empty and does not have the same length as the number of accounts.


deployInitialTestAccounts

deployInitialTestAccounts(pxe): Promise<{ account: AccountManager ; secretKey: Fr }[]>

Deploys the initial set of schnorr signature accounts to the test environment

Parameters

NameTypeDescription
pxePXEPXE instance.

Returns

Promise<{ account: AccountManager ; secretKey: Fr }[]>

The set of deployed Account objects and associated private encryption keys


getDeployedTestAccountsWallets

getDeployedTestAccountsWallets(pxe): Promise<AccountWalletWithSecretKey[]>

Queries a PXE for it's registered accounts and returns wallets for those accounts using keys in the initial test accounts.

Parameters

NameTypeDescription
pxePXEPXE instance.

Returns

Promise<AccountWalletWithSecretKey[]>

A set of AccountWallet implementations for each of the initial accounts.


getInitialTestAccountsWallets

getInitialTestAccountsWallets(pxe): Promise<AccountWalletWithSecretKey[]>

Gets a collection of wallets for the Aztec accounts that are initially stored in the test environment.

Parameters

NameTypeDescription
pxePXEPXE instance.

Returns

Promise<AccountWalletWithSecretKey[]>

A set of AccountWallet implementations for each of the initial accounts.