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

Multi collateral support - add concurrent liquidation tests #8422

Merged
merged 1 commit into from
Oct 7, 2023

Conversation

iomekam
Copy link
Contributor

@iomekam iomekam commented Oct 2, 2023

closes: #8270

Description

Adds test that validate concurrent liquidation of multiple collaterals.

Security Considerations

N/A

Scaling Considerations

N/A

Documentation Considerations

N/A

Testing Considerations

Adding new test, that have been validated locally

Upgrade Considerations

N/A

@iomekam iomekam force-pushed the 8270-concurrent-liquidation branch 2 times, most recently from 6486d53 to 41bcf85 Compare October 5, 2023 21:41
@iomekam iomekam marked this pull request as ready for review October 5, 2023 21:41
@iomekam iomekam requested a review from turadg October 5, 2023 21:41
@iomekam iomekam changed the title 8270 concurrent liquidation Multi collateral support - add concurrent liquidation tests Oct 5, 2023
@iomekam iomekam force-pushed the 8270-concurrent-liquidation branch from 41bcf85 to 9af1e08 Compare October 5, 2023 22:10
packages/boot/test/bootstrapTests/liquidation.ts Outdated Show resolved Hide resolved
t.log('building proposal');
const proposal = await buildProposal({
package: 'builders',
packageScriptName: 'build:add-STARS-proposal',
Copy link
Member

Choose a reason for hiding this comment

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

Out of scope, but we should parameterize this function to addNewCollateral and take the collateral name. @Chris-Hibbert needed (and made) such a thing in https://github.com/Agoric/agoric-sdk/pull/8398/files#diff-3c4081d1865d2d24a7abaee93a075a8852065c32783fbe25265746c13441875bR38-R45

packages/boot/test/bootstrapTests/test-liquidation-1.ts Outdated Show resolved Hide resolved

const test = anyTest as TestFn<LiquidationTestContext>;

const atomSetup = {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not reviewing the arithmetic. I assume you'll sync with PM on the correctness per their spec

const buyer = await walletFactoryDriver.provideSmartWallet('agoric1buyer');
const minter = await walletFactoryDriver.provideSmartWallet('agoric1minter');

const setupVault = async (
Copy link
Member

Choose a reason for hiding this comment

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

isn't this the same as in concurrent-1? please dedupe

return t.context.shutdown && t.context.shutdown();
});

const checkFlow2b = async (t: ExecutionContext<LiquidationTestContext>) => {
Copy link
Member

Choose a reason for hiding this comment

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

where is the "b" coming from?

Copy link
Contributor

Choose a reason for hiding this comment

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

Flow 2b from #7123

Copy link
Member

Choose a reason for hiding this comment

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

I asked socratically :) (that 2b is for a different test flow than this one)

Copy link
Member

Choose a reason for hiding this comment

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

I asked socratically :) (that 2b is for a different test flow than this one)

};

// Reference: Flow 2b from https://github.com/Agoric/agoric-sdk/issues/7123
test.serial('scenario: Flow 2b', async t => {
Copy link
Member

Choose a reason for hiding this comment

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

the helper function factoring is for re-use in multiple tests. since there's only in in this case it's an unwarranted complication

@iomekam iomekam force-pushed the 8270-concurrent-liquidation branch from 9af1e08 to 3d149fe Compare October 6, 2023 16:39
@iomekam iomekam requested a review from turadg October 6, 2023 18:58
Copy link
Member

@turadg turadg left a comment

Choose a reason for hiding this comment

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

Looking good.

packages/boot/test/bootstrapTests/liquidation.ts Outdated Show resolved Hide resolved
packages/boot/test/bootstrapTests/test-liquidation-1.ts Outdated Show resolved Hide resolved
packages/boot/test/bootstrapTests/liquidation.ts Outdated Show resolved Hide resolved
@iomekam iomekam force-pushed the 8270-concurrent-liquidation branch from 94694b6 to de35fd0 Compare October 6, 2023 20:55
@iomekam iomekam requested a review from turadg October 6, 2023 21:07
@iomekam iomekam force-pushed the 8270-concurrent-liquidation branch from de35fd0 to 90b2cc0 Compare October 6, 2023 21:13
collateralBrandKey: string,
t: ExecutionContext<LiquidationTestContext>,
) => {
// TODO: we'd like to have this work on any brand
Copy link
Member

Choose a reason for hiding this comment

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

nice solution! creates the right abstraction and we can improve its robustness later

Comment on lines 217 to 219
for (const { collateralBrandKey } of cases) {
await ensureVaultCollateral(collateralBrandKey, t)
}
Copy link
Member

Choose a reason for hiding this comment

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

this lint error could be ignored for tests but it still would be better to:

await Promise.all(
  cases.map(({collateralBrandKey}) => ensureVaultCollateral(collateralBrandKey, t));
);

Comment on lines 201 to 202
{
// ---------------
Copy link
Member

Choose a reason for hiding this comment

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

consider restoring this block to reduce churn for indentation.

@iomekam iomekam force-pushed the 8270-concurrent-liquidation branch from 90b2cc0 to c59e114 Compare October 6, 2023 22:11
@iomekam iomekam force-pushed the 8270-concurrent-liquidation branch from c59e114 to c900417 Compare October 6, 2023 22:18
@iomekam iomekam added the automerge:rebase Automatically rebase updates, then merge label Oct 6, 2023
@mergify mergify bot merged commit 3e909dc into master Oct 7, 2023
80 checks passed
@mergify mergify bot deleted the 8270-concurrent-liquidation branch October 7, 2023 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

automated test of Multiple Collateral Liquidation
3 participants