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

fix: Docs example e2e test #5456

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ jobs:
- *setup_env
- run:
name: "Test"
command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose.yml TEST=docs_examples_test.ts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof

command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose.yml TEST=docs_examples.test.ts
aztec_manifest_key: end-to-end
<<: *defaults_e2e_test

Expand Down
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"clean": "rm -rf ./dest .tsbuildinfo",
"formatting": "run -T prettier --check ./src \"!src/web/main.js\" && run -T eslint ./src",
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
"test": "DEBUG='aztec:*' NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --runInBand --passWithNoTests --testTimeout=15000 --forceExit",
"test": "DEBUG='aztec:*' NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --runInBand --testTimeout=60000 --forceExit",
"test:integration": "concurrently -k -s first -c reset,dim -n test,anvil \"yarn test:integration:run\" \"anvil\"",
"test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --config jest.integration.config.json"
},
Expand Down
63 changes: 34 additions & 29 deletions yarn-project/end-to-end/src/docs_examples.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,42 @@ import { TokenContract, TokenContractArtifact } from '@aztec/noir-contracts.js/T

// docs:end:import_token_contract

// docs:start:define_account_vars
const PXE_URL = process.env.PXE_URL || 'http://localhost:8080';
const encryptionPrivateKey = GrumpkinScalar.random();
const signingPrivateKey = GrumpkinScalar.random();
const pxe = createPXEClient(PXE_URL);
// docs:end:define_account_vars
describe('docs_examples', () => {
it('deploys and interacts with a token contract', async () => {
// docs:start:define_account_vars
const PXE_URL = process.env.PXE_URL || 'http://localhost:8080';
const encryptionPrivateKey = GrumpkinScalar.random();
const signingPrivateKey = GrumpkinScalar.random();
const pxe = createPXEClient(PXE_URL);
// docs:end:define_account_vars

// docs:start:create_wallet
const wallet = await getSchnorrAccount(pxe, encryptionPrivateKey, signingPrivateKey).waitSetup();
// docs:end:create_wallet
// docs:start:create_wallet
const wallet = await getSchnorrAccount(pxe, encryptionPrivateKey, signingPrivateKey).waitSetup();
// docs:end:create_wallet

// docs:start:deploy_contract
const deployedContract = await TokenContract.deploy(
wallet, // wallet instance
wallet.getAddress(), // account
'TokenName', // constructor arg1
'TokenSymbol', // constructor arg2
18,
) // constructor arg3
.send()
.deployed();
// docs:end:deploy_contract
// docs:start:deploy_contract
const deployedContract = await TokenContract.deploy(
wallet, // wallet instance
wallet.getAddress(), // account
'TokenName', // constructor arg1
'TokenSymbol', // constructor arg2
18,
) // constructor arg3
.send()
.deployed();
// docs:end:deploy_contract

// docs:start:get_contract
const contract = await Contract.at(deployedContract.address, TokenContractArtifact, wallet);
// docs:end:get_contract
// docs:start:get_contract
const contract = await Contract.at(deployedContract.address, TokenContractArtifact, wallet);
// docs:end:get_contract

// docs:start:send_transaction
const _tx = await contract.methods.transfer(1, wallet).send().wait();
// docs:end:send_transaction
// docs:start:send_transaction
const _tx = await contract.methods.mint_public(wallet.getAddress(), 1).send().wait();
// docs:end:send_transaction

// docs:start:call_view_function
const _balance = await contract.methods.get_balance(wallet.getAddress()).view();
// docs:end:call_view_function
// docs:start:call_view_function
const balance = await contract.methods.balance_of_public(wallet.getAddress()).view();
expect(balance).toEqual(1n);
// docs:end:call_view_function
}, 120_000);
});
Loading