Skip to content

Commit

Permalink
test: reduce race sensitivity
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg authored and mhofman committed Feb 16, 2024
1 parent 4dea35d commit 0cd9160
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions a3p-integration/proposals/a:upgrade-next/core-eval.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable @jessie.js/safe-await-separator */
import test from 'ava';
import { readFile, writeFile } from 'node:fs/promises';

import { agoric, evalBundles, waitForBlock } from '@agoric/synthetic-chain';
import { agd, evalBundles, waitForBlock } from '@agoric/synthetic-chain';

const SUBMISSION_DIR = 'core-eval-test-submission';

Expand All @@ -17,10 +18,27 @@ const replaceTemplateValuesInFile = async (fileName, replacements) => {
await writeFile(`${fileName}.js`, script);
};

const readPublished = async path => {
const { value } = await agd.query(
'vstorage',
'data',
'--output',
'json',
`published.${path}`,
);
if (value === '') {
return undefined;
}
const obj = JSON.parse(value);
return obj.values[0];
};

test(`core eval works`, async t => {
const nodePath = 'foo.bar';
const nodeValue = 'baz';

t.falsy(await readPublished(nodePath));

await replaceTemplateValuesInFile(`${SUBMISSION_DIR}/send-script`, {
NODE_PATH: nodePath,
NODE_VALUE: nodeValue,
Expand All @@ -29,12 +47,6 @@ test(`core eval works`, async t => {
await evalBundles(SUBMISSION_DIR);

await waitForBlock(2); // enough time for core eval to execute ?
const chainStorageValue = await agoric.follow(
'-lF',
`:${nodePath}`,
'-o',
'text',
);

t.is(chainStorageValue, nodeValue);
t.is(await readPublished(nodePath), nodeValue);
});

0 comments on commit 0cd9160

Please sign in to comment.