-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR creates an e2e test that can be used against Sepolia. It also sets up an automated job for the test.
- Loading branch information
1 parent
cd5d2df
commit 758c723
Showing
7 changed files
with
237 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
name: Run public testnet test | ||
on: | ||
schedule: | ||
- cron: '00 08 * * 1-5' | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
env: | ||
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
GIT_COMMIT: ${{ github.sha }} | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
|
||
# Uncomment the following to run against Sepolia | ||
# SEQ_PUBLISHER_PRIVATE_KEY: ${{ secrets.SEPOLIA_SEQ_PRIVATE_KEY }} | ||
# PROVER_PUBLISHER_PRIVATE_KEY: ${{ secrets.SEPOLIA_PROVER_PRIVATE_KEY }} | ||
# ETHEREUM_HOST: 'https://sepolia.infura.io/v3/${{ secrets.SEPOLIA_API_KEY }}'; | ||
# L1_CHAIN_ID: '11155111' # Sepolia Chain ID | ||
|
||
jobs: | ||
setup: | ||
uses: ./.github/workflows/setup-runner.yml | ||
with: | ||
username: ${{ github.event.pull_request.user.login || github.actor }} | ||
runner_type: builder-x86 | ||
secrets: inherit | ||
|
||
build: | ||
needs: setup | ||
runs-on: ${{ github.event.pull_request.user.login || github.actor }}-x86 | ||
outputs: | ||
e2e_list: ${{ steps.e2e_list.outputs.list }} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: "${{ env.GIT_COMMIT }}" | ||
|
||
- uses: ./.github/ci-setup-action | ||
with: | ||
concurrency_key: build-test-artifacts-${{ github.actor }} | ||
|
||
- name: "Build E2E Image" | ||
timeout-minutes: 40 | ||
run: | | ||
earthly-ci ./yarn-project+export-e2e-test-images | ||
- name: Create list of devnet end-to-end jobs | ||
id: e2e_list | ||
run: echo "list=$(earthly ls ./yarn-project/end-to-end | grep 'public_testnet' | sed 's/+//' | jq -R . | jq -cs .)" >> $GITHUB_OUTPUT | ||
|
||
e2e: | ||
needs: build | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
test: ${{ fromJson( needs.build.outputs.e2e_list )}} | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: { ref: "${{ env.GIT_COMMIT }}" } | ||
- uses: ./.github/ci-setup-action | ||
- name: Setup and Test | ||
timeout-minutes: 40 | ||
uses: ./.github/ensure-tester-with-images | ||
with: | ||
# big machine since we're doing proving | ||
runner_type: "64core-tester-x86" | ||
builder_type: builder-x86 | ||
# these are copied to the tester and expected by the earthly command below | ||
# if they fail to copy, it will try to build them on the tester and fail | ||
builder_images_to_copy: aztecprotocol/end-to-end:${{ env.GIT_COMMIT }} | ||
# command to produce the images in case they don't exist | ||
builder_command: scripts/earthly-ci ./yarn-project+export-e2e-test-images | ||
run: | | ||
set -eux | ||
cd ./yarn-project/end-to-end/ | ||
export FORCE_COLOR=1 | ||
../../scripts/earthly-ci -P --no-output +${{ matrix.test }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
yarn-project/end-to-end/src/public-testnet/e2e_public_testnet_transfer.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import { createAccounts } from '@aztec/accounts/testing'; | ||
import { type AztecNodeConfig } from '@aztec/aztec-node'; | ||
import { type AztecNode, type DebugLogger, Fr, type PXE } from '@aztec/aztec.js'; | ||
import { NULL_KEY } from '@aztec/ethereum'; | ||
import { EasyPrivateTokenContract } from '@aztec/noir-contracts.js'; | ||
import { type ProverNode, type ProverNodeConfig, getProverNodeConfigFromEnv } from '@aztec/prover-node'; | ||
|
||
import { foundry, sepolia } from 'viem/chains'; | ||
|
||
import { createAndSyncProverNode } from '../fixtures/snapshot_manager.js'; | ||
import { getPrivateKeyFromIndex, setup } from '../fixtures/utils.js'; | ||
|
||
// process.env.SEQ_PUBLISHER_PRIVATE_KEY = '<PRIVATE_KEY_WITH_SEPOLIA_ETH>'; | ||
// process.env.PROVER_PUBLISHER_PRIVATE_KEY = '<PRIVATE_KEY_WITH_SEPOLIA_ETH>'; | ||
// process.env.ETHEREUM_HOST= 'https://sepolia.infura.io/v3/<API_KEY>'; | ||
// process.env.L1_CHAIN_ID = '11155111'; | ||
|
||
describe(`deploys and transfers a private only token`, () => { | ||
let secretKey1: Fr; | ||
let secretKey2: Fr; | ||
let proverConfig: ProverNodeConfig; | ||
let config: AztecNodeConfig; | ||
let aztecNode: AztecNode; | ||
let proverNode: ProverNode; | ||
|
||
let pxe: PXE; | ||
let logger: DebugLogger; | ||
let teardown: () => Promise<void>; | ||
|
||
beforeEach(async () => { | ||
const chainId = !process.env.L1_CHAIN_ID ? foundry.id : +process.env.L1_CHAIN_ID; | ||
const chain = chainId == sepolia.id ? sepolia : foundry; // Not the best way of doing this. | ||
({ logger, pxe, teardown, config, aztecNode } = await setup( | ||
0, | ||
{ skipProtocolContracts: true, stateLoad: undefined }, | ||
{}, | ||
false, | ||
false, | ||
chain, | ||
)); | ||
proverConfig = getProverNodeConfigFromEnv(); | ||
const proverNodePrivateKey = getPrivateKeyFromIndex(2); | ||
proverConfig.publisherPrivateKey = | ||
proverConfig.publisherPrivateKey === NULL_KEY | ||
? `0x${proverNodePrivateKey?.toString('hex')}` | ||
: proverConfig.publisherPrivateKey; | ||
|
||
proverNode = await createAndSyncProverNode( | ||
config.l1Contracts.rollupAddress, | ||
proverConfig.publisherPrivateKey, | ||
config, | ||
aztecNode, | ||
); | ||
}, 600_000); | ||
|
||
afterEach(async () => { | ||
await proverNode.stop(); | ||
await teardown(); | ||
}); | ||
|
||
it('calls a private function', async () => { | ||
const initialBalance = 100000000000n; | ||
const transferValue = 5n; | ||
secretKey1 = Fr.random(); | ||
secretKey2 = Fr.random(); | ||
|
||
logger.info(`Deploying accounts.`); | ||
|
||
const accounts = await createAccounts(pxe, 2, [secretKey1, secretKey2], { | ||
interval: 0.1, | ||
proven: true, | ||
provenTimeout: 600, | ||
}); | ||
|
||
logger.info(`Accounts deployed, deploying token.`); | ||
|
||
const [deployerWallet, recipientWallet] = accounts; | ||
|
||
const token = await EasyPrivateTokenContract.deploy( | ||
deployerWallet, | ||
initialBalance, | ||
deployerWallet.getAddress(), | ||
deployerWallet.getAddress(), | ||
) | ||
.send({ | ||
universalDeploy: true, | ||
skipPublicDeployment: true, | ||
skipClassRegistration: true, | ||
skipInitialization: false, | ||
skipPublicSimulation: true, | ||
}) | ||
.deployed({ | ||
proven: true, | ||
provenTimeout: 600, | ||
}); | ||
|
||
logger.info(`Performing transfer.`); | ||
|
||
await token.methods | ||
.transfer(transferValue, deployerWallet.getAddress(), recipientWallet.getAddress(), deployerWallet.getAddress()) | ||
.send() | ||
.wait({ proven: true, provenTimeout: 600 }); | ||
|
||
logger.info(`Transfer completed`); | ||
|
||
const balanceDeployer = await token.methods.get_balance(deployerWallet.getAddress()).simulate(); | ||
const balanceRecipient = await token.methods.get_balance(recipientWallet.getAddress()).simulate(); | ||
|
||
logger.info(`Deployer balance: ${balanceDeployer}, Recipient balance: ${balanceRecipient}`); | ||
|
||
expect(balanceDeployer).toBe(initialBalance - transferValue); | ||
expect(balanceRecipient).toBe(transferValue); | ||
}, 600_000); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters