Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Cleanup sandbox dependent tests #3861

Merged
merged 60 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
b93d531
Initial cleanup
PhilWindle Jan 5, 2024
db662e8
Formatting
PhilWindle Jan 5, 2024
7076ee6
Formatting
PhilWindle Jan 5, 2024
3453dce
Cleanup
PhilWindle Jan 5, 2024
a30be6a
Fixes
PhilWindle Jan 5, 2024
28a1ef5
Fixes
PhilWindle Jan 5, 2024
9231590
Extract accounts out of aztecjs into new package and update imports
spalladino Jan 4, 2024
e370f7b
Remove unneeded types in package.common
spalladino Jan 4, 2024
431f72b
Fix sample-dapp tests
spalladino Jan 5, 2024
ef4c2ba
Remove web build from accounts package
spalladino Jan 5, 2024
d8c2892
Build web package specific for e2e tests
spalladino Jan 5, 2024
3378e09
Fix package local json
spalladino Jan 5, 2024
695bccc
Order tsconfig refs
spalladino Jan 5, 2024
1b0a10b
Update readmes
spalladino Jan 5, 2024
b71c0e6
Format
spalladino Jan 5, 2024
88fb559
Fix links in docs
spalladino Jan 5, 2024
2774060
Update docs content
spalladino Jan 5, 2024
4504a69
Fix boxes and format
spalladino Jan 5, 2024
867350a
Remove unused web build entrypoint for account package
spalladino Jan 5, 2024
362f4d8
Add accounts api reference to docsite
spalladino Jan 5, 2024
b9bbe1f
Fixes
PhilWindle Jan 5, 2024
2d942fb
Fixes
PhilWindle Jan 5, 2024
74a2193
Fixes
PhilWindle Jan 5, 2024
6fb4248
Fix
PhilWindle Jan 5, 2024
e8c44ab
Fixes
PhilWindle Jan 5, 2024
74149e2
Fixes
PhilWindle Jan 6, 2024
ea1d635
Formatting
PhilWindle Jan 6, 2024
1896b72
More cleanup
PhilWindle Jan 8, 2024
796a6bd
More cleanup
PhilWindle Jan 8, 2024
940b161
More cleanup
PhilWindle Jan 8, 2024
d96bae8
Merge branch 'palla/accounts-out-of-aztecjs' into pw/cleanup-tests
PhilWindle Jan 8, 2024
c1c5a81
Merge cleanup
PhilWindle Jan 8, 2024
463c858
More cleanup
PhilWindle Jan 8, 2024
a1ac6bc
Merge branch 'master' into pw/cleanup-tests
PhilWindle Jan 8, 2024
8c00e6c
Formatting
PhilWindle Jan 8, 2024
74d179a
Removed debug comment
PhilWindle Jan 8, 2024
4c169f3
Fixes
PhilWindle Jan 8, 2024
2f38742
Merge branch 'master' into pw/cleanup-tests
PhilWindle Jan 8, 2024
848497c
Fixes
PhilWindle Jan 8, 2024
29a2aa7
Merge branch 'pw/cleanup-tests' of github.com:AztecProtocol/aztec-pac…
PhilWindle Jan 8, 2024
9247064
Formatting
PhilWindle Jan 8, 2024
2b01828
Fixes
PhilWindle Jan 8, 2024
53ecc7c
Formatting
PhilWindle Jan 8, 2024
2e7d550
Formatting
PhilWindle Jan 8, 2024
3f68a96
More cleanup
PhilWindle Jan 8, 2024
b5334bd
Fixes
PhilWindle Jan 8, 2024
c237ea1
Another fix
PhilWindle Jan 8, 2024
b54ec49
More cleanup
PhilWindle Jan 8, 2024
1881d06
Cleanup
PhilWindle Jan 8, 2024
0c3355c
Formatting
PhilWindle Jan 8, 2024
0d36628
Cleanup
PhilWindle Jan 8, 2024
b011582
Fixes
PhilWindle Jan 9, 2024
224c50b
More cleanup
PhilWindle Jan 9, 2024
7003e5a
Merge branch 'master' into pw/cleanup-tests
PhilWindle Jan 9, 2024
5a01b07
Formatting
PhilWindle Jan 9, 2024
df057ed
Fix
PhilWindle Jan 9, 2024
2cde2bd
Formatting
PhilWindle Jan 9, 2024
a3b13f1
Fixes
PhilWindle Jan 9, 2024
9a54b82
Formatting
PhilWindle Jan 9, 2024
bdaae06
Merge branch 'master' into pw/cleanup-tests
PhilWindle Jan 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ jobs:
name: "Test"
command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose-no-sandbox.yml TEST=e2e_p2p_network.test.ts

