From a554a4ba1655983320079f36921cb66b7270a216 Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Tue, 22 Oct 2024 11:31:38 -0500 Subject: [PATCH] test(ERTP): balance {x, y, z} >= {z} --- .../mathHelpers/copySetMathHelpers.test.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/ERTP/test/unitTests/mathHelpers/copySetMathHelpers.test.js b/packages/ERTP/test/unitTests/mathHelpers/copySetMathHelpers.test.js index a0171c5fa38..e387d1e5db5 100644 --- a/packages/ERTP/test/unitTests/mathHelpers/copySetMathHelpers.test.js +++ b/packages/ERTP/test/unitTests/mathHelpers/copySetMathHelpers.test.js @@ -1,6 +1,7 @@ import { test } from '@agoric/swingset-vat/tools/prepare-test-env-ava.js'; import { getCopySetKeys, makeCopySet } from '@agoric/store'; +import { Far } from '@endo/far'; import { AmountMath as m, AssetKind } from '../../../src/index.js'; import { mockCopySetBrand as mockBrand } from './mockBrand.js'; @@ -291,3 +292,16 @@ test('copySet with strings subtract', t => { `['a', 'b'] - ['a'] = ['a']`, ); }); + +const mockHandle = iface => Far(iface, {}); + +test('balance {x, y, z} >= {z}', t => { + const x = { instance: mockHandle('Foo'), description: 'fraz' }; + const y = { instance: mockHandle('Foo'), description: 'fraz' }; + const z = { instance: mockHandle('Foo'), description: 'alan' }; + + const balance = harden({ brand: mockBrand, value: makeCopySet([x, y, z]) }); + const withdraw = harden({ brand: mockBrand, value: makeCopySet([z]) }); + + t.true(m.isGTE(balance, withdraw)); +});