Skip to content

Commit

Permalink
fix vow failure handling (#9696)
Browse files Browse the repository at this point in the history
follow up on #9449 

## Description
#9685 unwrapped an `asVow()` to get the promise failure to propagate. This reverts that now that #9704 removed the need for it.

### Security Considerations
none

### Scaling Considerations
none

### Documentation Considerations
none

### Testing Considerations
CI

### Upgrade Considerations
not yet deployed
  • Loading branch information
mergify[bot] authored Jul 14, 2024
2 parents bd50e5e + c9969a5 commit 66bf702
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 14 deletions.
28 changes: 15 additions & 13 deletions packages/orchestration/src/exos/remote-chain-facade.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,20 +91,22 @@ const prepareRemoteChainFacadeKit = (

/** @type {HostOf<Chain['makeAccount']>} */
makeAccount() {
const { remoteChainInfo, connectionInfo } = this.state;
const stakingDenom = remoteChainInfo.stakingTokens?.[0]?.denom;
if (!stakingDenom) {
return asVow(Fail`chain info lacks staking denom`);
}
return asVow(() => {
const { remoteChainInfo, connectionInfo } = this.state;
const stakingDenom = remoteChainInfo.stakingTokens?.[0]?.denom;
if (!stakingDenom) {
throw Fail`chain info lacks staking denom`;
}

return watch(
E(orchestration).makeAccount(
remoteChainInfo.chainId,
connectionInfo.id,
connectionInfo.counterparty.connection_id,
),
this.facets.makeAccountWatcher,
);
return watch(
E(orchestration).makeAccount(
remoteChainInfo.chainId,
connectionInfo.id,
connectionInfo.counterparty.connection_id,
),
this.facets.makeAccountWatcher,
);
});
},
},
makeAccountWatcher: {
Expand Down
50 changes: 49 additions & 1 deletion packages/orchestration/test/facade.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js';

import { prepareSwingsetVowTools } from '@agoric/vow/vat.js';
import { setupZCFTest } from '@agoric/zoe/test/unitTests/zcf/setupZcfTest.js';
import { reincarnate } from '@agoric/swingset-liveslots/tools/setup-vat-data.js';
import type { CosmosChainInfo, IBCConnectionInfo } from '../src/cosmos-api.js';
import type { Chain } from '../src/orchestration-api.js';
import { provideOrchestration } from '../src/utils/start-helper.js';
Expand Down Expand Up @@ -39,7 +40,7 @@ export const mockChainConnection: IBCConnectionInfo = {
},
};

test('chain info', async t => {
test.serial('chain info', async t => {
const { bootstrap, facadeServices, commonPrivateArgs } = await commonSetup(t);

const { zcf } = await setupZCFTest();
Expand Down Expand Up @@ -79,4 +80,51 @@ test('chain info', async t => {
t.deepEqual(await vt.when(result.getChainInfo()), mockChainInfo);
});

test.serial('faulty chain info', async t => {
const { facadeServices, commonPrivateArgs } = await commonSetup(t);

// XXX relax again so setupZCFTest can run. This is also why the tests are serial.
reincarnate({ relaxDurabilityRules: true });
const { zcf } = await setupZCFTest();

// After setupZCFTest because this disables relaxDurabilityRules
// which breaks Zoe test setup's fakeVatAdmin
const zone = provideDurableZone('test');
const vt = prepareSwingsetVowTools(zone);

const orchKit = provideOrchestration(
zcf,
zone.mapStore('test'),
{
agoricNames: facadeServices.agoricNames,
timerService: facadeServices.timerService,
storageNode: commonPrivateArgs.storageNode,
orchestrationService: facadeServices.orchestrationService,
localchain: facadeServices.localchain,
},
commonPrivateArgs.marshaller,
);

const { chainHub, orchestrate } = orchKit;

const { stakingTokens, ...sansStakingTokens } = mockChainInfo;

chainHub.registerChain('mock', sansStakingTokens);
chainHub.registerConnection(
'agoric-3',
mockChainInfo.chainId,
mockChainConnection,
);

const handle = orchestrate('mock', {}, async orc => {
const chain = await orc.getChain('mock');
const account = await chain.makeAccount();
return account;
});

await t.throwsAsync(handle(), {
message: 'chain info lacks staking denom',
});
});

test.todo('contract upgrade');

0 comments on commit 66bf702

Please sign in to comment.