e2e-browser-sandbox:
e2e-browser:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
Expand All @@ -791,7 +791,7 @@ jobs:
name: "Test"
command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose.yml TEST=e2e_card_game.test.ts

pxe-sandbox:
pxe:
docker:
- image: aztecprotocol/alpine-build-image
resource_class: small
Expand Down Expand Up @@ -1206,9 +1206,9 @@ workflows:
- integration-l1-publisher: *e2e_test
- integration-archiver-l1-to-l2: *e2e_test
- e2e-p2p: *e2e_test
- e2e-browser-sandbox: *e2e_test
- e2e-browser: *e2e_test
- e2e-card-game: *e2e_test
- pxe-sandbox: *e2e_test
- pxe: *e2e_test
- cli-docs-sandbox: *e2e_test
- guides-writing-an-account-contract: *e2e_test
- guides-dapp-testing: *e2e_test
Expand Down Expand Up @@ -1242,9 +1242,9 @@ workflows:
- integration-l1-publisher
- integration-archiver-l1-to-l2
- e2e-p2p
- e2e-browser-sandbox
- e2e-browser
- e2e-card-game
- pxe-sandbox
- pxe
- cli-docs-sandbox
- guides-writing-an-account-contract
- guides-dapp-testing
Expand Down
11 changes: 11 additions & 0 deletions boxes/blank-react/src/environment/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createPXEClient, waitForPXE } from '@aztec/aztec.js';

const { PXE_URL = 'http://localhost:8080' } = process.env;

// assumes environment is running locally, which this script does not trigger
// as well as anvil. anvil can be started with yarn test:integration
export const setupEnvironment = async () => {
const pxe = createPXEClient(PXE_URL);
await waitForPXE(pxe);
return pxe;
};
4 changes: 2 additions & 2 deletions boxes/blank-react/src/scripts/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AccountWallet, CompleteAddress, Fr, FunctionArtifact, PXE, encodeArguments } from '@aztec/aztec.js';

import { getSandboxAccountsWallets } from '@aztec/accounts/testing';
import { getInitialTestAccountsWallets } from '@aztec/accounts/testing';

