Skip to content

Commit ae5126a

Browse files
authored
fix: Docs example e2e test (#5456)
The docs example script was not running in CCI due to a misconfigured test name in the ci configuration. On top of that, the test command for e2e tests had a passWithNoTests flag, so this failed silently. Also, there were no tests defined on the test file, as it was just a script and the describe block was missing. And last, the test was outdated, as it was calling a function with a wrong number of arguments and another function that no longer existed in the token contract. This PR fixes all of the above.
1 parent 0e0748c commit ae5126a

File tree

3 files changed

+37
-32
lines changed

3 files changed

+37
-32
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ jobs:
10131013
- *setup_env
10141014
- run:
10151015
name: "Test"
1016-
command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose.yml TEST=pxe_sandbox.test.ts
1016+
command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose.yml TEST=pxe.test.ts
10171017
aztec_manifest_key: end-to-end
10181018
<<: *defaults_e2e_test
10191019

@@ -1033,7 +1033,7 @@ jobs:
10331033
- *setup_env
10341034
- run:
10351035
name: "Test"
1036-
command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose.yml TEST=docs_examples_test.ts
1036+
command: cond_spot_run_compose end-to-end 4 ./scripts/docker-compose.yml TEST=docs_examples.test.ts
10371037
aztec_manifest_key: end-to-end
10381038
<<: *defaults_e2e_test
10391039

yarn-project/end-to-end/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"clean": "rm -rf ./dest .tsbuildinfo",
1212
"formatting": "run -T prettier --check ./src \"!src/web/main.js\" && run -T eslint ./src",
1313
"formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
14-
"test": "DEBUG='aztec:*' NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --runInBand --passWithNoTests --testTimeout=15000 --forceExit",
14+
"test": "DEBUG='aztec:*' NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --runInBand --testTimeout=60000 --forceExit",
1515
"test:integration": "concurrently -k -s first -c reset,dim -n test,anvil \"yarn test:integration:run\" \"anvil\"",
1616
"test:integration:run": "NODE_NO_WARNINGS=1 node --experimental-vm-modules $(yarn bin jest) --no-cache --runInBand --config jest.integration.config.json"
1717
},

yarn-project/end-to-end/src/docs_examples.test.ts

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,42 @@ import { TokenContract, TokenContractArtifact } from '@aztec/noir-contracts.js/T
1010

1111
// docs:end:import_token_contract
1212

13-
// docs:start:define_account_vars
14-
const PXE_URL = process.env.PXE_URL || 'http://localhost:8080';
15-
const encryptionPrivateKey = GrumpkinScalar.random();
16-
const signingPrivateKey = GrumpkinScalar.random();
17-
const pxe = createPXEClient(PXE_URL);
18-
// docs:end:define_account_vars
13+
describe('docs_examples', () => {
14+
it('deploys and interacts with a token contract', async () => {
15+
// docs:start:define_account_vars
16+
const PXE_URL = process.env.PXE_URL || 'http://localhost:8080';
17+
const encryptionPrivateKey = GrumpkinScalar.random();
18+
const signingPrivateKey = GrumpkinScalar.random();
19+
const pxe = createPXEClient(PXE_URL);
20+
// docs:end:define_account_vars
1921

20-
// docs:start:create_wallet
21-
const wallet = await getSchnorrAccount(pxe, encryptionPrivateKey, signingPrivateKey).waitSetup();
22-
// docs:end:create_wallet
22+
// docs:start:create_wallet
23+
const wallet = await getSchnorrAccount(pxe, encryptionPrivateKey, signingPrivateKey).waitSetup();
24+
// docs:end:create_wallet
2325

24-
// docs:start:deploy_contract
25-
const deployedContract = await TokenContract.deploy(
26-
wallet, // wallet instance
27-
wallet.getAddress(), // account
28-
'TokenName', // constructor arg1
29-
'TokenSymbol', // constructor arg2
30-
18,
31-
) // constructor arg3
32-
.send()
33-
.deployed();
34-
// docs:end:deploy_contract
26+
// docs:start:deploy_contract
27+
const deployedContract = await TokenContract.deploy(
28+
wallet, // wallet instance
29+
wallet.getAddress(), // account
30+
'TokenName', // constructor arg1
31+
'TokenSymbol', // constructor arg2
32+
18,
33+
) // constructor arg3
34+
.send()
35+
.deployed();
36+
// docs:end:deploy_contract
3537

36-
// docs:start:get_contract
37-
const contract = await Contract.at(deployedContract.address, TokenContractArtifact, wallet);
38-
// docs:end:get_contract
38+
// docs:start:get_contract
39+
const contract = await Contract.at(deployedContract.address, TokenContractArtifact, wallet);
40+
// docs:end:get_contract
3941

40-
// docs:start:send_transaction
41-
const _tx = await contract.methods.transfer(1, wallet).send().wait();
42-
// docs:end:send_transaction
42+
// docs:start:send_transaction
43+
const _tx = await contract.methods.mint_public(wallet.getAddress(), 1).send().wait();
44+
// docs:end:send_transaction
4345

44-
// docs:start:call_view_function
45-
const _balance = await contract.methods.get_balance(wallet.getAddress()).view();
46-
// docs:end:call_view_function
46+
// docs:start:call_view_function
47+
const balance = await contract.methods.balance_of_public(wallet.getAddress()).view();
48+
expect(balance).toEqual(1n);
49+
// docs:end:call_view_function
50+
}, 120_000);
51+
});

0 commit comments

Comments
 (0)