Skip to content

Commit

Permalink
fix(a3p): remove usage of duplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge-Lopes committed Dec 12, 2024
1 parent cb5dad8 commit e960919
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 202 deletions.
6 changes: 1 addition & 5 deletions a3p-integration/proposals/p:upgrade-19/mintHolder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ import {
getPSMChildren,
upgradeMintHolder,
} from './test-lib/mintHolder-helpers.js';

const networkConfig = {
rpcAddrs: ['http://0.0.0.0:26657'],
chainName: 'agoriclocal',
};
import { networkConfig } from './test-lib/index.js';

test('mintHolder contract is upgraded', async t => {
const receiver = await addUser('receiver');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@agoric/synthetic-chain';
import { makeVstorageKit, retryUntilCondition } from '@agoric/client-utils';
import { readFile, writeFile } from 'node:fs/promises';
import { sendOfferAgd, psmSwap, snapshotAgoricNames } from './psm-helpers.js';
import { psmSwap, snapshotAgoricNames } from './psm-lib.js';

/**
* @param {string} fileName base file name without .tjs extension
Expand Down Expand Up @@ -103,12 +103,18 @@ export const swap = async (t, address, assetList, want) => {
const istBalanceBefore = await getISTBalance(address, 'uist');
const anchorBalanceBefore = await getISTBalance(address, denom);

await psmSwap(address, ['swap', '--pair', pair, '--wantMinted', want], {
const psmSwapIo = {
now: Date.now,
follow: agoric.follow,
setTimeout,
sendOffer: sendOfferAgd,
});
log: console.log,
};

await psmSwap(
address,
['swap', '--pair', pair, '--wantMinted', want],
psmSwapIo,
);

const istBalanceAfter = await getISTBalance(address, 'uist');
const anchorBalanceAfter = await getISTBalance(address, denom);
Expand Down
192 changes: 0 additions & 192 deletions a3p-integration/proposals/p:upgrade-19/test-lib/psm-helpers.js

This file was deleted.

27 changes: 26 additions & 1 deletion a3p-integration/proposals/p:upgrade-19/test-lib/psm-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@

import { execa } from 'execa';
import { getNetworkConfig } from 'agoric/src/helpers.js';
import { waitUntilOfferResult } from '@agoric/client-utils';
import {
waitUntilOfferResult,
makeFromBoard,
boardSlottingMarshaller,
} from '@agoric/client-utils';
import { deepMapObject } from '@agoric/internal';
import {
agd,
agoric,
agopsLocation,
CHAINID,
executeCommand,
Expand Down Expand Up @@ -285,3 +290,23 @@ export const tryISTBalances = async (t, actualBalance, expectedBalance) => {
const minFeeDebit = 200_000;
t.is(actualBalance + minFeeDebit, expectedBalance);
};

const fromBoard = makeFromBoard();
const marshaller = boardSlottingMarshaller(fromBoard.convertSlotToVal);

/**
* @param {string} path
*/
const objectFromVstorageEntries = async path => {
const rawEntries = await agoric.follow('-lF', `:${path}`, '-o', 'text');
return Object.fromEntries(marshaller.fromCapData(JSON.parse(rawEntries)));
};

export const snapshotAgoricNames = async () => {
const [brands, instances, vbankAssets] = await Promise.all([
objectFromVstorageEntries('published.agoricNames.brand'),
objectFromVstorageEntries('published.agoricNames.instance'),
objectFromVstorageEntries('published.agoricNames.vbankAsset'),
]);
return { brands, instances, vbankAssets };
};

0 comments on commit e960919

Please sign in to comment.