Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multichain testing improvements #10713

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions multichain-testing/test/account-balance-queries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const queryAccountBalances = test.macro({
const {
wallets,
provisionSmartWallet,
vstorageClient,
smartWalletKit,
retryUntilCondition,
} = t.context;

Expand All @@ -67,7 +67,8 @@ const queryAccountBalances = test.macro({
});

const offerResult = await retryUntilCondition(
() => vstorageClient.queryData(`published.wallet.${agoricAddr}`),
() => smartWalletKit.readPublished(`wallet.${agoricAddr}`),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in what way is this a kit? it looks like 1 object with methods, not a kit of facets.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm pretty sure "kit" is not necessarily an ExoClassKit.

is there another name you'd suggest? It would be a change to client-utils

// @ts-expect-error UpdateRecord may not have 'status'
({ status }) => status.id === offerId && (status.result || status.error),
Comment on lines +71 to 72
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there's no status, status.id will throw, right?

Suggested change
// @ts-expect-error UpdateRecord may not have 'status'
({ status }) => status.id === offerId && (status.result || status.error),
(u) => u?.status.id === offerId && (u?.status.result || u?.status.error),

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered the seatLike .getOfferResult() API?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haven't considered that yet. I was just trying to DRY out what I could.

do you think that API should be part of client-utils?

`${offerId} offer result is in vstorage`,
MAKE_ACCOUNT_AND_QUERY_BALANCE_TIMEOUT,
Expand All @@ -83,6 +84,7 @@ const queryAccountBalances = test.macro({
);

const {
// @ts-expect-error UpdateRecord may not have 'status'
status: { result, error },
} = offerResult;
if (expectValidResult) {
Expand Down Expand Up @@ -110,7 +112,7 @@ const queryAccountBalance = test.macro({
const {
wallets,
provisionSmartWallet,
vstorageClient,
smartWalletKit,
retryUntilCondition,
useChain,
} = t.context;
Expand Down Expand Up @@ -146,7 +148,8 @@ const queryAccountBalance = test.macro({
});

const offerResult = await retryUntilCondition(
() => vstorageClient.queryData(`published.wallet.${agoricAddr}`),
() => smartWalletKit.readPublished(`wallet.${agoricAddr}`),
// @ts-expect-error UpdateRecord may not have 'status'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here we are with another copy of the getOfferResult() logic.

({ status }) => status.id === offerId && (status.result || status.error),
`${offerId} offer result is in vstorage`,
MAKE_ACCOUNT_AND_QUERY_BALANCE_TIMEOUT,
Expand All @@ -162,6 +165,7 @@ const queryAccountBalance = test.macro({
);

const {
// @ts-expect-error UpdateRecord may not have 'status'
status: { result, error },
} = offerResult;
if (expectValidResult) {
Expand Down
7 changes: 4 additions & 3 deletions multichain-testing/test/auto-stake-it.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const autoStakeItScenario = test.macro({
// 1. setup
const {
wallets,
vstorageClient,
smartWalletKit,
provisionSmartWallet,
retryUntilCondition,
useChain,
Expand Down Expand Up @@ -98,9 +98,9 @@ const autoStakeItScenario = test.macro({

// FIXME https://github.com/Agoric/agoric-sdk/issues/9643
const currentWalletRecord = await retryUntilCondition(
() =>
vstorageClient.queryData(`published.wallet.${agoricUserAddr}.current`),
() => smartWalletKit.readPublished(`wallet.${agoricUserAddr}.current`),
({ offerToPublicSubscriberPaths }) =>
// @ts-expect-error retryUntilCondition expects a boolean return
Object.fromEntries(offerToPublicSubscriberPaths)[offerId],
`${offerId} continuing invitation is in vstorage`,
);
Expand All @@ -118,6 +118,7 @@ const autoStakeItScenario = test.macro({
.split('.')
.pop();
console.log({ lcaAddress, icaAddress });
assert(lcaAddress && icaAddress);
t.regex(lcaAddress, /^agoric1/, 'LOA address is valid');
t.regex(
icaAddress,
Expand Down
11 changes: 7 additions & 4 deletions multichain-testing/test/basic-flows.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const makeAccountScenario = test.macro({
const {
wallets,
provisionSmartWallet,
vstorageClient,
smartWalletKit,
retryUntilCondition,
} = t.context;

Expand Down Expand Up @@ -66,8 +66,9 @@ const makeAccountScenario = test.macro({
// TODO fix above so we don't have to poll for the offer result to be published
// https://github.com/Agoric/agoric-sdk/issues/9643
const currentWalletRecord = await retryUntilCondition(
() => vstorageClient.queryData(`published.wallet.${agoricAddr}.current`),
() => smartWalletKit.readPublished(`wallet.${agoricAddr}.current`),
({ offerToPublicSubscriberPaths }) =>
// @ts-expect-error retryUntilCondition expects a boolean return
Object.fromEntries(offerToPublicSubscriberPaths)[offerId],
`${offerId} continuing invitation is in vstorage`,
);
Expand All @@ -80,17 +81,19 @@ const makeAccountScenario = test.macro({
.split('.')
.pop();
t.log('Got address:', address);
assert(address);
t.regex(
address,
new RegExp(`^${config.expectedAddressPrefix}1`),
`address for ${chainName} is valid`,
);

const latestWalletUpdate = await vstorageClient.queryData(
`published.wallet.${agoricAddr}`,
const latestWalletUpdate = await smartWalletKit.readPublished(
`wallet.${agoricAddr}`,
);
t.log('latest wallet update', latestWalletUpdate);
t.like(
// @ts-expect-error UpdateRecord may not have 'status'
latestWalletUpdate.status,
{
id: offerId,
Expand Down
18 changes: 12 additions & 6 deletions multichain-testing/test/chain-queries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const queryICQChain = test.macro({
const {
wallets,
provisionSmartWallet,
vstorageClient,
smartWalletKit,
retryUntilCondition,
useChain,
} = t.context;
Expand Down Expand Up @@ -108,7 +108,8 @@ const queryICQChain = test.macro({
});

const offerResult = await retryUntilCondition(
() => vstorageClient.queryData(`published.wallet.${agoricAddr}`),
() => smartWalletKit.readPublished(`wallet.${agoricAddr}`),
// @ts-expect-error UpdateRecord may not have 'status'
({ status }) => status.id === offerId && (status.result || status.error),
`${offerId} offer result is in vstorage`,
{
Expand All @@ -117,6 +118,7 @@ const queryICQChain = test.macro({
);
t.log('ICQ Query Offer Result', offerResult);
const {
// @ts-expect-error UpdateRecord may not have 'status'
status: { result, error },
} = offerResult;
t.is(error, undefined, 'No error observed');
Expand Down Expand Up @@ -160,7 +162,7 @@ const queryChainWithoutICQ = test.macro({
const {
wallets,
provisionSmartWallet,
vstorageClient,
smartWalletKit,
retryUntilCondition,
useChain,
} = t.context;
Expand Down Expand Up @@ -200,14 +202,16 @@ const queryChainWithoutICQ = test.macro({
});

const offerResult = await retryUntilCondition(
() => vstorageClient.queryData(`published.wallet.${agoricAddr}`),
() => smartWalletKit.readPublished(`wallet.${agoricAddr}`),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow there are a lot of these.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah. I think SmartWalletKit is a good place to hang something like "await a matching state of the status node and return it"

// @ts-expect-error UpdateRecord may not have 'status'
({ status }) => status.id === offerId && (status.result || status.error),
`${offerId} continuing invitation is in vstorage`,
{
maxRetries: 10,
},
);
t.is(
// @ts-expect-error UpdateRecord may not have 'status'
offerResult.status.error,
`Error: Queries not available for chain "${chain_id}"`,
'Queries not available error returned',
Expand All @@ -216,7 +220,7 @@ const queryChainWithoutICQ = test.macro({
});

test.serial('Send Local Query from chain object', async t => {
const { wallets, provisionSmartWallet, vstorageClient, retryUntilCondition } =
const { wallets, provisionSmartWallet, smartWalletKit, retryUntilCondition } =
t.context;

const agoricAddr = wallets['agoric'];
Expand Down Expand Up @@ -268,14 +272,16 @@ test.serial('Send Local Query from chain object', async t => {
});

const offerResult = await retryUntilCondition(
() => vstorageClient.queryData(`published.wallet.${agoricAddr}`),
() => smartWalletKit.readPublished(`wallet.${agoricAddr}`),
// @ts-expect-error UpdateRecord may not have 'status'
({ status }) => status.id === offerId && (status.result || status.error),
`${offerId} continuing invitation is in vstorage`,
{
maxRetries: 10,
},
);

// @ts-expect-error UpdateRecord may not have 'status'
const parsedResults = JSON.parse(offerResult.status.result);
t.truthy(parsedResults[0].height, 'query height is returned');
t.is(parsedResults[0].error, '', 'error is empty');
Expand Down
20 changes: 12 additions & 8 deletions multichain-testing/test/deposit-withdraw-lca.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test('Deposit IST to orchAccount and then withdraw', async t => {
const {
wallets,
provisionSmartWallet,
vstorageClient,
smartWalletKit,
retryUntilCondition,
useChain,
} = t.context;
Expand Down Expand Up @@ -61,8 +61,9 @@ test('Deposit IST to orchAccount and then withdraw', async t => {

// Wait for the orchAccount to be created
const { offerToPublicSubscriberPaths } = await retryUntilCondition(
() => vstorageClient.queryData(`published.wallet.${agoricAddr}.current`),
() => smartWalletKit.readPublished(`wallet.${agoricAddr}.current`),
({ offerToPublicSubscriberPaths }) =>
// @ts-expect-error retryUntilCondition expects a boolean return
Object.fromEntries(offerToPublicSubscriberPaths)[makeAccountOfferId],
'makeAccount offer result is in vstorage',
);
Expand All @@ -72,10 +73,10 @@ test('Deposit IST to orchAccount and then withdraw', async t => {
makeAccountOfferId
]!.account;
const lcaAddress = accountStoragePath.split('.').at(-1);
t.truthy(lcaAddress, 'Account address is in storage path');
assert(lcaAddress, 'Account address is in storage path');

// Get IST brand
const brands = await vstorageClient.queryData('published.agoricNames.brand');
const brands = await smartWalletKit.readPublished('agoricNames.brand');
const istBrand = Object.fromEntries(brands).IST;

// Deposit IST to orchAccount
Expand Down Expand Up @@ -150,7 +151,7 @@ test('Deposit IST to orchAccount and then withdraw', async t => {
test.todo('Deposit and Withdraw ATOM/OSMO to localOrchAccount via offer #9966');

test('Attempt to withdraw more than available balance', async t => {
const { wallets, provisionSmartWallet, vstorageClient, retryUntilCondition } =
const { wallets, provisionSmartWallet, smartWalletKit, retryUntilCondition } =
t.context;

// Provision the Agoric smart wallet
Expand Down Expand Up @@ -178,8 +179,9 @@ test('Attempt to withdraw more than available balance', async t => {

// Wait for the orchAccount to be created
const { offerToPublicSubscriberPaths } = await retryUntilCondition(
() => vstorageClient.queryData(`published.wallet.${agoricAddr}.current`),
() => smartWalletKit.readPublished(`wallet.${agoricAddr}.current`),
({ offerToPublicSubscriberPaths }) =>
// @ts-expect-error retryUntilCondition expects a boolean return
Object.fromEntries(offerToPublicSubscriberPaths)[makeAccountOfferId],
`${makeAccountOfferId} offer result is in vstorage`,
);
Expand All @@ -191,7 +193,7 @@ test('Attempt to withdraw more than available balance', async t => {
t.truthy(lcaAddress, 'Account address is in storage path');

// Get IST brand
const brands = await vstorageClient.queryData('published.agoricNames.brand');
const brands = await smartWalletKit.readPublished('agoricNames.brand');
const istBrand = Object.fromEntries(brands).IST;

// Attempt to withdraw more than available balance
Expand All @@ -212,11 +214,13 @@ test('Attempt to withdraw more than available balance', async t => {

// Verify that the withdrawal failed
const offerResult = await retryUntilCondition(
() => vstorageClient.queryData(`published.wallet.${agoricAddr}`),
() => smartWalletKit.readPublished(`wallet.${agoricAddr}`),
// @ts-expect-error UpdateRecord may not have 'status'
({ status }) => status.id === withdrawOfferId && status.error !== undefined,
'Withdrawal offer error is in vstorage',
);
t.is(
// @ts-expect-error UpdateRecord may not have 'status'
offerResult.status.error,
'Error: One or more withdrawals failed ["[Error: cannot grab 200uist coins: 0uist is smaller than 200uist: insufficient funds]"]',
);
Expand Down
13 changes: 6 additions & 7 deletions multichain-testing/test/deposit-withdraw-portfolio.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const portfolioAccountScenario = test.macro({
const {
wallets,
provisionSmartWallet,
vstorageClient,
smartWalletKit,
retryUntilCondition,
useChain,
} = t.context;
Expand Down Expand Up @@ -64,8 +64,9 @@ const portfolioAccountScenario = test.macro({
});

const { offerToPublicSubscriberPaths } = await retryUntilCondition(
() => vstorageClient.queryData(`published.wallet.${agoricAddr}.current`),
() => smartWalletKit.readPublished(`wallet.${agoricAddr}.current`),
({ offerToPublicSubscriberPaths }) =>
// @ts-expect-error retryUntilCondition expects a boolean return
Object.fromEntries(offerToPublicSubscriberPaths)[
makePortfolioAcctOfferId
],
Expand All @@ -81,13 +82,11 @@ const portfolioAccountScenario = test.macro({

const agoricLcaAddress = accountPaths.agoric.split('.').at(-1);
const remoteIcaAddress = accountPaths[chainName].split('.').at(-1);
t.truthy(agoricLcaAddress, 'Agoric LCA address is in storage path');
t.truthy(remoteIcaAddress, `${chainName} ICA address is in storage path`);
assert(agoricLcaAddress, 'Agoric LCA address is in storage path');
assert(remoteIcaAddress, `${chainName} ICA address is in storage path`);

// Get IST brand
const brands = await vstorageClient.queryData(
'published.agoricNames.brand',
);
const brands = await smartWalletKit.readPublished('agoricNames.brand');
const istBrand = Object.fromEntries(brands).IST;

// Setup query clients
Expand Down
Loading
Loading