export function convertArgs(functionAbi: FunctionArtifact, args: any): Fr[] {
const untypedArgs = functionAbi.parameters.map(param => {
Expand All @@ -27,7 +27,7 @@ export function convertArgs(functionAbi: FunctionArtifact, args: any): Fr[] {
* @returns
*/
export async function getWallet(account: CompleteAddress, pxe: PXE): Promise<AccountWallet> {
const accountWallets: AccountWallet[] = await getSandboxAccountsWallets(pxe);
const accountWallets: AccountWallet[] = await getInitialTestAccountsWallets(pxe);
const selectedWallet: AccountWallet = accountWallets.find(w => w.getAddress().equals(account.address))!;
if (!selectedWallet) {
throw new Error(`Wallet for account ${account.address.toShortString()} not found in the PXE.`);
Expand Down
14 changes: 2 additions & 12 deletions boxes/blank-react/src/tests/blank.contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,11 @@ import {
TxStatus,
Wallet,
createDebugLogger,
createPXEClient,
waitForSandbox,
} from '@aztec/aztec.js';
import { setupEnvironment } from '../environment/index.js';

const logger = createDebugLogger('aztec:http-pxe-client');

// assumes sandbox is running locally, which this script does not trigger
// as well as anvil. anvil can be started with yarn test:integration
const setupSandbox = async () => {
const { PXE_URL = 'http://localhost:8080' } = process.env;
const pxe = createPXEClient(PXE_URL);
await waitForSandbox(pxe);

return pxe;
};

async function deployZKContract(owner: CompleteAddress, wallet: Wallet, pxe: PXE) {
logger('Deploying Blank contract...');
Expand All @@ -44,7 +34,7 @@ describe('ZK Contract Tests', () => {
let pxe: PXE;

beforeAll(async () => {
pxe = await setupSandbox();
pxe = await setupEnvironment();
const accounts = await pxe.getRegisteredAccounts();
[owner, _account2, _account3] = accounts;

Expand Down
11 changes: 11 additions & 0 deletions boxes/blank/src/environment/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createPXEClient, waitForPXE } from '@aztec/aztec.js';

const { PXE_URL = 'http://localhost:8080' } = process.env;

// assumes environment is running locally, which this script does not trigger
// as well as anvil. anvil can be started with yarn test:integration
export const setupEnvironment = async () => {
const pxe = createPXEClient(PXE_URL);
await waitForPXE(pxe);
return pxe;
};
8 changes: 4 additions & 4 deletions boxes/blank/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
encodeArguments,
} from '@aztec/aztec.js';

import { getSandboxAccountsWallets } from '@aztec/accounts/testing';
import { getInitialTestAccountsWallets } from '@aztec/accounts/testing';

// docs:end:imports

Expand Down Expand Up @@ -45,7 +45,7 @@ if (typeof document !== 'undefined') {
export async function handleDeployClick(): Promise<string> {
// eslint-disable-next-line no-console
console.log('Deploying Contract');
const [wallet, ..._rest] = await getSandboxAccountsWallets(pxe);
const [wallet, ..._rest] = await getInitialTestAccountsWallets(pxe);

const contractAztecAddress = await deployContract(
wallet.getCompleteAddress(),
Expand All @@ -60,7 +60,7 @@ export async function handleDeployClick(): Promise<string> {
// docs:end:deploy
// docs:start:interact
export async function handleInteractClick(contractAddress: string) {
const [wallet, ..._rest] = await getSandboxAccountsWallets(pxe);
const [wallet, ..._rest] = await getInitialTestAccountsWallets(pxe);
const callArgs = { address: wallet.getCompleteAddress().address };
const getPkAbi = getFunctionAbi(BlankContractArtifact, 'getPublicKey');
const typedArgs = convertArgs(getPkAbi, callArgs);
Expand Down Expand Up @@ -115,7 +115,7 @@ export async function callContractFunction(
* @returns
*/
export async function getWallet(account: CompleteAddress, pxe: PXE): Promise<AccountWallet> {
const accountWallets: AccountWallet[] = await getSandboxAccountsWallets(pxe);
const accountWallets: AccountWallet[] = await getInitialTestAccountsWallets(pxe);
const selectedWallet: AccountWallet = accountWallets.find(w => w.getAddress().equals(account.address))!;
if (!selectedWallet) {
throw new Error(`Wallet for account ${account.address.toShortString()} not found in the PXE.`);
Expand Down
14 changes: 2 additions & 12 deletions boxes/blank/src/tests/blank.contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,11 @@ import {
TxStatus,
Wallet,
createDebugLogger,
createPXEClient,
waitForSandbox,
} from '@aztec/aztec.js';
import { setupEnvironment } from '../environment/index.js';

const logger = createDebugLogger('aztec:blank-box-test');

// assumes sandbox is running locally, which this script does not trigger
// as well as anvil. anvil can be started with yarn test:integration
const setupSandbox = async () => {
const { PXE_URL = 'http://localhost:8080' } = process.env;
const pxe = createPXEClient(PXE_URL);
await waitForSandbox(pxe);
return pxe;
};

async function deployZKContract(owner: CompleteAddress, wallet: Wallet, pxe: PXE) {
logger('Deploying Blank contract...');
const contractAddress = await deployContract(owner, BlankContract.artifact, [], Fr.random(), pxe);
Expand All @@ -43,7 +33,7 @@ describe('ZK Contract Tests', () => {
let pxe: PXE;

beforeAll(async () => {
pxe = await setupSandbox();
pxe = await setupEnvironment();
const accounts = await pxe.getRegisteredAccounts();
[owner, _account2, _account3] = accounts;

Expand Down
11 changes: 11 additions & 0 deletions boxes/token/src/environment/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createPXEClient, waitForPXE } from '@aztec/aztec.js';

const { PXE_URL = 'http://localhost:8080' } = process.env;

// assumes environment is running locally, which this script does not trigger
// as well as anvil. anvil can be started with yarn test:integration
export const setupEnvironment = async () => {
const pxe = createPXEClient(PXE_URL);
await waitForPXE(pxe);
return pxe;
};
4 changes: 2 additions & 2 deletions boxes/token/src/scripts/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AccountWallet, CompleteAddress, Fr, FunctionArtifact, PXE, encodeArguments } from '@aztec/aztec.js';

import { getSandboxAccountsWallets } from '@aztec/accounts/testing';
import { getInitialTestAccountsWallets } from '@aztec/accounts/testing';

function convertBasicArg(paramType: string, value: any) {
switch (paramType) {
Expand Down Expand Up @@ -42,7 +42,7 @@ export function convertArgs(functionAbi: FunctionArtifact, args: any): Fr[] {
* @returns
*/
export async function getWallet(account: CompleteAddress, pxe: PXE): Promise<AccountWallet> {
const accountWallets: AccountWallet[] = await getSandboxAccountsWallets(pxe);
const accountWallets: AccountWallet[] = await getInitialTestAccountsWallets(pxe);
const selectedWallet: AccountWallet = accountWallets.find(w => w.getAddress().equals(account.address))!;
if (!selectedWallet) {
throw new Error(`Wallet for account ${account.address.toShortString()} not found in the PXE.`);
Expand Down
18 changes: 4 additions & 14 deletions boxes/token/src/tests/token.contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,12 @@ import {
computeAuthWitMessageHash,
computeMessageSecretHash,
createDebugLogger,
createPXEClient,
waitForSandbox,
} from '@aztec/aztec.js';

import { getSandboxAccountsWallets } from '@aztec/accounts/testing';
import { getInitialTestAccountsWallets } from '@aztec/accounts/testing';

import { afterEach, beforeAll, expect, jest } from '@jest/globals';

// assumes sandbox is running locally, which this script does not trigger
// as well as anvil. anvil can be started with yarn test:integration
const setupSandbox = async () => {
const { PXE_URL = 'http://localhost:8080' } = process.env;
const pxe = createPXEClient(PXE_URL);
await waitForSandbox(pxe);
return pxe;
};
import { setupEnvironment } from '../environment/index.js';

const TIMEOUT = 60_000;

Expand All @@ -53,10 +43,10 @@ describe('e2e_token_contract', () => {

beforeAll(async () => {
logger = createDebugLogger('box:token_contract_test');
pxe = await setupSandbox();
pxe = await setupEnvironment();
// wallets = await createAccounts(pxe, 3);
accounts = await pxe.getRegisteredAccounts();
wallets = await getSandboxAccountsWallets(pxe);
wallets = await getInitialTestAccountsWallets(pxe);

logger(`Accounts: ${accounts.map(a => a.toReadableString())}`);
logger(`Wallets: ${wallets.map(w => w.getAddress().toString())}`);
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/dev_docs/cli/blank_box.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ The Sandbox runs on `localhost:8080` by default. With the `SANDBOX_URL`, we set

#include_code deploy boxes/blank/src/index.ts typescript

To deploy, it gets one of the pre-initialized wallets that comes with the Sandbox with `getSandboxAccountsWallets`. Using that wallet, the contract ABI, optional salt (used to deterministically calculate the contract address, like [CREATE2 in Ethereum](https://docs.openzeppelin.com/cli/2.8/deploying-with-create2)), and the PXE, we can create a contract deployment transaction and send it to the sandbox network. The constructor defined in the Blank contract doesn't take any arguments, so we pass an empty array.
To deploy, it gets one of the pre-initialized wallets that comes with the Sandbox with `getInitialTestAccountsWallets`. Using that wallet, the contract ABI, optional salt (used to deterministically calculate the contract address, like [CREATE2 in Ethereum](https://docs.openzeppelin.com/cli/2.8/deploying-with-create2)), and the PXE, we can create a contract deployment transaction and send it to the sandbox network. The constructor defined in the Blank contract doesn't take any arguments, so we pass an empty array.

With the web interface running, open your browser dev tools console, click the "Deploy" button and see the successfully deployed contract address. In the terminal or Docker logs where your sandbox is running, you will see transaction and block production info printed.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ Open `cross_chain_messaging.test.ts` and paste the initial description of the te

```typescript
import { expect, jest} from '@jest/globals'
import { AccountWallet, AztecAddress, DebugLogger, EthAddress, Fr, computeAuthWitMessageHash, createDebugLogger, createPXEClient, waitForSandbox } from '@aztec/aztec.js';
import { getSandboxAccountsWallets } from '@aztec/accounts/testing';
import { AccountWallet, AztecAddress, DebugLogger, EthAddress, Fr, computeAuthWitMessageHash, createDebugLogger, createPXEClient, waitForPXE } from '@aztec/aztec.js';
import { getInitialTestAccountsWallets } from '@aztec/accounts/testing';
import { TokenContract } from '@aztec/noir-contracts/Token';
import { TokenBridgeContract } from '@aztec/noir-contracts/TokenBridge';

Expand Down Expand Up @@ -120,8 +120,8 @@ describe('e2e_cross_chain_messaging', () => {
beforeEach(async () => {
logger = createDebugLogger('aztec:e2e_uniswap');
const pxe = createPXEClient(PXE_URL);
await waitForSandbox(pxe);
const wallets = await getSandboxAccountsWallets(pxe);
await waitForPXE(pxe);
const wallets = await getInitialTestAccountsWallets(pxe);

const walletClient = createWalletClient({
account: hdAccount,
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/dev_docs/tutorials/uniswap/typescript_glue_code.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ import {
computeAuthWitMessageHash,
createDebugLogger,
createPXEClient,
waitForSandbox,
waitForPXE,
} from "@aztec/aztec.js";
import { getSandboxAccountsWallets } from '@aztec/accounts/testing';
import { getInitialTestAccountsWallets } from '@aztec/accounts/testing';
import {
Chain,
HttpTransport,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ Create a new file `src/deploy.mjs`:
```js
// src/deploy.mjs
import { writeFileSync } from 'fs';
import { Contract, ContractDeployer, createPXEClient, getSandboxAccountsWallets } from '@aztec/aztec.js';
import { getSandboxAccountsWallets } from '@aztec/accounts/testing';
import { Contract, ContractDeployer, createPXEClient } from '@aztec/aztec.js';
import { getInitialTestAccountsWallets } from '@aztec/accounts/testing';
import TokenContractArtifact from "../contracts/token/target/Token.json" assert { type: "json" };

#include_code dapp-deploy yarn-project/end-to-end/src/sample-dapp/deploy.mjs raw
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ const wallet = await getSchnorrAccount(
).getWallet();
```

For ease of use, `accounts` also ships with a helper `getSandboxAccountsWallets` method that returns a wallet for each of the pre-initialized accounts in the Sandbox, so you can send transactions as any of them.
For ease of use, `accounts` also ships with a helper `getInitialTestAccountsWallets` method that returns a wallet for each of the pre-initialized accounts in the Sandbox, so you can send transactions as any of them.

```js
import { getSandboxAccountsWallets } from '@aztec/accounts/testing';
import { getInitialTestAccountsWallets } from '@aztec/accounts/testing';
```

We'll use one of these wallets to initialize the `Contract` instance that represents our private token contract, so every transaction sent through it will be sent through that wallet.
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/dev_docs/tutorials/writing_dapp/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
computeMessageSecretHash,
createAccount,
createPXEClient,
waitForSandbox,
waitForPXE,
} from "@aztec/aztec.js";
import { TokenContractArtifact } from "@aztec/noir-contracts/Token";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,56 @@ import { Fr, GrumpkinScalar } from '@aztec/foundation/fields';
import { PXE } from '@aztec/types';

import { getSchnorrAccount } from '../schnorr/index.js';
import { generatePublicKey } from '@aztec/aztec.js';

export const INITIAL_SANDBOX_ENCRYPTION_KEYS = [
export const INITIAL_TEST_ENCRYPTION_KEYS = [
GrumpkinScalar.fromString('2153536ff6628eee01cf4024889ff977a18d9fa61d0e414422f7681cf085c281'),
GrumpkinScalar.fromString('aebd1b4be76efa44f5ee655c20bf9ea60f7ae44b9a7fd1fd9f189c7a0b0cdae'),
GrumpkinScalar.fromString('0f6addf0da06c33293df974a565b03d1ab096090d907d98055a8b7f4954e120c'),
];

export const INITIAL_SANDBOX_SIGNING_KEYS = INITIAL_SANDBOX_ENCRYPTION_KEYS;
export const INITIAL_TEST_SIGNING_KEYS = INITIAL_TEST_ENCRYPTION_KEYS;

export const INITIAL_SANDBOX_SALTS = [Fr.ZERO, Fr.ZERO, Fr.ZERO];
export const INITIAL_TEST_ACCOUNT_SALTS = [Fr.ZERO, Fr.ZERO, Fr.ZERO];

/**
* Gets a collection of wallets for the Aztec accounts that are initially stored in the sandbox.
* Gets a collection of wallets for the Aztec accounts that are initially stored in the test environment.
* @param pxe - PXE instance.
* @returns A set of AccountWallet implementations for each of the initial accounts.
*/
export function getSandboxAccountsWallets(pxe: PXE): Promise<AccountWalletWithPrivateKey[]> {
export function getInitialTestAccountsWallets(pxe: PXE): Promise<AccountWalletWithPrivateKey[]> {
return Promise.all(
INITIAL_SANDBOX_ENCRYPTION_KEYS.map((encryptionKey, i) =>
getSchnorrAccount(pxe, encryptionKey!, INITIAL_SANDBOX_SIGNING_KEYS[i]!, INITIAL_SANDBOX_SALTS[i]).getWallet(),
INITIAL_TEST_ENCRYPTION_KEYS.map((encryptionKey, i) =>
getSchnorrAccount(pxe, encryptionKey!, INITIAL_TEST_SIGNING_KEYS[i]!, INITIAL_TEST_ACCOUNT_SALTS[i]).getWallet(),
),
);
}

/**
* Deploys the initial set of schnorr signature accounts to the sandbox
* Queries a PXE for it's registered accounts and returns wallets for those accounts using keys in the initial test accounts.
* @param pxe - PXE instance.
* @returns A set of AccountWallet implementations for each of the initial accounts.
*/
export async function getDeployedTestAccountsWallets(pxe: PXE): Promise<AccountWalletWithPrivateKey[]> {
const registeredAccounts = await pxe.getRegisteredAccounts();
return Promise.all(
INITIAL_TEST_ENCRYPTION_KEYS.filter(initialKey => {
const publicKey = generatePublicKey(initialKey);
return registeredAccounts.find(registered => registered.publicKey.equals(publicKey)) != undefined;
}).map((encryptionKey, i) =>
getSchnorrAccount(pxe, encryptionKey!, INITIAL_TEST_SIGNING_KEYS[i]!, INITIAL_TEST_ACCOUNT_SALTS[i]).getWallet(),
),
);
}

/**
* Deploys the initial set of schnorr signature accounts to the test environment
* @param pxe - PXE instance.
* @returns The set of deployed Account objects and associated private encryption keys
*/
export async function deployInitialSandboxAccounts(pxe: PXE) {
const accounts = INITIAL_SANDBOX_ENCRYPTION_KEYS.map((privateKey, i) => {
const account = getSchnorrAccount(pxe, privateKey, INITIAL_SANDBOX_SIGNING_KEYS[i], INITIAL_SANDBOX_SALTS[i]);
export async function deployInitialTestAccounts(pxe: PXE) {
const accounts = INITIAL_TEST_ENCRYPTION_KEYS.map((privateKey, i) => {
const account = getSchnorrAccount(pxe, privateKey, INITIAL_TEST_SIGNING_KEYS[i], INITIAL_TEST_ACCOUNT_SALTS[i]);
return {
account,
privateKey,
Expand Down
Loading