From e09e2c535f426bb55891c48b97e02cf26f1d4ed2 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Thu, 12 Dec 2024 18:17:03 -0800 Subject: [PATCH] test: observe node sequence --- packages/fast-usdc/test/exos/advancer.test.ts | 21 +++++++------- packages/fast-usdc/test/exos/settler.test.ts | 18 +++++++++--- .../test/exos/status-manager.test.ts | 29 ++++++++++++++----- packages/fast-usdc/test/supports.ts | 1 - 4 files changed, 47 insertions(+), 22 deletions(-) diff --git a/packages/fast-usdc/test/exos/advancer.test.ts b/packages/fast-usdc/test/exos/advancer.test.ts index 0f1be85ee9f..815727e6bf7 100644 --- a/packages/fast-usdc/test/exos/advancer.test.ts +++ b/packages/fast-usdc/test/exos/advancer.test.ts @@ -12,6 +12,7 @@ import { type ZoeTools } from '@agoric/orchestration/src/utils/zoe-tools.js'; import { q } from '@endo/errors'; import { Far } from '@endo/pass-style'; import type { TestFn } from 'ava'; +import { stringifyWithBigint } from '@agoric/internal'; import { PendingTxStatus } from '../../src/constants.js'; import { prepareAdvancer } from '../../src/exos/advancer.js'; import type { SettlerKit } from '../../src/exos/settler.js'; @@ -186,8 +187,8 @@ test('updates status to ADVANCING in happy path', async t => { await eventLoopIteration(); t.deepEqual( - storage.data.get(`fun.txns.${mockEvidence.txHash}`), - PendingTxStatus.Advancing, + storage.getValues(`fun.txns.${mockEvidence.txHash}`), + [stringifyWithBigint(mockEvidence), PendingTxStatus.Advancing], 'ADVANCED status in happy path', ); @@ -260,8 +261,8 @@ test('updates status to OBSERVED on insufficient pool funds', async t => { await eventLoopIteration(); t.deepEqual( - storage.data.get(`fun.txns.${mockEvidence.txHash}`), - PendingTxStatus.Observed, + storage.getValues(`fun.txns.${mockEvidence.txHash}`), + [stringifyWithBigint(mockEvidence), PendingTxStatus.Observed], 'OBSERVED status on insufficient pool funds', ); @@ -289,8 +290,8 @@ test('updates status to OBSERVED if makeChainAddress fails', async t => { await advancer.handleTransactionEvent(mockEvidence); t.deepEqual( - storage.data.get(`fun.txns.${mockEvidence.txHash}`), - PendingTxStatus.Observed, + storage.getValues(`fun.txns.${mockEvidence.txHash}`), + [stringifyWithBigint(mockEvidence), PendingTxStatus.Observed], 'OBSERVED status on makeChainAddress failure', ); @@ -322,8 +323,8 @@ test('calls notifyAdvancingResult (AdvancedFailed) on failed transfer', async t await eventLoopIteration(); t.deepEqual( - storage.data.get(`fun.txns.${mockEvidence.txHash}`), - PendingTxStatus.Advancing, + storage.getValues(`fun.txns.${mockEvidence.txHash}`), + [stringifyWithBigint(mockEvidence), PendingTxStatus.Advancing], 'tx is Advancing', ); @@ -369,8 +370,8 @@ test('updates status to OBSERVED if pre-condition checks fail', async t => { await advancer.handleTransactionEvent(mockEvidence); t.deepEqual( - storage.data.get(`fun.txns.${mockEvidence.txHash}`), - PendingTxStatus.Observed, + storage.getValues(`fun.txns.${mockEvidence.txHash}`), + [stringifyWithBigint(mockEvidence), PendingTxStatus.Observed], 'tx is recorded as OBSERVED', ); diff --git a/packages/fast-usdc/test/exos/settler.test.ts b/packages/fast-usdc/test/exos/settler.test.ts index f224515df1c..d82479479c9 100644 --- a/packages/fast-usdc/test/exos/settler.test.ts +++ b/packages/fast-usdc/test/exos/settler.test.ts @@ -4,6 +4,7 @@ import type { TestFn } from 'ava'; import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js'; import fetchedChainInfo from '@agoric/orchestration/src/fetched-chain-info.js'; import type { Zone } from '@agoric/zone'; +import { stringifyWithBigint } from '@agoric/internal'; import { PendingTxStatus } from '../../src/constants.js'; import { prepareSettler } from '../../src/exos/settler.js'; import { prepareStatusManager } from '../../src/exos/status-manager.js'; @@ -234,8 +235,13 @@ test('happy path: disburse to LPs; StatusManager removes tx', async t => { 'SETTLED entry removed from StatusManger', ); await eventLoopIteration(); - const vstorage = t.context.storage.data; - t.is(vstorage.get(`fun.txns.${cctpTxEvidence.txHash}`), 'DISBURSED'); + const { storage } = t.context; + t.deepEqual(storage.getValues(`fun.txns.${cctpTxEvidence.txHash}`), [ + stringifyWithBigint(cctpTxEvidence), + 'ADVANCING', + 'ADVANCED', + 'DISBURSED', + ]); }); test('slow path: forward to EUD; remove pending tx', async t => { @@ -302,8 +308,12 @@ test('slow path: forward to EUD; remove pending tx', async t => { [], 'SETTLED entry removed from StatusManger', ); - const vstorage = t.context.storage.data; - t.is(vstorage.get(`fun.txns.${cctpTxEvidence.txHash}`), 'FORWARDED'); + const { storage } = t.context; + t.deepEqual(storage.getValues(`fun.txns.${cctpTxEvidence.txHash}`), [ + stringifyWithBigint(cctpTxEvidence), + 'OBSERVED', + 'FORWARDED', + ]); }); test('Settlement for unknown transaction', async t => { diff --git a/packages/fast-usdc/test/exos/status-manager.test.ts b/packages/fast-usdc/test/exos/status-manager.test.ts index 182a54de513..a45ab0dee72 100644 --- a/packages/fast-usdc/test/exos/status-manager.test.ts +++ b/packages/fast-usdc/test/exos/status-manager.test.ts @@ -2,6 +2,7 @@ import type { TestFn } from 'ava'; import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js'; import type { StorageNode } from '@agoric/internal/src/lib-chainStorage.js'; import { eventLoopIteration } from '@agoric/internal/src/testing-utils.js'; +import { stringifyWithBigint } from '@agoric/internal'; import { PendingTxStatus } from '../../src/constants.js'; import { prepareStatusManager } from '../../src/exos/status-manager.js'; import { commonSetup, provideDurableZone } from '../supports.js'; @@ -54,8 +55,11 @@ test('ADVANCED transactions are published to vstorage', async t => { statusManager.advance(evidence); await eventLoopIteration(); - const vstorage = t.context.storage.data; - t.is(vstorage.get(`fun.txns.${evidence.txHash}`), 'ADVANCING'); + const { storage } = t.context; + t.deepEqual(storage.getValues(`fun.txns.${evidence.txHash}`), [ + stringifyWithBigint(evidence), + 'ADVANCING', + ]); }); test('observe creates new entry with OBSERVED status', t => { @@ -86,8 +90,11 @@ test('OBSERVED transactions are published to vstorage', async t => { statusManager.observe(evidence); await eventLoopIteration(); - const vstorage = t.context.storage.data; - t.is(vstorage.get(`fun.txns.${evidence.txHash}`), 'OBSERVED'); + const { storage } = t.context; + t.deepEqual(storage.getValues(`fun.txns.${evidence.txHash}`), [ + stringifyWithBigint(evidence), + 'OBSERVED', + ]); }); test('cannot process same tx twice', t => { @@ -212,7 +219,7 @@ test('cannot advanceOutcome without ADVANCING entry', t => { }); test('advanceOutcome transitions to ADVANCED and ADVANCE_FAILED', async t => { - const vstorage = t.context.storage.data; + const { storage } = t.context; const zone = provideDurableZone('status-test'); const statusManager = prepareStatusManager( zone.subZone('status-manager'), @@ -229,7 +236,11 @@ test('advanceOutcome transitions to ADVANCED and ADVANCE_FAILED', async t => { }, ]); await eventLoopIteration(); - t.is(vstorage.get(`fun.txns.${e1.txHash}`), PendingTxStatus.Advanced); + t.deepEqual(storage.getValues(`fun.txns.${e1.txHash}`), [ + stringifyWithBigint(e1), + PendingTxStatus.Advancing, + PendingTxStatus.Advanced, + ]); statusManager.advance(e2); statusManager.advanceOutcome(e2.tx.forwardingAddress, e2.tx.amount, false); @@ -239,7 +250,11 @@ test('advanceOutcome transitions to ADVANCED and ADVANCE_FAILED', async t => { }, ]); await eventLoopIteration(); - t.is(vstorage.get(`fun.txns.${e2.txHash}`), PendingTxStatus.AdvanceFailed); + t.deepEqual(storage.getValues(`fun.txns.${e2.txHash}`), [ + stringifyWithBigint(e2), + PendingTxStatus.Advancing, + PendingTxStatus.AdvanceFailed, + ]); }); test('dequeueStatus returns undefined when nothing is settleable', t => { diff --git a/packages/fast-usdc/test/supports.ts b/packages/fast-usdc/test/supports.ts index 05502171587..26e0b775a51 100644 --- a/packages/fast-usdc/test/supports.ts +++ b/packages/fast-usdc/test/supports.ts @@ -151,7 +151,6 @@ export const commonSetup = async (t: ExecutionContext) => { const marshaller = makeFakeBoard().getReadonlyMarshaller(); const storage = makeFakeStorageKit( 'fun', // Fast USDC Node - { sequence: false }, ); const { portAllocator, setupIBCProtocol, ibcBridge } = setupFakeNetwork(