From 30a6c6f4707a1953794a77707514bf778eadad74 Mon Sep 17 00:00:00 2001 From: Lydia Garms Date: Mon, 20 Apr 2026 10:23:20 +0100 Subject: [PATCH 1/9] chore(orchestration): only use tx for transaction receipt --- src/boilerplate/common/commitment-storage.mjs | 20 ++++++++----------- src/boilerplate/common/contract.mjs | 4 ++-- .../javascript/raw/toOrchestration.ts | 20 +++++++++---------- 3 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/boilerplate/common/commitment-storage.mjs b/src/boilerplate/common/commitment-storage.mjs index 7b309df17..8814a8e69 100644 --- a/src/boilerplate/common/commitment-storage.mjs +++ b/src/boilerplate/common/commitment-storage.mjs @@ -506,15 +506,13 @@ export async function joinCommitments( const signed = await web3.eth.accounts.signTransaction(txParams, key); - const sendTxn = await web3.eth.sendSignedTransaction(signed.rawTransaction); + const tx = await web3.eth.sendSignedTransaction(signed.rawTransaction); - let tx = await instance.getPastEvents('allEvents', { - fromBlock: sendTxn?.blockNumber || 0, - toBlock: sendTxn?.blockNumber || 'latest', + await instance.getPastEvents('allEvents', { + fromBlock: tx?.blockNumber || 0, + toBlock: tx?.blockNumber || 'latest', }); - tx = tx[0]; - await markNullified(generalise(commitments[0]._id), secretKey.hex(32)); await markNullified(generalise(commitments[1]._id), secretKey.hex(32)); await storeCommitment({ @@ -675,15 +673,13 @@ export async function splitCommitments( const signed = await web3.eth.accounts.signTransaction(txParams, key); - const sendTxn = await web3.eth.sendSignedTransaction(signed.rawTransaction); + const tx = await web3.eth.sendSignedTransaction(signed.rawTransaction); - let tx = await instance.getPastEvents('allEvents', { - fromBlock: sendTxn?.blockNumber || 0, - toBlock: sendTxn?.blockNumber || 'latest', + await instance.getPastEvents('allEvents', { + fromBlock: tx?.blockNumber || 0, + toBlock: tx?.blockNumber || 'latest', }); - tx = tx[0]; - await markNullified(generalise(commitment._id), secretKey.hex(32)); await storeCommitment({ diff --git a/src/boilerplate/common/contract.mjs b/src/boilerplate/common/contract.mjs index 173929f45..856b01061 100644 --- a/src/boilerplate/common/contract.mjs +++ b/src/boilerplate/common/contract.mjs @@ -147,7 +147,7 @@ export async function registerKey( }; const key = config.web3.key; const signed = await web3.eth.accounts.signTransaction(txParams, key); - const sendTxn = await web3.eth.sendSignedTransaction(signed.rawTransaction); + const tx = await web3.eth.sendSignedTransaction(signed.rawTransaction); } const keyJson = { secretKey: secretKey.integer, @@ -156,4 +156,4 @@ export async function registerKey( fs.writeFileSync(keyDb, JSON.stringify(keyJson, null, 4)); return publicKey; -} \ No newline at end of file +} diff --git a/src/boilerplate/orchestration/javascript/raw/toOrchestration.ts b/src/boilerplate/orchestration/javascript/raw/toOrchestration.ts index 80716e8d0..88739d710 100644 --- a/src/boilerplate/orchestration/javascript/raw/toOrchestration.ts +++ b/src/boilerplate/orchestration/javascript/raw/toOrchestration.ts @@ -743,7 +743,7 @@ export const OrchestrationCodeBoilerPlate: any = (node: any) => { } if (node.isConstructor) lines.push( - `\nfs.writeFileSync("/app/orchestration/common/db/constructorTx.json", JSON.stringify(tx, null, 4));`, + `\nfs.writeFileSync("/app/orchestration/common/db/constructorTx.json", JSON.stringify(constructorInput, null, 4));`, ); return { statements: [ @@ -1047,7 +1047,7 @@ export const OrchestrationCodeBoilerPlate: any = (node: any) => { \nBackupData.forEach((element) => { element.cipherText = element.cipherText.map(ct => generalise(ct).hex(32)); }); - \nconst tx = { proofInput: [{customInputs: [${returnInputs}], newNullifiers: ${params[0][0]} commitmentRoot:${params[0][1]} checkNullifiers: ${params[0][3]} newCommitments: ${params[0][2]} cipherText:${params[0][4]} encKeys: ${params[0][5]}}, proof, BackupData], nullifiers: ${params[0][1]} ${publicInputs}};` + \nconst constructorInput = { proofInput: [{customInputs: [${returnInputs}], newNullifiers: ${params[0][0]} commitmentRoot:${params[0][1]} checkNullifiers: ${params[0][3]} newCommitments: ${params[0][2]} cipherText:${params[0][4]} encKeys: ${params[0][5]}}, proof, BackupData], nullifiers: ${params[0][1]} ${publicInputs}};` ] } } @@ -1071,8 +1071,8 @@ export const OrchestrationCodeBoilerPlate: any = (node: any) => { }; } let checkLeaves = - `\n tx = tx[0];\n - \n if (!tx) { + `\n const newLeavesEvent = newLeavesEvents[0];\n + \n if (!newLeavesEvent) { throw new Error( 'Tx failed - the commitment was not accepted on-chain, or the contract is not deployed.'); } \n`; if (!node.newCommitmentsRequired) { @@ -1094,18 +1094,18 @@ export const OrchestrationCodeBoilerPlate: any = (node: any) => { }; \n const key = config.web3.key; \n const signed = await web3.eth.accounts.signTransaction(txParams, key); - \n const sendTxn = await web3.eth.sendSignedTransaction(signed.rawTransaction); - \n let tx = await instance.getPastEvents("NewLeaves", {fromBlock: sendTxn?.blockNumber || 0, toBlock: sendTxn?.blockNumber || 'latest'}); + \n const tx = await web3.eth.sendSignedTransaction(signed.rawTransaction); + \n const newLeavesEvents = await instance.getPastEvents("NewLeaves", {fromBlock: tx?.blockNumber || 0, toBlock: tx?.blockNumber || 'latest'}); ${checkLeaves} let encEvent = ''; \n try { - \n encEvent = await instance.getPastEvents("EncryptedData", {fromBlock: sendTxn?.blockNumber || 0, toBlock: sendTxn?.blockNumber || 'latest'}); + \n encEvent = await instance.getPastEvents("EncryptedData", {fromBlock: tx?.blockNumber || 0, toBlock: tx?.blockNumber || 'latest'}); \n } catch (err) { \n console.log('No encrypted event'); \n} \nlet encBackupEvent = ''; \n try { - \n encBackupEvent = await instance.getPastEvents("EncryptedBackupData", {fromBlock: sendTxn?.blockNumber || 0, toBlock: sendTxn?.blockNumber || 'latest'}); + \n encBackupEvent = await instance.getPastEvents("EncryptedBackupData", {fromBlock: tx?.blockNumber || 0, toBlock: tx?.blockNumber || 'latest'}); \n } catch (err) { \n console.log('No encrypted backup event'); \n}`, @@ -1138,11 +1138,11 @@ export const OrchestrationCodeBoilerPlate: any = (node: any) => { return { statements: [ `\n\n// Save transaction for the constructor: - \nconst tx = { ${lines}}; + \nconst constructorInput = { ${lines}}; \n if (!fs.existsSync("/app/orchestration/common/db")) { \n fs.mkdirSync("/app/orchestration/common/db", { recursive: true }); \n } - \nfs.writeFileSync("/app/orchestration/common/db/constructorTx.json", JSON.stringify(tx, null, 4));` + \nfs.writeFileSync("/app/orchestration/common/db/constructorTx.json", JSON.stringify(constructorInput, null, 4));` ], }; } From f97f07ec3e2b74f4f572481a565de5d488d2a887 Mon Sep 17 00:00:00 2001 From: Lydia Garms Date: Mon, 20 Apr 2026 11:20:49 +0100 Subject: [PATCH 2/9] chore(orchestration): remove sendTxn from unsupported variable names --- src/transformers/visitors/checks/unsupportedVisitor.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/transformers/visitors/checks/unsupportedVisitor.ts b/src/transformers/visitors/checks/unsupportedVisitor.ts index aafcc2d50..9d8b73622 100644 --- a/src/transformers/visitors/checks/unsupportedVisitor.ts +++ b/src/transformers/visitors/checks/unsupportedVisitor.ts @@ -30,7 +30,6 @@ const disallowedVariableNames = new Set([ 'txParams', 'tx', 'signed', - 'sendTxn', 'encEvent', 'encBackupEvent', 'publicReturns', From c5cbd6b021b8f721f8e6835c7c41289eec92d607 Mon Sep 17 00:00:00 2001 From: Lydia Garms Date: Mon, 20 Apr 2026 11:48:48 +0100 Subject: [PATCH 3/9] fix(orchestration): remove unnecessary logic and use newLeavesEvent instead of tx now that tx is the transaction receipt --- src/boilerplate/common/generic-test.mjs | 14 +++++++------- .../common/services/generic-api_services.mjs | 15 ++++++--------- .../services/generic-read-only-api_services.mjs | 1 - .../services/genericpublic-api_services.mjs | 6 ------ .../javascript/raw/boilerplate-generator.ts | 1 - .../javascript/raw/toOrchestration.ts | 6 ++++-- 6 files changed, 17 insertions(+), 26 deletions(-) diff --git a/src/boilerplate/common/generic-test.mjs b/src/boilerplate/common/generic-test.mjs index 3dc337478..d74987ffa 100644 --- a/src/boilerplate/common/generic-test.mjs +++ b/src/boilerplate/common/generic-test.mjs @@ -31,15 +31,15 @@ describe('FUNCTION_NAME', function () { await startEventFilter('CONTRACT_NAME'); // this calls your function! It returns the tx from the shield contract // you can replace the values below - numbers are randomly generated - const { tx , encEvent, encBackupEvent } = await FUNCTION_NAME.FUNCTION_NAME(FUNCTION_SIG_1); + const { tx , newLeavesEvent, encEvent, encBackupEvent } = await FUNCTION_NAME.FUNCTION_NAME(FUNCTION_SIG_1); // prints the tx console.log(tx); // reassigns leafIndex to the index of the first commitment added by this function - if (tx.event) { - leafIndex = tx.returnValues[0]; + if (newLeavesEvent) { + leafIndex = newLeavesEvent.returnValues.minLeafIndex ?? newLeavesEvent.returnValues[0]; // prints the new leaves (commitments) added by this function call console.log(`Merkle tree event returnValues:`); - console.log(tx.returnValues[0]); + console.log(newLeavesEvent.returnValues); } if (encEvent && encEvent[0].event) { encryption.msgs = encEvent[0].returnValues[0]; @@ -71,10 +71,10 @@ describe('FUNCTION_NAME', function () { it('should call FUNCTION_NAME again', async () => { try { // this calls your function a second time for incremental cases - const { tx } = await FUNCTION_NAME.FUNCTION_NAME(FUNCTION_SIG_2); - if (tx.event) { + const { tx, newLeavesEvent } = await FUNCTION_NAME.FUNCTION_NAME(FUNCTION_SIG_2); + if (newLeavesEvent) { console.log(`Merkle tree event returnValues:`); - console.log(tx.returnValues[0]); + console.log(newLeavesEvent.returnValues); } } catch (err) { logger.error(err); diff --git a/src/boilerplate/common/services/generic-api_services.mjs b/src/boilerplate/common/services/generic-api_services.mjs index 0a7ed169c..a5a8a17ad 100644 --- a/src/boilerplate/common/services/generic-api_services.mjs +++ b/src/boilerplate/common/services/generic-api_services.mjs @@ -20,7 +20,6 @@ import web3 from "./common/web3.mjs"; NOTE: if you'd like to keep track of your commitments, check out ./common/db/preimage. Remember to delete this file if you'd like to start fresh with a newly deployed contract. */ const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); -let leafIndex; let encryption = {}; // eslint-disable-next-line func-names @@ -34,23 +33,21 @@ export class ServiceManager{ await this.FUNCTION_NAME.init(); } - async service_FUNCTION_NAME (req, res, next){ + async service_FUNCTION_NAME (req, res, next){ try { await startEventFilter('CONTRACT_NAME'); const FUNCTION_SIG; - const { tx , encEvent, encBackupEvent, _RESPONSE_} = await this.FUNCTION_NAME.FUNCTION_NAME(FUNCTION_SIG); + const { tx , newLeavesEvent, encEvent, encBackupEvent, _RESPONSE_} = await this.FUNCTION_NAME.FUNCTION_NAME(FUNCTION_SIG); // prints the tx console.log(tx); const txSerialized = serializeBigInt(tx); + const newLeavesEventSerialized = serializeBigInt(newLeavesEvent); const encEventSerialized = serializeBigInt(encEvent); const encBackupEventSerialized = serializeBigInt(encBackupEvent); - res.send({ tx: txSerialized, encEvent: encEventSerialized, encBackupEvent: encBackupEventSerialized, _RESPONSE_ }); - // reassigns leafIndex to the index of the first commitment added by this function - if (tx.event) { - leafIndex = tx.returnValues[0]; - // prints the new leaves (commitments) added by this function call + res.send({ tx: txSerialized, newLeavesEvent: newLeavesEventSerialized, encEvent: encEventSerialized, encBackupEvent: encBackupEventSerialized, _RESPONSE_ }); + if (newLeavesEvent) { console.log(`Merkle tree event returnValues:`); - console.log(tx.returnValues); + console.log(newLeavesEvent.returnValues); } if (encEvent.event) { encryption.msgs = encEvent[0].returnValues[0]; diff --git a/src/boilerplate/common/services/generic-read-only-api_services.mjs b/src/boilerplate/common/services/generic-read-only-api_services.mjs index 8e5ecc3bd..1ff7d52cb 100644 --- a/src/boilerplate/common/services/generic-read-only-api_services.mjs +++ b/src/boilerplate/common/services/generic-read-only-api_services.mjs @@ -20,7 +20,6 @@ import web3 from "./common/web3.mjs"; NOTE: if you'd like to keep track of your commitments, check out ./common/db/preimage. Remember to delete this file if you'd like to start fresh with a newly deployed contract. */ const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); -let leafIndex; let encryption = {}; // eslint-disable-next-line func-names diff --git a/src/boilerplate/common/services/genericpublic-api_services.mjs b/src/boilerplate/common/services/genericpublic-api_services.mjs index cef1cf983..655213ce0 100644 --- a/src/boilerplate/common/services/genericpublic-api_services.mjs +++ b/src/boilerplate/common/services/genericpublic-api_services.mjs @@ -6,7 +6,6 @@ import fs from "fs"; import logger from "./common/logger.mjs"; import web3 from "./common/web3.mjs"; const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); -let leafIndex; let encryption = {}; // eslint-disable-next-line func-names async service_FUNCTION_NAME (req, res, next){ @@ -16,9 +15,4 @@ let encryption = {}; console.log(tx); const txSerialized = serializeBigInt(tx); res.send({tx: txSerialized, _RESPONSE_}); - - if (tx.event) { - console.log(tx.returnValues); - } - } diff --git a/src/boilerplate/orchestration/javascript/raw/boilerplate-generator.ts b/src/boilerplate/orchestration/javascript/raw/boilerplate-generator.ts index 5fdb2c983..72de58aee 100644 --- a/src/boilerplate/orchestration/javascript/raw/boilerplate-generator.ts +++ b/src/boilerplate/orchestration/javascript/raw/boilerplate-generator.ts @@ -852,7 +852,6 @@ integrationApiServicesBoilerplate = { minus() cannot be called before an initial add(). */ const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); - let leafIndex; let encryption = {}; // eslint-disable-next-line func-names diff --git a/src/boilerplate/orchestration/javascript/raw/toOrchestration.ts b/src/boilerplate/orchestration/javascript/raw/toOrchestration.ts index 88739d710..78d6dfdbc 100644 --- a/src/boilerplate/orchestration/javascript/raw/toOrchestration.ts +++ b/src/boilerplate/orchestration/javascript/raw/toOrchestration.ts @@ -576,7 +576,7 @@ export const OrchestrationCodeBoilerPlate: any = (node: any) => { rtnparams?.push( ` ${param.replace('_change', '').replace('_newCommitmentValue', '')}_newCommitmentValue : ${param}.integer `); }); if (params) params[params.length - 1] += `,`; - let txReturns = "tx, encEvent, encBackupEvent,"; + let txReturns = "tx, newLeavesEvent, encEvent, encBackupEvent,"; if (node.stateMutability === 'view'){ txReturns = ""; } @@ -1071,7 +1071,7 @@ export const OrchestrationCodeBoilerPlate: any = (node: any) => { }; } let checkLeaves = - `\n const newLeavesEvent = newLeavesEvents[0];\n + `\n newLeavesEvent = newLeavesEvents[0];\n \n if (!newLeavesEvent) { throw new Error( 'Tx failed - the commitment was not accepted on-chain, or the contract is not deployed.'); } \n`; @@ -1096,6 +1096,7 @@ export const OrchestrationCodeBoilerPlate: any = (node: any) => { \n const signed = await web3.eth.accounts.signTransaction(txParams, key); \n const tx = await web3.eth.sendSignedTransaction(signed.rawTransaction); \n const newLeavesEvents = await instance.getPastEvents("NewLeaves", {fromBlock: tx?.blockNumber || 0, toBlock: tx?.blockNumber || 'latest'}); + \n let newLeavesEvent = null; ${checkLeaves} let encEvent = ''; \n try { @@ -1196,6 +1197,7 @@ export const OrchestrationCodeBoilerPlate: any = (node: any) => { \nconst key = config.web3.key; \nconst signed = await web3.eth.accounts.signTransaction(txParams, key); \nconst tx = await web3.eth.sendSignedTransaction(signed.rawTransaction); + \nconst newLeavesEvent = null; \nconst encEvent = {}; \nconst encBackupEvent ={}; ` From 88102f5ea214ba4787242bae6cad10f40b2f0ae8 Mon Sep 17 00:00:00 2001 From: Lydia Garms Date: Mon, 20 Apr 2026 12:05:37 +0100 Subject: [PATCH 4/9] fix(orchestration): remove erroneous intro - this is the intro for the tests --- src/boilerplate/common/services/generic-api_services.mjs | 9 --------- .../common/services/generic-read-only-api_services.mjs | 9 --------- 2 files changed, 18 deletions(-) diff --git a/src/boilerplate/common/services/generic-api_services.mjs b/src/boilerplate/common/services/generic-api_services.mjs index a5a8a17ad..913aa319b 100644 --- a/src/boilerplate/common/services/generic-api_services.mjs +++ b/src/boilerplate/common/services/generic-api_services.mjs @@ -10,15 +10,6 @@ import { getAllCommitments, getCommitmentsByState } from "./common/commitment-st import ServiceManager from './common/serviceManager.mjs' import web3 from "./common/web3.mjs"; -/** - Welcome to your zApp's integration test! - Depending on how your functions interact and the range of inputs they expect, the below may need to be changed. - e.g. Your input contract has two functions, add() and minus(). minus() cannot be called before an initial add() - the compiler won't know this! You'll need to rearrange the below. - e.g. The function add() only takes numbers greater than 100. The compiler won't know this, so you'll need to change the call to add() below. - The transpiler automatically fills in any ZKP inputs for you and provides some dummy values for the original zol function. - NOTE: if any non-secret functions need to be called first, the transpiler won't know! You'll need to add those calls below. - NOTE: if you'd like to keep track of your commitments, check out ./common/db/preimage. Remember to delete this file if you'd like to start fresh with a newly deployed contract. - */ const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); let encryption = {}; // eslint-disable-next-line func-names diff --git a/src/boilerplate/common/services/generic-read-only-api_services.mjs b/src/boilerplate/common/services/generic-read-only-api_services.mjs index 1ff7d52cb..240cc25aa 100644 --- a/src/boilerplate/common/services/generic-read-only-api_services.mjs +++ b/src/boilerplate/common/services/generic-read-only-api_services.mjs @@ -10,15 +10,6 @@ import { getAllCommitments, getCommitmentsByState } from "./common/commitment-st import ServiceManager from './common/serviceManager.mjs' import web3 from "./common/web3.mjs"; -/** - Welcome to your zApp's integration test! - Depending on how your functions interact and the range of inputs they expect, the below may need to be changed. - e.g. Your input contract has two functions, add() and minus(). minus() cannot be called before an initial add() - the compiler won't know this! You'll need to rearrange the below. - e.g. The function add() only takes numbers greater than 100. The compiler won't know this, so you'll need to change the call to add() below. - The transpiler automatically fills in any ZKP inputs for you and provides some dummy values for the original zol function. - NOTE: if any non-secret functions need to be called first, the transpiler won't know! You'll need to add those calls below. - NOTE: if you'd like to keep track of your commitments, check out ./common/db/preimage. Remember to delete this file if you'd like to start fresh with a newly deployed contract. - */ const sleep = (ms) => new Promise((r) => setTimeout(r, ms)); let encryption = {}; // eslint-disable-next-line func-names From 2ee819af04bd71367c4ba5688917c8a623c3cc15 Mon Sep 17 00:00:00 2001 From: Lydia Garms Date: Wed, 15 Apr 2026 11:41:38 +0100 Subject: [PATCH 5/9] fix(deployment): parameter defined twice --- src/codeGenerators/orchestration/files/toOrchestration.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/codeGenerators/orchestration/files/toOrchestration.ts b/src/codeGenerators/orchestration/files/toOrchestration.ts index 951f43540..4f43ebc7c 100644 --- a/src/codeGenerators/orchestration/files/toOrchestration.ts +++ b/src/codeGenerators/orchestration/files/toOrchestration.ts @@ -543,7 +543,7 @@ const prepareMigrationsFile = (file: localFile, node: any) => { } } }); - } else if(constructorParamsIncludesAddr) { + } else if (!node.isConstructor && constructorParamsIncludesAddr) { // for each address in the shield contract constructor... constructorAddrParams.forEach(name => { // we have an address input which is likely not a another contract @@ -556,7 +556,7 @@ const prepareMigrationsFile = (file: localFile, node: any) => { }); } if (node.isConstructor) { - // we have a constructor which requires a proof + // we have a cnstrctr.mjs file if (node.functionNames.includes('cnstrctr') || publicConstructorParams.length > 0) { customProofImport += `const constructorInput = JSON.parse( fs.readFileSync('/app/orchestration/common/db/constructorTx.json', 'utf-8'), From 37569fa56bf45b8f6afa9545a98510cb6fea670a Mon Sep 17 00:00:00 2001 From: Lydia Garms Date: Wed, 15 Apr 2026 12:05:36 +0100 Subject: [PATCH 6/9] fix(tests): use bytes20 which is a supported variable type --- test/real-world-zapps/Voting.zol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/real-world-zapps/Voting.zol b/test/real-world-zapps/Voting.zol index 4a5850999..3b78791ba 100644 --- a/test/real-world-zapps/Voting.zol +++ b/test/real-world-zapps/Voting.zol @@ -5,7 +5,7 @@ pragma solidity ^0.8.0; contract Voting { secret mapping (uint256 => uint256) public proposalVotes; - mapping (uint256 => bytes32) public proposals; + mapping (uint256 => bytes20) public proposals; mapping (address => bool) public hasVoted; mapping (address => bool) public canPropose; address public admin; @@ -21,7 +21,7 @@ contract Voting { hasVoted[msg.sender] = true; } - function propose(uint256 proposalId, bytes32 proposalName) public { + function propose(uint256 proposalId, bytes20 proposalName) public { require(canPropose[msg.sender]); proposals[proposalId] = proposalName; } From 3a82891e5b1eefc0a64020b929c6f448133f9006 Mon Sep 17 00:00:00 2001 From: Lydia Garms Date: Thu, 16 Apr 2026 16:26:59 +0100 Subject: [PATCH 7/9] fix: github workflows as npm 20 deprecated --- .github/workflows/main.yml | 7 +++---- .github/workflows/release.yml | 6 +++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ed8c72df1..c0e529c2d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,7 +22,7 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v3 + - uses: actions/checkout@v5 # Runs a single command using the runners shell - name: compile and test @@ -41,8 +41,8 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v1 + - uses: actions/checkout@v5 + - uses: actions/setup-node@v5 with: node-version: '16.17.0' @@ -76,4 +76,3 @@ jobs: - name: run zapp apitest run: npx mocha --exit --timeout 50000 --require @babel/register apitest.js - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aeb769205..e6e8de9c5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,8 +8,8 @@ jobs: release: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v5 + - uses: actions/setup-node@v5 with: node-version: '14.17.0' - run: | @@ -22,4 +22,4 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - run: echo ${{ steps.semantic.outputs.release-version }} \ No newline at end of file + - run: echo ${{ steps.semantic.outputs.release-version }} From 64fe61c77e8baf322bd144bd946537c8f86f09df Mon Sep 17 00:00:00 2001 From: Lydia Garms Date: Thu, 16 Apr 2026 16:40:08 +0100 Subject: [PATCH 8/9] fix(workflow): use local TypeScript in CI via npx tsc --- .github/workflows/main.yml | 2 +- .github/workflows/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c0e529c2d..fef98fc4a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,7 +28,7 @@ jobs: - name: compile and test run: | npm i npm@7 - tsc + npx tsc npm test - name: compile shield contracts and circuits diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e6e8de9c5..c8d3bbe7f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: node-version: '14.17.0' - run: | npm install - tsc + npx tsc - uses: codfish/semantic-release-action@master id: semantic From aebff26d4d2f4c20b1e00756bb7a69004225b79f Mon Sep 17 00:00:00 2001 From: Lydia Garms Date: Tue, 21 Apr 2026 11:30:35 +0100 Subject: [PATCH 9/9] fix(tests): fix to take into account new api returns --- apitest.js | 290 ++++++++++++++++++++++++----------------------------- 1 file changed, 132 insertions(+), 158 deletions(-) diff --git a/apitest.js b/apitest.js index 33c94255c..74269d129 100644 --- a/apitest.js +++ b/apitest.js @@ -22,6 +22,26 @@ const testedZapps = []; const zappLogs = new Map(); // Store logs for each zapp const displayedZapps = new Set(); // Track which ZApps have already had logs displayed +const getNewLeavesEvent = body => body?.newLeavesEvent ?? null; + +const expectNewLeavesEvent = body => { + const newLeavesEvent = getNewLeavesEvent(body); + expect(newLeavesEvent?.event).to.equal('NewLeaves'); +}; + +const getMinLeafIndex = body => { + const newLeavesEvent = getNewLeavesEvent(body); + return parseInt( + newLeavesEvent?.returnValues?.minLeafIndex ?? + newLeavesEvent?.returnValues?.[0], + 10, + ); +}; + +const expectMinLeafIndex = (body, expectedIndex) => { + expect(getMinLeafIndex(body)).to.equal(expectedIndex); +}; + const getUserFriendlyTestNames = async folderPath => { try { const files = await fs.promises.readdir(folderPath, { withFileTypes: true }); @@ -726,14 +746,14 @@ describe('Arrays Zapp', () => { } }); it('tests APIs are working', async () => { - expect(res.Arrays[0].body.tx.event).to.equal('NewLeaves'); - expect(res.Arrays[1].body.tx.event).to.equal('NewLeaves'); - expect(res.Arrays[2].body.tx.event).to.equal('NewLeaves'); + expectNewLeavesEvent(res.Arrays[0].body); + expectNewLeavesEvent(res.Arrays[1].body); + expectNewLeavesEvent(res.Arrays[2].body); }); it('MinLeaf Index check', async () => { - expect(parseInt(res.Arrays[0].body.tx.returnValues.minLeafIndex)).to.equal(0); - expect(parseInt(res.Arrays[1].body.tx.returnValues.minLeafIndex)).to.equal(3); - expect(parseInt(res.Arrays[2].body.tx.returnValues.minLeafIndex)).to.equal(6); + expectMinLeafIndex(res.Arrays[0].body, 0); + expectMinLeafIndex(res.Arrays[1].body, 3); + expectMinLeafIndex(res.Arrays[2].body, 6); }); it('Check number of commitments', async () => { expect(res.Arrays[3].body.commitments.length).to.equal(7); @@ -754,7 +774,7 @@ describe('Arrays Zapp', () => { expect(parseInt(res.Arrays[7].body.commitments[0].preimage.value)).to.equal(9); }); it('Check commitments are correct after deleting and restoring from backup', async () => { - expect(res.Arrays[9].body.tx.event).to.equal('NewLeaves'); + expectNewLeavesEvent(res.Arrays[9].body); expect(parseInt(res.Arrays[10].body.commitments[1].preimage.value)).to.equal(0); expect(res.Arrays[10].body.commitments[1].isNullified).to.equal(false); expect(parseInt(res.Arrays[11].body.commitments[0].preimage.value)).to.equal(7); @@ -773,14 +793,14 @@ describe('Assign Zapp', () => { } }); it('tests APIs are working', async () => { - expect(res.Assign[0].body.tx.event).to.equal('NewLeaves'); - expect(res.Assign[1].body.tx.event).to.equal('NewLeaves'); - expect(res.Assign[3].body.tx.event).to.equal('NewLeaves'); + expectNewLeavesEvent(res.Assign[0].body); + expectNewLeavesEvent(res.Assign[1].body); + expectNewLeavesEvent(res.Assign[3].body); }); it('MinLeaf Index check', async () => { - expect(parseInt(res.Assign[0].body.tx.returnValues.minLeafIndex)).to.equal(0); - expect(parseInt(res.Assign[1].body.tx.returnValues.minLeafIndex)).to.equal(1); - expect(parseInt(res.Assign[3].body.tx.returnValues.minLeafIndex)).to.equal(2); + expectMinLeafIndex(res.Assign[0].body, 0); + expectMinLeafIndex(res.Assign[1].body, 1); + expectMinLeafIndex(res.Assign[3].body, 2); }); it('test getBalance', async () => { expect(parseInt(res.Assign[2].body.totalBalance)).to.equal(19); @@ -802,7 +822,7 @@ describe('Assign Zapp', () => { expect(res.Assign[8].body.commitments[0].isNullified).to.equal(true); expect(res.Assign[8].body.commitments[1].isNullified).to.equal(true); expect(res.Assign[8].body.commitments[2].isNullified).to.equal(false); - expect(res.Assign[9].body.tx.event).to.equal('NewLeaves'); + expectNewLeavesEvent(res.Assign[9].body); }); }); @@ -813,12 +833,12 @@ describe('Assign-api Zapp', () => { } }); it('tests APIs are working', async () => { - expect(res.Assign_api[0].body.tx.event).to.equal('NewLeaves'); - expect(res.Assign_api[1].body.tx.event).to.equal('NewLeaves'); + expectNewLeavesEvent(res.Assign_api[0].body); + expectNewLeavesEvent(res.Assign_api[1].body); }); it('MinLeaf Index check', async () => { - expect(parseInt(res.Assign_api[0].body.tx.returnValues.minLeafIndex)).to.equal(0); - expect(parseInt(res.Assign_api[1].body.tx.returnValues.minLeafIndex)).to.equal(3); + expectMinLeafIndex(res.Assign_api[0].body, 0); + expectMinLeafIndex(res.Assign_api[1].body, 3); }); it('test public read only function', async () => { expect(parseInt(res.Assign_api[3].body.publicReturns)).to.equal(50); @@ -844,20 +864,14 @@ describe('BucketsOfBalls Zapp', () => { } }); it('tests APIs are working', async () => { - expect(res.BucketsOfBalls[0].body.tx.event).to.equal('NewLeaves'); - expect(res.BucketsOfBalls[1].body.tx.event).to.equal('NewLeaves'); - expect(res.BucketsOfBalls[2].body.tx.event).to.equal('NewLeaves'); + expectNewLeavesEvent(res.BucketsOfBalls[0].body); + expectNewLeavesEvent(res.BucketsOfBalls[1].body); + expectNewLeavesEvent(res.BucketsOfBalls[2].body); }); it('MinLeaf Index check', async () => { - expect( - parseInt(res.BucketsOfBalls[0].body.tx.returnValues.minLeafIndex, 10), - ).to.equal(0); - expect( - parseInt(res.BucketsOfBalls[1].body.tx.returnValues.minLeafIndex, 10), - ).to.equal(1); - expect( - parseInt(res.BucketsOfBalls[2].body.tx.returnValues.minLeafIndex, 10), - ).to.equal(2); + expectMinLeafIndex(res.BucketsOfBalls[0].body, 0); + expectMinLeafIndex(res.BucketsOfBalls[1].body, 1); + expectMinLeafIndex(res.BucketsOfBalls[2].body, 2); }); it('Check number of commitments', async () => { expect(res.BucketsOfBalls[3].body.commitments.length).to.equal(4); @@ -886,7 +900,7 @@ describe('BucketsOfBalls Zapp', () => { }); it('Check commitments are correct after deleting and restoring from backup', async () => { expect(res.BucketsOfBalls[7].body.commitments.length).to.equal(3); - expect(res.BucketsOfBalls[8].body.tx.event).to.equal('NewLeaves'); + expectNewLeavesEvent(res.BucketsOfBalls[8].body); }); it('Test getBalanceByState', async () => { expect(parseInt(res.BucketsOfBalls[9].body.totalBalance, 10)).to.equal(3); @@ -901,24 +915,16 @@ describe('CharityPot Zapp', () => { } }); it('tests APIs are working', async () => { - expect(res.CharityPot[0].body.tx.event).to.equal('NewLeaves'); - expect(res.CharityPot[1].body.tx.event).to.equal('NewLeaves'); - expect(res.CharityPot[2].body.tx.event).to.equal('NewLeaves'); - expect(res.CharityPot[3].body.tx.event).to.equal('NewLeaves'); + expectNewLeavesEvent(res.CharityPot[0].body); + expectNewLeavesEvent(res.CharityPot[1].body); + expectNewLeavesEvent(res.CharityPot[2].body); + expectNewLeavesEvent(res.CharityPot[3].body); }); it('MinLeaf Index check', async () => { - expect( - parseInt(res.CharityPot[0].body.tx.returnValues.minLeafIndex, 10), - ).to.equal(0); - expect( - parseInt(res.CharityPot[1].body.tx.returnValues.minLeafIndex, 10), - ).to.equal(1); - expect( - parseInt(res.CharityPot[2].body.tx.returnValues.minLeafIndex, 10), - ).to.equal(3); - expect( - parseInt(res.CharityPot[3].body.tx.returnValues.minLeafIndex, 10), - ).to.equal(5); + expectMinLeafIndex(res.CharityPot[0].body, 0); + expectMinLeafIndex(res.CharityPot[1].body, 1); + expectMinLeafIndex(res.CharityPot[2].body, 3); + expectMinLeafIndex(res.CharityPot[3].body, 5); }); it('Check number of commitments', async () => { expect(res.CharityPot[4].body.commitments.length).to.equal(3); @@ -950,7 +956,7 @@ describe('CharityPot Zapp', () => { expect(res.CharityPot[7].body.commitments[4].isNullified).to.equal(true); expect(res.CharityPot[7].body.commitments[5].isNullified).to.equal(false); expect(res.CharityPot[7].body.commitments[6].isNullified).to.equal(false); - expect(res.CharityPot[8].body.tx.event).to.equal('NewLeaves'); + expectNewLeavesEvent(res.CharityPot[8].body); }); }); @@ -965,14 +971,14 @@ describe('Constructor Zapp', () => { expect(parseInt(res.Constructor[0].body.commitments[0].preimage.value)).to.equal(5); }); it('tests APIs are working', async () => { - expect(res.Constructor[1].body.tx.event).to.equal('NewLeaves'); - expect(res.Constructor[2].body.tx.event).to.equal('NewLeaves'); - expect(res.Constructor[4].body.tx.event).to.equal('NewLeaves'); + expectNewLeavesEvent(res.Constructor[1].body); + expectNewLeavesEvent(res.Constructor[2].body); + expectNewLeavesEvent(res.Constructor[4].body); }); it('MinLeaf Index check', async () => { - expect(parseInt(res.Constructor[1].body.tx.returnValues.minLeafIndex)).to.equal(1); - expect(parseInt(res.Constructor[2].body.tx.returnValues.minLeafIndex)).to.equal(2); - expect(parseInt(res.Constructor[4].body.tx.returnValues.minLeafIndex)).to.equal(3); + expectMinLeafIndex(res.Constructor[1].body, 1); + expectMinLeafIndex(res.Constructor[2].body, 2); + expectMinLeafIndex(res.Constructor[4].body, 3); }); it('test getBalance', async () => { expect(parseInt(res.Constructor[3].body.totalBalance)).to.equal(31); @@ -996,7 +1002,7 @@ describe('Constructor Zapp', () => { expect(res.Constructor[8].body.commitments[1].isNullified).to.equal(true); expect(res.Constructor[8].body.commitments[2].isNullified).to.equal(true); expect(res.Constructor[8].body.commitments[3].isNullified).to.equal(false); - expect(res.Constructor[9].body.tx.event).to.equal('NewLeaves'); + expectNewLeavesEvent(res.Constructor[9].body); }); }); @@ -1007,12 +1013,12 @@ describe('Encrypt Zapp', () => { } }); it('tests APIs are working', async () => { - expect(res.Encrypt[0].body.tx.event).to.equal('NewLeaves'); - expect(res.Encrypt[1].body.tx.event).to.equal('NewLeaves'); + expectNewLeavesEvent(res.Encrypt[0].body); + expectNewLeavesEvent(res.Encrypt[1].body); }); it('MinLeaf Index check', async () => { - expect(parseInt(res.Encrypt[0].body.tx.returnValues.minLeafIndex)).to.equal(0); - expect(parseInt(res.Encrypt[1].body.tx.returnValues.minLeafIndex)).to.equal(1); + expectMinLeafIndex(res.Encrypt[0].body, 0); + expectMinLeafIndex(res.Encrypt[1].body, 1); }); it('Check number of commitments', async () => { expect(res.Encrypt[2].body.commitments.length).to.equal(3); @@ -1036,32 +1042,20 @@ describe('Escrow Zapp', () => { } }); it('tests APIs are working', async () => { - expect(res.Escrow[0].body.tx.event).to.equal('NewLeaves'); - expect(res.Escrow[1].body.tx.event).to.equal('NewLeaves'); - expect(res.Escrow[2].body.tx.event).to.equal('NewLeaves'); - expect(res.Escrow[3].body.tx.event).to.equal('NewLeaves'); - expect(res.Escrow[4].body.tx.event).to.equal('NewLeaves'); - expect(res.Escrow[5].body.tx.event).to.equal('NewLeaves'); + expectNewLeavesEvent(res.Escrow[0].body); + expectNewLeavesEvent(res.Escrow[1].body); + expectNewLeavesEvent(res.Escrow[2].body); + expectNewLeavesEvent(res.Escrow[3].body); + expectNewLeavesEvent(res.Escrow[4].body); + expectNewLeavesEvent(res.Escrow[5].body); }); it('MinLeaf Index check', async () => { - expect( - parseInt(res.Escrow[0].body.tx.returnValues.minLeafIndex, 10), - ).to.equal(0); - expect( - parseInt(res.Escrow[1].body.tx.returnValues.minLeafIndex, 10), - ).to.equal(1); - expect( - parseInt(res.Escrow[2].body.tx.returnValues.minLeafIndex, 10), - ).to.equal(2); - expect( - parseInt(res.Escrow[3].body.tx.returnValues.minLeafIndex, 10), - ).to.equal(6); - expect( - parseInt(res.Escrow[4].body.tx.returnValues.minLeafIndex, 10), - ).to.equal(7); - expect( - parseInt(res.Escrow[5].body.tx.returnValues.minLeafIndex, 10), - ).to.equal(10); + expectMinLeafIndex(res.Escrow[0].body, 0); + expectMinLeafIndex(res.Escrow[1].body, 1); + expectMinLeafIndex(res.Escrow[2].body, 2); + expectMinLeafIndex(res.Escrow[3].body, 6); + expectMinLeafIndex(res.Escrow[4].body, 7); + expectMinLeafIndex(res.Escrow[5].body, 10); }); it('Check number of commitments', async () => { expect(res.Escrow[6].body.commitments.length).to.equal(12); @@ -1099,7 +1093,7 @@ describe('Escrow Zapp', () => { expect(res.Escrow[11].body.commitments[4].isNullified).to.equal(false); expect(res.Escrow[12].body.commitments[0].isNullified).to.equal(false); expect(res.Escrow[12].body.commitments[1].isNullified).to.equal(false); - expect(res.Escrow[13].body.tx.event).to.equal('NewLeaves'); + expectNewLeavesEvent(res.Escrow[13].body); }); }); @@ -1110,12 +1104,12 @@ describe('for-loop Zapp', () => { } }); it('tests APIs are working', async () => { - expect(res.forloop[0].body.tx.event).to.equal('NewLeaves'); - expect(res.forloop[1].body.tx.event).to.equal('NewLeaves'); + expectNewLeavesEvent(res.forloop[0].body); + expectNewLeavesEvent(res.forloop[1].body); }); it('MinLeaf Index check', async () => { - expect(parseInt(res.forloop[0].body.tx.returnValues.minLeafIndex)).to.equal(0); - expect(parseInt(res.forloop[1].body.tx.returnValues.minLeafIndex)).to.equal(1); + expectMinLeafIndex(res.forloop[0].body, 0); + expectMinLeafIndex(res.forloop[1].body, 1); }); it('Check number of commitments', async () => { expect(res.forloop[2].body.commitments.length).to.equal(2); @@ -1136,12 +1130,12 @@ describe('If-Statement Zapp', () => { } }); it('tests APIs are working', async () => { - expect(res.IfStatement[0].body.tx.event).to.equal('NewLeaves'); - expect(res.IfStatement[1].body.tx.event).to.equal('NewLeaves'); + expectNewLeavesEvent(res.IfStatement[0].body); + expectNewLeavesEvent(res.IfStatement[1].body); }); it('MinLeaf Index check', async () => { - expect(parseInt(res.IfStatement[0].body.tx.returnValues.minLeafIndex)).to.equal(0); - expect(parseInt(res.IfStatement[1].body.tx.returnValues.minLeafIndex)).to.equal(1); + expectMinLeafIndex(res.IfStatement[0].body, 0); + expectMinLeafIndex(res.IfStatement[1].body, 1); }); it('Check number of commitments', async () => { expect(res.IfStatement[2].body.commitments.length).to.equal(2); @@ -1159,20 +1153,20 @@ describe('If-Statement Zapp', () => { }); it('Check commitments are correct after deleting and restoring from backup', async () => { expect(res.IfStatement[5].body.commitments.length).to.equal(2); - expect(res.IfStatement[6].body.tx.event).to.equal('NewLeaves'); + expectNewLeavesEvent(res.IfStatement[6].body); }); }); /*describe('InternalFunctionCall Zapp', () => { it('tests APIs are working', async () => { - expect(res.InternalFunctionCall[0].body.tx.event).to.equal('NewLeaves'); - expect(res.InternalFunctionCall[1].body.tx.event).to.equal('NewLeaves'); - expect(res.InternalFunctionCall[2].body.tx.event).to.equal('NewLeaves'); + expectNewLeavesEvent(res.InternalFunctionCall[0].body); + expectNewLeavesEvent(res.InternalFunctionCall[1].body); + expectNewLeavesEvent(res.InternalFunctionCall[2].body); }); it('MinLeaf Index check', async () => { - expect(parseInt(res.InternalFunctionCall[0].body.tx.returnValues.minLeafIndex)).to.equal(0); - expect(parseInt(res.InternalFunctionCall[1].body.tx.returnValues.minLeafIndex)).to.equal(1); - expect(parseInt(res.InternalFunctionCall[2].body.tx.returnValues.minLeafIndex)).to.equal(2); + expectMinLeafIndex(res.InternalFunctionCall[0].body, 0); + expectMinLeafIndex(res.InternalFunctionCall[1].body, 1); + expectMinLeafIndex(res.InternalFunctionCall[2].body, 2); }); it('Check number of commitments', async () => { expect(res.InternalFunctionCall[3].body.commitments.length).to.equal(4); @@ -1196,12 +1190,12 @@ describe('MappingtoStruct Zapp', () => { } }); it('tests APIs are working', async () => { - expect(res.MappingtoStruct[0].body.tx.event).to.equal('NewLeaves'); - expect(res.MappingtoStruct[1].body.tx.event).to.equal('NewLeaves'); + expectNewLeavesEvent(res.MappingtoStruct[0].body); + expectNewLeavesEvent(res.MappingtoStruct[1].body); }); it('MinLeaf Index check', async () => { - expect(parseInt(res.MappingtoStruct[0].body.tx.returnValues.minLeafIndex)).to.equal(0); - expect(parseInt(res.MappingtoStruct[1].body.tx.returnValues.minLeafIndex)).to.equal(1); + expectMinLeafIndex(res.MappingtoStruct[0].body, 0); + expectMinLeafIndex(res.MappingtoStruct[1].body, 1); }); it('Check number of commitments', async () => { expect(res.MappingtoStruct[2].body.commitments.length).to.equal(2); @@ -1217,7 +1211,7 @@ describe('MappingtoStruct Zapp', () => { }); it('Check commitments are correct after deleting and restoring from backup', async () => { expect(res.MappingtoStruct[5].body.commitments.length).to.equal(2); - expect(res.MappingtoStruct[6].body.tx.event).to.equal('NewLeaves'); + expectNewLeavesEvent(res.MappingtoStruct[6].body); }); }); @@ -1228,32 +1222,20 @@ describe('NFT_Escrow Zapp', () => { } }); it('tests APIs are working', async () => { - expect(res.NFT_Escrow[0].body.tx.event).to.equal('NewLeaves'); - expect(res.NFT_Escrow[1].body.tx.event).to.equal('NewLeaves'); - expect(res.NFT_Escrow[2].body.tx.event).to.equal('NewLeaves'); - expect(res.NFT_Escrow[3].body.tx.event).to.equal('NewLeaves'); - expect(res.NFT_Escrow[5].body.tx.event).to.equal('NewLeaves'); - expect(res.NFT_Escrow[6].body.tx.event).to.equal('NewLeaves'); + expectNewLeavesEvent(res.NFT_Escrow[0].body); + expectNewLeavesEvent(res.NFT_Escrow[1].body); + expectNewLeavesEvent(res.NFT_Escrow[2].body); + expectNewLeavesEvent(res.NFT_Escrow[3].body); + expectNewLeavesEvent(res.NFT_Escrow[5].body); + expectNewLeavesEvent(res.NFT_Escrow[6].body); }); it('MinLeaf Index check', async () => { - expect( - parseInt(res.NFT_Escrow[0].body.tx.returnValues.minLeafIndex, 10), - ).to.equal(0); - expect( - parseInt(res.NFT_Escrow[1].body.tx.returnValues.minLeafIndex, 10), - ).to.equal(1); - expect( - parseInt(res.NFT_Escrow[2].body.tx.returnValues.minLeafIndex, 10), - ).to.equal(2); - expect( - parseInt(res.NFT_Escrow[3].body.tx.returnValues.minLeafIndex, 10), - ).to.equal(3); - expect( - parseInt(res.NFT_Escrow[5].body.tx.returnValues.minLeafIndex, 10), - ).to.equal(4); - expect( - parseInt(res.NFT_Escrow[6].body.tx.returnValues.minLeafIndex, 10), - ).to.equal(5); + expectMinLeafIndex(res.NFT_Escrow[0].body, 0); + expectMinLeafIndex(res.NFT_Escrow[1].body, 1); + expectMinLeafIndex(res.NFT_Escrow[2].body, 2); + expectMinLeafIndex(res.NFT_Escrow[3].body, 3); + expectMinLeafIndex(res.NFT_Escrow[5].body, 4); + expectMinLeafIndex(res.NFT_Escrow[6].body, 5); }); it('Check number of commitments', async () => { expect(res.NFT_Escrow[7].body.commitments.length).to.equal(6); @@ -1310,12 +1292,12 @@ describe('Return Zapp', () => { } }); it('tests APIs are working', async () => { - expect(res.Return[0].body.tx.event).to.equal('NewLeaves'); - expect(res.Return[1].body.tx.event).to.equal('NewLeaves'); + expectNewLeavesEvent(res.Return[0].body); + expectNewLeavesEvent(res.Return[1].body); }); it('MinLeaf Index check', async () => { - expect(parseInt(res.Return[0].body.tx.returnValues.minLeafIndex)).to.equal(0); - expect(parseInt(res.Return[1].body.tx.returnValues.minLeafIndex)).to.equal(3); + expectMinLeafIndex(res.Return[0].body, 0); + expectMinLeafIndex(res.Return[1].body, 3); }); it('Check number of commitments', async () => { expect(res.Return[2].body.commitments.length).to.equal(4); @@ -1338,14 +1320,14 @@ describe('SimpleStruct Zapp', () => { } }); it('tests APIs are working', async () => { - expect(res.SimpleStruct[0].body.tx.event).to.equal('NewLeaves'); - expect(res.SimpleStruct[1].body.tx.event).to.equal('NewLeaves'); - expect(res.SimpleStruct[2].body.tx.event).to.equal('NewLeaves'); + expectNewLeavesEvent(res.SimpleStruct[0].body); + expectNewLeavesEvent(res.SimpleStruct[1].body); + expectNewLeavesEvent(res.SimpleStruct[2].body); }); it('MinLeaf Index check', async () => { - expect(parseInt(res.SimpleStruct[0].body.tx.returnValues.minLeafIndex)).to.equal(0); - expect(parseInt(res.SimpleStruct[1].body.tx.returnValues.minLeafIndex)).to.equal(1); - expect(parseInt(res.SimpleStruct[2].body.tx.returnValues.minLeafIndex)).to.equal(2); + expectMinLeafIndex(res.SimpleStruct[0].body, 0); + expectMinLeafIndex(res.SimpleStruct[1].body, 1); + expectMinLeafIndex(res.SimpleStruct[2].body, 2); }); it('Check number of commitments', async () => { expect(res.SimpleStruct[3].body.commitments.length).to.equal(4); @@ -1370,10 +1352,10 @@ describe('InternalFunctionCallTest1 Zapp', () => { } }); it('tests APIs are working', async () => { - expect(res.InternalFunctionCallTest1[0].body.tx.event).to.equal('NewLeaves'); - expect(res.InternalFunctionCallTest1[1].body.tx.event).to.equal('NewLeaves'); - expect(res.InternalFunctionCallTest1[3].body.tx.event).to.equal('NewLeaves'); - expect(res.InternalFunctionCallTest1[4].body.tx.event).to.equal('NewLeaves'); + expectNewLeavesEvent(res.InternalFunctionCallTest1[0].body); + expectNewLeavesEvent(res.InternalFunctionCallTest1[1].body); + expectNewLeavesEvent(res.InternalFunctionCallTest1[3].body); + expectNewLeavesEvent(res.InternalFunctionCallTest1[4].body); }); it('Check value after internal function call intialize', async () => { expect(res.InternalFunctionCallTest1[2].body.commitments[0].isNullified).to.equal(true); @@ -1398,25 +1380,17 @@ describe('Swap Zapp', () => { } }); it('tests APIs are working', async () => { - expect(res.Swap[0].body.tx.event).to.equal('NewLeaves'); // deposit 1 - expect(res.Swap[1].body.tx.event).to.equal('NewLeaves'); // deposit 2 - expect(res.Swap[3].body.tx.event).to.equal('NewLeaves'); // startSwap - expect(res.Swap[5].body.tx.event).to.equal('NewLeaves'); // completeSwap + expectNewLeavesEvent(res.Swap[0].body); // deposit 1 + expectNewLeavesEvent(res.Swap[1].body); // deposit 2 + expectNewLeavesEvent(res.Swap[3].body); // startSwap + expectNewLeavesEvent(res.Swap[5].body); // completeSwap }); it('MinLeaf Index check', async () => { - expect( - parseInt(res.Swap[0].body.tx.returnValues.minLeafIndex, 10), - ).to.equal(0); // deposit 1 - expect( - parseInt(res.Swap[1].body.tx.returnValues.minLeafIndex, 10), - ).to.equal(2); // deposit 2 - expect( - parseInt(res.Swap[3].body.tx.returnValues.minLeafIndex, 10), - ).to.equal(4); // startSwap - expect( - parseInt(res.Swap[5].body.tx.returnValues.minLeafIndex, 10), - ).to.equal(7); // completeSwap + expectMinLeafIndex(res.Swap[0].body, 0); // deposit 1 + expectMinLeafIndex(res.Swap[1].body, 2); // deposit 2 + expectMinLeafIndex(res.Swap[3].body, 4); // startSwap + expectMinLeafIndex(res.Swap[5].body, 7); // completeSwap }); it('Check number of commitments', async () => {