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

test: depositing to and withdrawing from a remote ica account #10211

Merged
merged 3 commits into from
Oct 4, 2024

Conversation

0xpatrickdev
Copy link
Member

@0xpatrickdev 0xpatrickdev commented Oct 3, 2024

closes: #9193

Description

  • adds e2e tests for Deposit and Withdraw invitationMakers for LocalOrchestrationAccount via the basic-flows contract
  • adds e2e test demonstrating depositing to and withdrawing from an ICA in a PortfolioHolder via the basic-flows contract
  • updates PortfolioHolder's Proxying invitationMaker to optionally accept invitationArgs

Security Considerations

n/a, primarily tests

Scaling Considerations

n/a, primarily tests

Documentation Considerations

These tests serve as documentation for using the Deposit, Withdraw, Transfer, and Proxying invitationMakers from the Orchestration API

Testing Considerations

PR includes E2E tests to close out the referenced issue.

Upgrade Considerations

Library code for NPM Orch release

@0xpatrickdev 0xpatrickdev added the force:integration Force integration tests to run on PR label Oct 3, 2024
@0xpatrickdev 0xpatrickdev marked this pull request as ready for review October 3, 2024 21:23
@0xpatrickdev 0xpatrickdev requested a review from a team as a code owner October 3, 2024 21:23
@dckc
Copy link
Member

dckc commented Oct 3, 2024

scope question...

closes: #9193

#9193 depends on #9784, which is open. How can this close #9193 without closing #9784?

@0xpatrickdev
Copy link
Member Author

scope question...

closes: #9193

#9193 depends on #9784, which is open. How can this close #9193 without closing #9784?

I think that's a mistake. I am going to remove it from the requirements. I also adjusted the description for #9784 to better reflect the current state of things. .transfer() / Transfer is implemented, just not to the same level as it is in LocalOrchAccount. Getting notified of a successful transfer is not a current capability and needs design.

Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

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

sharing my comments so far

Comment on lines +17 to +19
const { deleteTestKeys, setupTestKeys, ...rest } = await commonSetup(t);
deleteTestKeys(accounts).catch();
const wallets = await setupTestKeys(accounts);
Copy link
Member

Choose a reason for hiding this comment

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

Aside...

In Agoric/dapp-orchestration-basics#61 where I folded in your work on starship testing, I struggled a bit to get this commonSetup(t) stuff working. In order to be able to test it without re-deploying my contract for each iteration (or worse: standing up the whole cluster again), I factored out the ambient authority so I could inject mocks for quick ava testing.

See test('orca-multichain.test style usage', ...).
https://github.com/Agoric/dapp-orchestration-basics/blob/63f85352eaa73659d4cadbc1f17d48dd4095d98c/contract/test/agd-lib.test.js#L234

and test('deploy-cli style usage', ...)
https://github.com/Agoric/dapp-orchestration-basics/blob/main/contract/test/agd-lib.test.js#L214

Here's hoping we can migrate that back to support.js here in due course.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice, that's a good approach for this problem. We added startContact in 3639831 a bit ago that ensures the contract is only installed once by querying vstorage

I wonder what the best path is for keeping testing tools in sync with minimal effort. Releases were something I'd floated in the past but it didn't seem to get much support.

invitationSpec: {
source: 'agoricContract',
instancePath: [contractName],
callPipe: [['makeOrchAccountInvitation']],
Copy link
Member

Choose a reason for hiding this comment

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

devex note: it would be nice if our contracts came with a supplementary module of constants so that client didn't have to come up with magic strings like this.

For example: https://github.com/Agoric/agoric-sdk/blob/master/packages/inter-protocol/src/clientSupport.js

Copy link
Member

@turadg turadg Oct 3, 2024

Choose a reason for hiding this comment

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

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.

Awesome to have this user story tested e2e

I'd like to improve the abstractions in the tests so they're more reviewable by Product, but that can wait


const accountStoragePath = Object.fromEntries(offerToPublicSubscriberPaths)[
makeAccountOfferId
]?.account;
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 surprised this optional doesn't cause a problem for the .split on 73. Maybe offerToPublicSubscriberPaths is `any? Not a blocker but consider typing.

Suggested change
]?.account;
]!.account;

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, offerToPublicSubscriberPaths is any. Typing that here doesn't feel right - I've added a TODO for #10214


// IBC Transfer funds to remoteChain account
const remoteChainId = remoteChainInfo.chain.chain_id;
const ibcTransferOfferId = `Transfer-to-${chainName}-${Date.now()}`;
Copy link
Member

Choose a reason for hiding this comment

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

the other offer ids are lowercase

- creates a `PortfolioHolder` account that's comprised of a local and remote orchAccounts
- uses `Deposit` and `Transfer` invitationMakers (via `Proxying`) to send funds to `remoteOrchAccount`
- uses `Transfer` and `Withdraw` invitationMakers (via `Proxying`) to retrieve funds from `remoteOrchAccount`
@0xpatrickdev 0xpatrickdev force-pushed the pc/deposit-withdraw-e2e branch from 6021289 to 4a2108a Compare October 4, 2024 15:49
Copy link

cloudflare-workers-and-pages bot commented Oct 4, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: ba81770
Status: ✅  Deploy successful!
Preview URL: https://269bfedc.agoric-sdk.pages.dev
Branch Preview URL: https://pc-deposit-withdraw-e2e.agoric-sdk.pages.dev

View logs

@0xpatrickdev 0xpatrickdev force-pushed the pc/deposit-withdraw-e2e branch 3 times, most recently from 9d82dfa to 53f76a5 Compare October 4, 2024 16:26
Copy link
Member Author

@0xpatrickdev 0xpatrickdev left a comment

Choose a reason for hiding this comment

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

@0xpatrickdev in Documentation Considerations of #10211, you write...

These tests serve as documentation for using the Deposit, Withdraw, Transfer, and Proxying invitationMakers from the Orchestration API

Do we have any JSDoc for those? I'm struggling to find PortfolioHolderKit at all in @agoric/orchestration API docs.

Good question @dckc . I exported the types for PortfolioHolder and MakeCombineInvitationMakers in the recent commits and improved the copy.

See: https://e46fc33c.agoric-sdk.pages.dev/funcs/_agoric_orchestration.preparePortfolioHolder and https://e46fc33c.agoric-sdk.pages.dev/funcs/_agoric_orchestration.prepareCombineInvitationMakers

Edit: moved to its own PR: #10217


const accountStoragePath = Object.fromEntries(offerToPublicSubscriberPaths)[
makeAccountOfferId
]?.account;
Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, offerToPublicSubscriberPaths is any. Typing that here doesn't feel right - I've added a TODO for #10214

@0xpatrickdev 0xpatrickdev force-pushed the pc/deposit-withdraw-e2e branch from 53f76a5 to ba81770 Compare October 4, 2024 17:09
@0xpatrickdev 0xpatrickdev added the automerge:rebase Automatically rebase updates, then merge label Oct 4, 2024
@mergify mergify bot merged commit 097ef82 into master Oct 4, 2024
87 of 95 checks passed
@mergify mergify bot deleted the pc/deposit-withdraw-e2e branch October 4, 2024 17:44
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 force:integration Force integration tests to run on PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

orchestration - ICA Controller - deposit payment to ICA
3 participants