Skip to content

Commit

Permalink
Add flag to skip vcounters check
Browse files Browse the repository at this point in the history
  • Loading branch information
ignasirv committed Feb 14, 2024
1 parent 5189e7d commit 7d02e3c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
npm run test:zkasm
- name: Generate tests
run: |
npm run test:gen
node tools/parallel-testing/gen-parallel-tests.js
- name: Run tests
run: |
export NUM_CPUS=31
Expand Down
6 changes: 3 additions & 3 deletions main/opcodes/logs.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ initLogLoop:
0 => HASHPOS
32 => D
$ => B :MLOAD(currentLogIndex)
$ => E :MLOAD(nextHashPId)
$ => A :MLOAD(nextHashPId)
; Update nextHashPId
E + 1 :MSTORE(nextHashPId)
A + 1 :MSTORE(nextHashPId)
; store nextHashPId to aux variable
E :MSTORE(logNextHashPIdAux)
A :MSTORE(logNextHashPIdAux)

logLoop:
; checks zk-counters
Expand Down
7 changes: 6 additions & 1 deletion tools/parallel-testing/gen-parallel-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const pathMainPil = path.join(__dirname, '../../node_modules/@0xpolygonhermez/zk
const inputs = [];
const testsFolder = path.join(__dirname, 'parallel-tests');
const sampleDir = path.join(__dirname, 'parallel-tests-sample/sample.test.js');
const { argv } = require('yargs');

async function genTestsFiles() {
if (!fs.existsSync(testsFolder)) {
Expand All @@ -26,7 +27,11 @@ async function genTestsFiles() {
for (const inputPath of inputs) {
const name = inputPath.split('/').slice(-1)[0].replace('json', 'test.js');
const sample = fs.readFileSync(sampleDir, 'utf-8');
const test = sample.replace('%%INPUT_PATH%%', `${inputPath}`);
let test = sample.replace('%%INPUT_PATH%%', `${inputPath}`);
// Replace skip vcounters flag
if (argv.skipVCounters) {
test = test.replace('%%SKIP_VCOUNTERS%%', 'yes');
}
fs.writeFileSync(`${testsFolder}/${name}`, test);
}
expect(true).to.be.equal(true);
Expand Down
5 changes: 4 additions & 1 deletion tools/parallel-testing/parallel-tests-sample/sample.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const checkerDir = path.join(__dirname, 'checker.txt');
const inputPath = '%%INPUT_PATH%%';
const nameFile = path.basename(inputPath);
const input = JSON.parse(fs.readFileSync(inputPath, 'utf8'));
const skipVcounters = '%%SKIP_VCOUNTERS%%';

it(`${nameFile}`, async () => {
if (fs.existsSync(checkerDir)) {
Expand Down Expand Up @@ -55,7 +56,9 @@ async function runTest(cmPols, steps) {
};

const res = await smMain.execute(cmPols.Main, input, rom, config);
compareCounters(input.virtualCounters, res.counters);
if (skipVcounters !== 'yes') {
compareCounters(input.virtualCounters, res.counters);
}
} catch (err) {
fs.writeFileSync(checkerDir, `Failed test ${inputPath} - ${err}}`);
throw err;
Expand Down

0 comments on commit 7d02e3c

Please sign in to comment.