-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...integration/proposals/a:upgrade-next/provisioning-test-submission/send-script-permit.json
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 @@ | ||
true |
28 changes: 28 additions & 0 deletions
28
a3p-integration/proposals/a:upgrade-next/provisioning-test-submission/send-script.tjs
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,28 @@ | ||
#! false node --ignore-this-line | ||
/* global E */ | ||
|
||
/// <reference types="@agoric/vats/src/core/core-eval-env"/> | ||
/// <reference types="@agoric/vats/src/core/types-ambient"/> | ||
|
||
/** | ||
* Send a payment by looking up deposit facet via namesByAddress. | ||
* | ||
* see ./post.test.js | ||
* | ||
* @param {BootstrapPowers} powers | ||
*/ | ||
const sendIt = async powers => { | ||
const addr = '{{ADDRESS}}'; | ||
const { | ||
consume: { namesByAddress, zoe }, | ||
instance: { | ||
consume: { reserve }, | ||
}, | ||
} = powers; | ||
const pf = E(zoe).getPublicFacet(reserve); | ||
const anInvitation = await E(pf).makeAddCollateralInvitation(); | ||
const addressDepositFacet = E(namesByAddress).lookup(addr, 'depositFacet'); | ||
await E(addressDepositFacet).receive(anInvitation); | ||
}; | ||
|
||
sendIt; |
51 changes: 51 additions & 0 deletions
51
a3p-integration/proposals/a:upgrade-next/provisioning.test.js
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,51 @@ | ||
// @ts-check | ||
|
||
import test from 'ava'; | ||
import { readFile, writeFile } from 'node:fs/promises'; | ||
|
||
import { | ||
getIncarnation, | ||
getUser, | ||
evalBundles, | ||
waitForBlock, | ||
agoric, | ||
} from '@agoric/synthetic-chain'; | ||
|
||
const SUBMISSION_DIR = 'provisioning-test-submission'; | ||
|
||
/** | ||
* @param {string} fileName base file name without .tjs extension | ||
* @param {Record<string, string>} replacements | ||
*/ | ||
const replaceTemplateValuesInFile = async (fileName, replacements) => { | ||
let script = await readFile(`${fileName}.tjs`, 'utf-8'); | ||
for (const [template, value] of Object.entries(replacements)) { | ||
script = script.replaceAll(`{{${template}}}`, value); | ||
} | ||
await writeFile(`${fileName}.js`, script); | ||
}; | ||
|
||
test(`provisioning vat was upgraded`, async t => { | ||
const incarnation = await getIncarnation('provisioning'); | ||
|
||
t.is(incarnation, 1); | ||
}); | ||
|
||
test(`send invitation via namesByAddress`, async t => { | ||
const addr = await getUser('gov1'); | ||
|
||
await replaceTemplateValuesInFile(`${SUBMISSION_DIR}/send-script`, { | ||
ADDRESS: addr, | ||
}); | ||
|
||
await evalBundles(SUBMISSION_DIR); | ||
|
||
await waitForBlock(2); // enough time for invitation to arrive? | ||
const update = await agoric.follow('-lF', `:published.wallet.${addr}`); | ||
t.is(update.updated, 'balance'); | ||
t.notDeepEqual(update.currentAmount.value, []); | ||
t.log('balance value', update.currentAmount.value); | ||
t.log('balance brand', update.currentAmount.brand); | ||
// XXX agoric follow returns brands as strings | ||
t.regex(update.currentAmount.brand, /Invitation/); | ||
}); |
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