From 3be300dca3d6fc9814fc8f63f467661d973b95fc Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Thu, 15 Feb 2024 16:46:38 -0800 Subject: [PATCH] test: reduce race sensitivity --- .../a:upgrade-next/core-eval.test.js | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/a3p-integration/proposals/a:upgrade-next/core-eval.test.js b/a3p-integration/proposals/a:upgrade-next/core-eval.test.js index 4d39ade7af00..ab94ec5ac3f9 100644 --- a/a3p-integration/proposals/a:upgrade-next/core-eval.test.js +++ b/a3p-integration/proposals/a:upgrade-next/core-eval.test.js @@ -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'; @@ -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, @@ -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); });