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
Name | Type | Description |
---|---|---|
pxe | PXE | PXE. |
Returns
Promise
<AccountWalletWithSecretKey
>
- A wallet for a fresh account.
createAccounts
▸ createAccounts(pxe
, numberOfAccounts?
, secrets?
, waitOpts?
): Promise
<AccountWalletWithSecretKey
[]>
Creates a given number of random accounts using the Schnorr account wallet.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
pxe | PXE | undefined | PXE. |
numberOfAccounts | number | 1 | How many accounts to create. |
secrets | Fr [] | [] | Optional array of secrets to use for the accounts. If empty, random secrets will be generated. |
waitOpts | WaitOpts | undefined | - |
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
Name | Type | Description |
---|---|---|
pxe | PXE | PXE 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
Name | Type | Description |
---|---|---|
pxe | PXE | PXE 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
Name | Type | Description |
---|---|---|
pxe | PXE | PXE instance. |
Returns
Promise
<AccountWalletWithSecretKey
[]>
A set of AccountWallet implementations for each of the initial accounts.