@@ -5,7 +5,6 @@ import { test as anyTest } from './prepare-test-env-ava.js';
5
5
6
6
import { createRequire } from 'module' ;
7
7
import { E , Far } from '@endo/far' ;
8
- // import { makeCopyBag } from '@endo/patterns';
9
8
import { makeNodeBundleCache } from '@endo/bundle-source/cache.js' ;
10
9
import { AmountMath , makeIssuerKit } from '@agoric/ertp' ;
11
10
import { registerChain } from '@agoric/orchestration/src/chain-info.js' ;
@@ -15,6 +14,7 @@ import { startOrcaContract } from '../src/orca.proposal.js';
15
14
import { makeMockTools , mockBootstrapPowers } from './boot-tools.js' ;
16
15
import { startOrchCoreEval } from '../tools/startOrch.js' ;
17
16
import { getBundleId } from '../tools/bundle-tools.js' ;
17
+ import { Fail } from '@endo/errors' ;
18
18
19
19
/** @typedef {typeof import('../src/orca.contract.js').start } OrcaContractFn */
20
20
@@ -115,75 +115,38 @@ const makeTestContext = async t => {
115
115
const bundleCache = await makeNodeBundleCache ( 'bundles/' , { } , s => import ( s ) ) ;
116
116
const bundle = await bundleCache . load ( contractPath , 'orca' ) ;
117
117
118
- const { powers } = await mockBootstrapPowers ( t . log ) ;
119
- // await publishChainInfo(powers.consume.agoricNamesAdmin);
118
+ const { powers, vowTools : vt } = await mockBootstrapPowers ( t . log ) ;
119
+ await publishChainInfo ( powers . consume . agoricNamesAdmin ) ;
120
120
const tools = await makeMockTools ( t , bundleCache ) ;
121
121
122
- const cosmosInterchainService = Far ( 'DummyCosmosInterchainService' , {
123
- getChainHub : async ( ) => {
124
- const chainHub = {
125
- registerChain : async ( name , details ) => {
126
- console . log ( `chain registered: ${ name } ` , details ) ;
122
+ const sent = [ ] ;
123
+ const cosmosInterchainService = Far ( 'MockCosmosInterchainService' , {
124
+ makeAccount ( chainId , hostConnectionId , controllerConnectionId , opts ) {
125
+ return Far ( 'IcaAccount' , {
126
+ getAddress : ( ) =>
127
+ harden ( {
128
+ chainId,
129
+ value : `agoric123` ,
130
+ encoding : 'bech32' , // or 'ethereum', based on your requirements
131
+ } ) ,
132
+ getLocalAddress : ( ) => '/ibc-port/LOCAL' ,
133
+ getRemoteAddress : ( ) => '/ibc-port/REMOTE' ,
134
+ getPort : ( ) => Fail `not implemented` ,
135
+ executeTx : ( ) => Fail `not implemented` ,
136
+ executeEncodedTx : ( msgs , opts ) => {
137
+ sent . push ( { msgs, opts } ) ;
138
+ return vt . asVow ( ( ) => Fail `TODO` ) ;
127
139
} ,
128
- getChain : async name => {
129
- if (
130
- name === 'agoric' ||
131
- name === 'osmosis' ||
132
- name === 'agoriclocal' ||
133
- name === 'osmosislocal'
134
- ) {
135
- const state = harden ( {
136
- name,
137
- chainId : `${ name } local` ,
138
- denom : name === 'agoric' ? 'ubld' : 'uosmo' ,
139
- expectedAddressPrefix : name === 'agoric' ? 'agoric' : 'osmo' ,
140
- details : `${ name } chain details` ,
141
- stakingTokens : [ { denom : name === 'agoric' ? 'ubld' : 'uosmo' } ] ,
142
- } ) ;
143
-
144
- return harden ( {
145
- ...state ,
146
- makeAccount : ( ) =>
147
- Far ( 'Account' , {
148
- getChainId : ( ) => state . chainId ,
149
- getAccountAddress : ( ) => `${ state . name } AccountAddress` ,
150
- getAddress : ( ) =>
151
- harden ( {
152
- chainId : state . chainId ,
153
- value : `${ state . name } AccountAddress` ,
154
- encoding : 'bech32' , // or 'ethereum', based on your requirements
155
- } ) ,
156
- getBalance : ( ) => `1000${ state . denom } ` ,
157
- } ) ,
158
- getChainInfo : ( ) =>
159
- Far ( 'ChainInfo' , {
160
- getChainId : ( ) => state . chainId ,
161
- getDenom : ( ) => state . denom ,
162
- getExpectedAddressPrefix : ( ) => state . expectedAddressPrefix ,
163
- } ) ,
164
- } ) ;
165
- }
166
- throw Error ( `chain not found: ${ name } ` ) ;
167
- } ,
168
- } ;
169
- return chainHub ;
170
- } ,
171
- makeAccount : async name => {
172
- const chainHub = await E ( cosmosInterchainService ) . getChainHub ( ) ;
173
- const chain = await E ( chainHub ) . getChain ( name ) ;
174
- return E ( chain ) . makeAccount ( ) ;
175
- } ,
176
- getChainInfo : async name => {
177
- const chainHub = await E ( cosmosInterchainService ) . getChainHub ( ) ;
178
- const chain = await E ( chainHub ) . getChain ( name ) ;
179
- return E ( chain ) . getChainInfo ( ) ;
140
+ } ) ;
180
141
} ,
142
+ provideICQConnection : ( ) => Fail `not implemented` ,
181
143
} ) ;
182
144
183
145
return {
184
146
bundle,
185
147
bundleCache,
186
148
powers,
149
+ vowTools : vt ,
187
150
cosmosInterchainService,
188
151
...tools ,
189
152
} ;
@@ -295,17 +258,6 @@ const chainConfigs = {
295
258
} ,
296
259
} ;
297
260
298
- test ( 'Verify chain registration' , async t => {
299
- const { cosmosInterchainService } = t . context ;
300
- const chainHub = await E ( cosmosInterchainService ) . getChainHub ( ) ;
301
-
302
- const agoricChain = await E ( chainHub ) . getChain ( 'agoric' ) ;
303
- t . truthy ( agoricChain , 'Agoric chain should be registered' ) ;
304
-
305
- const osmosisChain = await E ( chainHub ) . getChain ( 'osmosis' ) ;
306
- t . truthy ( osmosisChain , 'Osmosis chain should be registered' ) ;
307
- } ) ;
308
-
309
261
const queryVstorage = async ( t , qt , wallet , offerId ) => {
310
262
t . log ( `querying vstorage for wallet: ${ wallet } , offerId: ${ offerId } ` ) ;
311
263
const currentWalletRecord = await qt . queryData (
@@ -331,26 +283,25 @@ const orchestrationAccountScenario = test.macro({
331
283
`orchestrate - ${ chainName } makeAccount returns a ContinuingOfferResult` ,
332
284
exec : async ( t , chainName ) => {
333
285
const config = chainConfigs [ chainName ] ;
334
- if ( ! config ) {
335
- return t . fail ( `unknown chain: ${ chainName } ` ) ;
336
- }
286
+ assert ( config ) ;
337
287
338
- const { bundle, cosmosInterchainService, powers } = t . context ;
288
+ const { bundle, cosmosInterchainService, powers, vowTools : vt } = t . context ;
339
289
const { agoricNames, board, chainStorage, zoe } = powers . consume ;
340
290
t . log ( 'installing the contract...' ) ;
341
291
const installation = E ( zoe ) . install ( bundle ) ;
342
292
293
+ await null ;
343
294
const privateArgs = harden ( {
344
295
cosmosInterchainService,
345
- orchestrationService : cosmosInterchainService ,
346
- storageNode : chainStorage ,
347
- marshaller : E ( board ) . getPublishingMarshaller ( ) ,
296
+ orchestrationService : await cosmosInterchainService ,
297
+ storageNode : await chainStorage ,
298
+ marshaller : await E ( board ) . getPublishingMarshaller ( ) ,
348
299
timerService : Far ( 'DummyTimer' ) ,
349
300
localchain : Far ( 'DummyLocalchain' ) ,
350
- agoricNames,
301
+ agoricNames : await agoricNames ,
351
302
} ) ;
352
303
353
- t . log ( 'starting the instance...' ) ;
304
+ t . log ( 'starting the instance...' , privateArgs ) ;
354
305
const { instance } = await E ( zoe ) . startInstance (
355
306
installation ,
356
307
{ } ,
@@ -360,36 +311,24 @@ const orchestrationAccountScenario = test.macro({
360
311
t . log ( 'instance started:' , instance ) ;
361
312
t . truthy ( instance ) ;
362
313
363
- t . log ( 'getting public facet...' ) ;
364
314
const publicFacet = await E ( zoe ) . getPublicFacet ( instance ) ;
365
- t . log ( 'public facet obtained:' , publicFacet ) ;
366
-
367
- t . log ( 'creating account invitation...' ) ;
368
315
const initialInvitation = await E ( publicFacet ) . makeAccountInvitation ( ) ;
369
- t . log ( 'invitation created:' , initialInvitation ) ;
370
-
371
- const makeAccountOffer = {
372
- give : { } ,
373
- want : { } ,
374
- exit : { onDemand : null } ,
375
- } ;
376
316
377
317
t . log ( 'making offer...' ) ;
378
318
const offerId = 'offerId' ;
379
319
const initialUserSeat = await E ( zoe ) . offer (
380
320
initialInvitation ,
381
- makeAccountOffer ,
321
+ { } ,
382
322
undefined ,
383
- { id : offerId } ,
323
+ { chainName } ,
384
324
) ;
385
325
t . log ( 'initial user seat:' , initialUserSeat ) ;
386
326
387
327
t . log ( 'getting offer result...' ) ;
388
- const offerResult = await E ( initialUserSeat ) . getOfferResult ( ) ;
328
+ const offerResult = await vt . when ( E ( initialUserSeat ) . getOfferResult ( ) ) ;
389
329
t . log ( 'offer result:' , offerResult ) ;
390
330
t . truthy ( offerResult , 'Offer result should exist' ) ;
391
331
392
- const { makeQueryTool } = t . context ;
393
332
const qt = makeQueryToolMock ( ) ;
394
333
const wallet = 'test-wallet' ;
395
334
// log vstorage state before querying
@@ -410,22 +349,15 @@ const orchestrationAccountScenario = test.macro({
410
349
) ;
411
350
t . log ( 'current wallet record' , currentWalletRecord ) ;
412
351
413
- const continuingInvitation = await E ( publicFacet ) . makeAccountInvitation ( ) ;
414
- t . truthy ( continuingInvitation , 'continuing invitation should be created' ) ;
352
+ const toClose = await E ( offerResult . invitationMakers ) . Undelegate ( [ ] ) ;
353
+ t . truthy ( toClose , 'continuing invitation should be created' ) ;
415
354
416
- const continuingOffer = {
417
- give : { } ,
418
- want : { } ,
419
- exit : { onDemand : null } ,
420
- } ;
421
-
422
- const continuingUserSeat = await E ( zoe ) . offer (
423
- continuingInvitation ,
424
- continuingOffer ,
425
- undefined ,
426
- { previousOffer : offerId } ,
355
+ const continuingUserSeat = await E ( zoe ) . offer ( toClose , { } , undefined , {
356
+ chainName,
357
+ } ) ;
358
+ const continuingOfferResult = await vt . when (
359
+ E ( continuingUserSeat ) . getOfferResult ( ) ,
427
360
) ;
428
- const continuingOfferResult = await E ( continuingUserSeat ) . getOfferResult ( ) ;
429
361
430
362
t . truthy ( continuingOfferResult , 'continuing offer should produce a result' ) ;
431
363
t . log ( 'continuing offer result' , continuingOfferResult ) ;
@@ -446,15 +378,16 @@ const orchestrationAccountAndFundScenario = test.macro({
446
378
t . log ( 'installing the contract...' ) ;
447
379
const installation = E ( zoe ) . install ( bundle ) ;
448
380
381
+ await null ;
449
382
const privateArgs = harden ( {
450
383
cosmosInterchainService,
451
- orchestrationService : cosmosInterchainService ,
452
- storageNode : chainStorage ,
453
- marshaller : E ( board ) . getPublishingMarshaller ( ) ,
384
+ orchestrationService : await cosmosInterchainService ,
385
+ storageNode : await chainStorage ,
386
+ marshaller : await E ( board ) . getPublishingMarshaller ( ) ,
454
387
timer : Far ( 'DummyTimer' ) ,
455
388
timerService : Far ( 'DummyTimer' ) ,
456
389
localchain : Far ( 'DummyLocalchain' ) ,
457
- agoricNames,
390
+ agoricNames : await agoricNames ,
458
391
} ) ;
459
392
460
393
const { mint, issuer, brand } = makeIssuerKit ( 'BLD' ) ;
0 commit comments