Skip to content

Commit

Permalink
chore: "oracles accept" handles already accepted invs
Browse files Browse the repository at this point in the history
- mainly to facilitate active development; allows test to be run more than once
  • Loading branch information
0xpatrickdev committed Dec 13, 2024
1 parent 12ce988 commit 57494a3
Showing 1 changed file with 32 additions and 5 deletions.
37 changes: 32 additions & 5 deletions multichain-testing/test/fast-usdc/fast-usdc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,44 @@ const toOracleOfferId = (idx: number) => `oracle${idx + 1}-accept`;

test.serial('oracles accept', async t => {
const { oracleWds, retryUntilCondition, vstorageClient, wallets } = t.context;
const brands = await vstorageClient.queryData('published.agoricNames.brand');
const { Invitation } = Object.fromEntries(brands);

const instances = await vstorageClient.queryData(
'published.agoricNames.instance',
);
const instance = fromEntries(instances)[contractName];
// TODO export/import INVITATION_MAKERS_DESC
const ORACLE_INV_DESC = 'oracle operator invitation';

// ensure we have an unused (or used) oracle invitation in each purse
let hasAccepted = false;
for (const name of keys(oracleMnemonics)) {
const { offerToUsedInvitation, purses } = await vstorageClient.queryData(
`published.wallet.${wallets[name]}.current`,
);
const { value: invitations } = balancesFromPurses(purses)[Invitation];
const hasInvitation = invitations.some(
x => x.description === ORACLE_INV_DESC,
);
const usedInvitation = offerToUsedInvitation?.[0]?.[0] === `${name}-accept`;
t.log({ name, hasInvitation, usedInvitation });
t.true(hasInvitation || usedInvitation, 'has or accepted invitation');
if (usedInvitation) hasAccepted = true;
}
// if the oracles have already accepted, skip the rest of the test this is
// primarily to facilitate active development but could support testing on
// images where operator invs are already accepted
if (hasAccepted) return t.pass();

// accept oracle operator invitations
const instance = fromEntries(
await vstorageClient.queryData('published.agoricNames.instance'),
)[contractName];
await Promise.all(
oracleWds.map(makeDoOffer).map((doOffer, i) =>
doOffer({
id: toOracleOfferId(i),
invitationSpec: {
source: 'purse',
instance,
description: 'oracle operator invitation', // TODO export/import INVITATION_MAKERS_DESC
description: ORACLE_INV_DESC,
},
proposal: {},
}),
Expand Down Expand Up @@ -387,3 +410,7 @@ test.serial('lp withdraws', async t => {
),
);
});

test.todo('insufficient LP funds; forward path');
test.todo('mint while Advancing; still Disbursed');
test.todo('transfer failed (e.g. to cosmos, not in env)');

0 comments on commit 57494a3

Please sign in to comment.