Skip to content

Commit

Permalink
fixup! test: revise chain info
Browse files Browse the repository at this point in the history
  • Loading branch information
turadg committed Jun 21, 2024
1 parent 88ee6df commit 699f2b1
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 10 deletions.
12 changes: 3 additions & 9 deletions packages/boot/test/bootstrapTests/orchestration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,23 +242,17 @@ test.serial('revise chain info', async t => {

const agoricNames = await EV.vat('bootstrap').consumeItem('agoricNames');

const agoricBefore = await EV(agoricNames).lookup('chain', 'agoric');
t.like(agoricBefore, { chainId: 'agoric-3' });

await t.throwsAsync(EV(agoricNames).lookup('chain', 'hot'), {
message: '"nameKey" not found: "hot"',
});

// Revise chain info in agoricNames with the fixture in this script
await evalProposal(
buildProposal('@agoric/builders/scripts/testing/tweak-chain-info.js'),
buildProposal('@agoric/builders/scripts/testing/append-chain-info.js'),
);

const hotAfter = await EV(agoricNames).lookup('chain', 'hot');
t.deepEqual(hotAfter, { allegedName: 'Hot New Chain', chainId: 'hot-1' });

const agoricAfter = await EV(agoricNames).lookup('chain', 'agoric');
t.like(agoricAfter, { chainId: 'agoric-4' });
const hotchain = await EV(agoricNames).lookup('chain', 'hot');
t.deepEqual(hotchain, { allegedName: 'Hot New Chain', chainId: 'hot-1' });

const connection = await EV(agoricNames).lookup(
'chainConnection',
Expand Down
50 changes: 50 additions & 0 deletions packages/builders/scripts/testing/append-chain-info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/// <reference types="ses" />
import { makeHelpers } from '@agoric/deploy-script-support';

/** @type {Record<string, import('@agoric/orchestration/src/chain-info.js').ChainInfo>} */
const chainInfo = {
hot: {
allegedName: 'Hot New Chain',
chainId: 'hot-1',
connections: {
'cosmoshub-4': {
id: 'connection-99',
client_id: '07-tendermint-3',
counterparty: {
client_id: '07-tendermint-2',
connection_id: 'connection-1',
prefix: {
key_prefix: '',
},
},
state: 3 /* IBCConnectionState.STATE_OPEN */,
transferChannel: {
portId: 'transfer',
channelId: 'channel-1',
counterPartyChannelId: 'channel-1',
counterPartyPortId: 'transfer',
ordering: 1 /* Order.ORDER_UNORDERED */,
state: 3 /* IBCConnectionState.STATE_OPEN */,
version: 'ics20-1',
},
},
},
},
};

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */
export const defaultProposalBuilder = async () =>
harden({
sourceSpec: '@agoric/orchestration/src/proposals/revise-chain-info.js',
getManifestCall: [
'getManifestForReviseChains',
{
chainInfo,
},
],
});

export default async (homeP, endowments) => {
const { writeCoreEval } = await makeHelpers(homeP, endowments);
await writeCoreEval('revise-chain-info', defaultProposalBuilder);
};
5 changes: 4 additions & 1 deletion packages/orchestration/src/proposals/revise-chain-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ const trace = makeTracer('ReviseChainInfo', true);

/** @import {CosmosChainInfo} from '../types.js'; */

// ??? what other keys does the second param ever have?
/**
* This will add news values AND overwrite any existing values. Voters on a
* proposal of core-eval must be careful not to overwrite any values operating
* in production.
*
* @param {BootstrapPowers} powers
* @param {{ options: { chainInfo: Record<string, CosmosChainInfo> } }} opt
*/
Expand Down

0 comments on commit 699f2b1

Please sign in to comment.