From ae1841138da05f34861c133175cdf7cd83569b46 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Mon, 2 Dec 2024 23:46:41 -0600 Subject: [PATCH] test(boot): core-eval to change fastUsdc.feedPolicy --- .../boot/test/fast-usdc/fast-usdc.test.ts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/packages/boot/test/fast-usdc/fast-usdc.test.ts b/packages/boot/test/fast-usdc/fast-usdc.test.ts index 2e09d13f1b3..7effca63560 100644 --- a/packages/boot/test/fast-usdc/fast-usdc.test.ts +++ b/packages/boot/test/fast-usdc/fast-usdc.test.ts @@ -1,6 +1,7 @@ import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js'; import type { CctpTxEvidence } from '@agoric/fast-usdc/src/types.js'; +import { configurations } from '@agoric/fast-usdc/src/utils/deploy-config.js'; import { MockCctpTxEvidences } from '@agoric/fast-usdc/test/fixtures.js'; import { documentStorageSchema } from '@agoric/governance/tools/storageDoc.js'; import { unmarshalFromVstorage } from '@agoric/internal/src/marshal.js'; @@ -156,6 +157,33 @@ test.serial('writes status updates to vstorage', async t => { await documentStorageSchema(t, storage, doc); }); +test.serial('core-eval to change feedPolicy', async t => { + const { buildProposal, evalProposal, storage } = t.context; + + const { feedPolicy } = configurations.MAINNET; + const arbitrum3 = harden({ + // @ts-expect-error FeedPolicy & Passable is not recognized as an object type?! + ...feedPolicy, + chainPolicies: { + ...feedPolicy.chainPolicies, + Arbitrum: { ...feedPolicy.chainPolicies.Arbitrum, confirmations: 3 }, + }, + }); + const materials = buildProposal( + '@agoric/builders/scripts/fast-usdc/init-fast-usdc.js', + ['--update', '--feedPolicy', JSON.stringify(arbitrum3)], + ); + await evalProposal(materials); + + const raw = storage.data.get('published.fastUsdc.feedPolicy'); + + const getLast = (/** @type {string} */ cell) => + JSON.parse(cell).values.at(-1) || assert.fail(); + const actual = JSON.parse(getLast(raw)); + t.log('updated', actual.chainPolicies); + t.like(actual, { chainPolicies: { Arbitrum: { confirmations: 3 } } }); +}); + test.serial('restart contract', async t => { const { EV } = t.context.runUtils; await null;