-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Description Filling out some use case and test coverage. This adds undelegate to LCA. Also a bunch of cleanup. ### Security Considerations <!-- Does this change introduce new assumptions or dependencies that, if violated, could introduce security vulnerabilities? How does this PR change the boundaries between mutually-suspicious components? What new authorities are introduced by this change, perhaps by new API calls? --> ### Scaling Considerations <!-- Does this change require or encourage significant increase in consumption of CPU cycles, RAM, on-chain storage, message exchanges, or other scarce resources? If so, can that be prevented or mitigated? --> ### Documentation Considerations <!-- Give our docs folks some hints about what needs to be described to downstream users. Backwards compatibility: what happens to existing data or deployments when this code is shipped? Do we need to instruct users to do something to upgrade their saved data? If there is no upgrade path possible, how bad will that be for users? --> ### Testing Considerations <!-- Every PR should of course come with tests of its own functionality. What additional tests are still needed beyond those unit tests? How does this affect CI, other test automation, or the testnet? --> ### Upgrade Considerations <!-- What aspects of this PR are relevant to upgrading live production systems, and how should they be addressed? -->
- Loading branch information
Showing
20 changed files
with
442 additions
and
261 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js'; | ||
|
||
import type { TestFn } from 'ava'; | ||
|
||
import { Fail } from '@agoric/assert'; | ||
import { AmountMath } from '@agoric/ertp'; | ||
import type { start as stakeBldStart } from '@agoric/orchestration/src/examples/stakeBld.contract.js'; | ||
import type { Instance } from '@agoric/zoe/src/zoeService/utils.js'; | ||
import { M, matches } from '@endo/patterns'; | ||
import { makeWalletFactoryContext } from './walletFactory.ts'; | ||
|
||
type DefaultTestContext = Awaited<ReturnType<typeof makeWalletFactoryContext>>; | ||
|
||
const test: TestFn<DefaultTestContext> = anyTest; | ||
|
||
test.before(async t => (t.context = await makeWalletFactoryContext(t))); | ||
test.after.always(t => t.context.shutdown?.()); | ||
|
||
test.serial('stakeBld', async t => { | ||
const { | ||
agoricNamesRemotes, | ||
buildProposal, | ||
evalProposal, | ||
refreshAgoricNamesRemotes, | ||
} = t.context; | ||
// TODO move into a vm-config for u15 | ||
await evalProposal( | ||
buildProposal('@agoric/builders/scripts/vats/init-localchain.js'), | ||
); | ||
// start-stakeBld depends on this. Sanity check in case the context changes. | ||
const { BLD } = agoricNamesRemotes.brand; | ||
BLD || Fail`BLD missing from agoricNames`; | ||
await evalProposal( | ||
buildProposal('@agoric/builders/scripts/orchestration/init-stakeBld.js'), | ||
); | ||
// update now that stakeBld is instantiated | ||
refreshAgoricNamesRemotes(); | ||
const stakeBld = agoricNamesRemotes.instance.stakeBld as Instance< | ||
typeof stakeBldStart | ||
>; | ||
t.truthy(stakeBld); | ||
|
||
const wd = await t.context.walletFactoryDriver.provideSmartWallet( | ||
'agoric1testStakeBld', | ||
); | ||
|
||
await wd.executeOffer({ | ||
id: 'request-stake', | ||
invitationSpec: { | ||
source: 'agoricContract', | ||
instancePath: ['stakeBld'], | ||
callPipe: [['makeStakeBldInvitation']], | ||
}, | ||
proposal: { | ||
give: { | ||
// @ts-expect-error XXX BoardRemote | ||
In: { brand: BLD, value: 10n }, | ||
}, | ||
}, | ||
}); | ||
|
||
const current = await wd.getCurrentWalletRecord(); | ||
const latest = await wd.getLatestUpdateRecord(); | ||
t.like(current, { | ||
offerToPublicSubscriberPaths: [ | ||
// TODO publish something useful | ||
['request-stake', { account: 'published.stakeBld' }], | ||
], | ||
}); | ||
t.like(latest, { | ||
status: { id: 'request-stake', numWantsSatisfied: 1 }, | ||
}); | ||
|
||
await wd.executeOffer({ | ||
id: 'request-delegate', | ||
invitationSpec: { | ||
source: 'continuing', | ||
previousOffer: 'request-stake', | ||
invitationMakerName: 'Delegate', | ||
invitationArgs: ['agoric1validator1', { brand: BLD, value: 10n }], | ||
}, | ||
proposal: { | ||
give: { | ||
// @ts-expect-error XXX BoardRemote | ||
In: { brand: BLD, value: 10n }, | ||
}, | ||
}, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.