Skip to content

Commit eb8451b

Browse files
committed
test(boot): set price without zoe offer using evalExpr
1 parent ecd2ff4 commit eb8451b

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

packages/boot/test/bootstrapTests/wallet-fun.test.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
makeWalletFactoryContext,
1010
type WalletFactoryTestContext as TC,
1111
} from './walletFactory.ts';
12+
import type { NameHub } from '@agoric/vats';
1213

1314
const nodeRequire = createRequire(import.meta.url);
1415

@@ -42,6 +43,9 @@ const startContract = async (t: ExecutionContext<TC>) => {
4243
return started;
4344
};
4445

46+
const arrowBody = (f: Function) =>
47+
`${f}`.match(/\(\) =>\s*(?<body>.*)/)?.groups?.body || assert.fail();
48+
4549
test('use offer result without zoe', async t => {
4650
const { walletFactoryDriver, agoricNamesRemotes } = t.context;
4751
const { EV } = t.context.runUtils;
@@ -77,7 +81,15 @@ test('use offer result without zoe', async t => {
7781
});
7882
t.log('redeemInvitation last update', wd.getLatestUpdateRecord());
7983

80-
const initialPrices = await EV(started.publicFacet).getPrices();
81-
t.log({ initialPrices });
82-
t.deepEqual(initialPrices, [0n]);
84+
t.log('initial prices', await EV(started.publicFacet).getPrices());
85+
86+
const setPriceFn =
87+
(nameHub = null as unknown as NameHub, E = <T>(x: Awaited<T>) => x) =>
88+
() =>
89+
E(nameHub.lookup('priceSetter')).setPrice(100n);
90+
91+
await wd.evalExpr(arrowBody(setPriceFn));
92+
const actual = await EV(started.publicFacet).getPrices();
93+
t.log('prices after', actual);
94+
t.deepEqual(actual, [100n]);
8395
});

0 commit comments

Comments
 (0)