-
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.
test:
send-anywhere
pfm scenarios (#10591)
closes: #9966 closes: #10445 ## Description Adds multi-hop (PFM) scenarios to the `examples/send-anywhere.contract.js` multichain (e2e) test. To support this change, this PR also includes: - a proposal for registering interchain assets in vbank (closes #9966). aims for production quality but is only used in tests - a `fundFaucet` helper in `multichain-testing` so developers can request ATOM, OSMO, etc in `provisionSmartWallet` - a `GoDuration` type in `@agoric/orchestration` that captures basic Go [time duration strings](https://pkg.go.dev/time#ParseDuration) and an update to `DefaultPfmTimeoutOpts` (10min -> 10m) ### Security Considerations `@agoric/builders/scripts/testing/register-interchain-bank-assets.js` allows callers overwrite assets in `vbank` and `agoricNames`. It's only intended for testing, and shouldn't be used in production. A production version might guard against accidental overrides. ### Scaling Considerations None, mostly test code. Adds a little CI time to `multichain-testing` for the extra CoreEval. ### Documentation Considerations None ### Testing Considerations Includes an E2E to test in `multichain-testing` that leverages `register-interchain-bank-assets.js`. Also includes the first E2E test of PFM functionality added in #10584 and #10571. ### Upgrade Considerations None, library code an NPM orch or FUSDC release.
- Loading branch information
Showing
26 changed files
with
572 additions
and
118 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env -S node --import ts-blank-space/register | ||
/* eslint-env node */ | ||
|
||
import '@endo/init'; | ||
import starshipChainInfo from '../starship-chain-info.js'; | ||
import { makeAssetInfo } from '../tools/asset-info.ts'; | ||
|
||
const main = () => { | ||
if (!starshipChainInfo) { | ||
throw new Error( | ||
'starshipChainInfo not found. run `./scripts/fetch-starship-chain-info.ts` first.', | ||
); | ||
} | ||
|
||
const assetInfo = makeAssetInfo(starshipChainInfo) | ||
.filter( | ||
([_, { chainName, baseName }]) => | ||
chainName === 'agoric' && baseName !== 'agoric', | ||
) | ||
.map(([denom, { baseDenom }]) => ({ | ||
denom, | ||
issuerName: baseDenom.replace(/^u/, '').toUpperCase(), | ||
decimalPlaces: 6, // TODO do not assume 6 | ||
})); | ||
|
||
// Directly output JSON string for proposal builder options | ||
process.stdout.write(JSON.stringify(assetInfo)); | ||
}; | ||
|
||
main(); |
51 changes: 51 additions & 0 deletions
51
multichain-testing/src/register-interchain-bank-assets.builder.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 @@ | ||
/* global harden */ | ||
/// <reference types="ses" /> | ||
import { makeHelpers } from '@agoric/deploy-script-support'; | ||
import { parseArgs } from 'node:util'; | ||
|
||
/** | ||
* @import {ParseArgsConfig} from 'node:util'; | ||
* @import {CoreEvalBuilder, DeployScriptFunction} from '@agoric/deploy-script-support/src/externalTypes.js'; | ||
*/ | ||
|
||
/** @type {ParseArgsConfig['options']} */ | ||
const parserOpts = { | ||
assets: { type: 'string' }, | ||
}; | ||
|
||
/** @type {CoreEvalBuilder} */ | ||
export const defaultProposalBuilder = async (_, options) => { | ||
return harden({ | ||
sourceSpec: | ||
'@agoric/builders/scripts/testing/register-interchain-bank-assets.js', | ||
getManifestCall: ['getManifestCall', options], | ||
}); | ||
}; | ||
|
||
/** @type {DeployScriptFunction} */ | ||
export default async (homeP, endowments) => { | ||
const { scriptArgs } = endowments; | ||
|
||
const { | ||
values: { assets }, | ||
} = parseArgs({ | ||
args: scriptArgs, | ||
options: parserOpts, | ||
}); | ||
|
||
const parseAssets = () => { | ||
if (typeof assets !== 'string') { | ||
throw Error( | ||
'must provide --assets=JSON.stringify({ denom: Denom; issuerName: string; decimalPlaces: number; }[])', | ||
); | ||
} | ||
return JSON.parse(assets); | ||
}; | ||
|
||
const opts = harden({ assets: parseAssets() }); | ||
|
||
const { writeCoreEval } = await makeHelpers(homeP, endowments); | ||
await writeCoreEval('eval-register-interchain-bank-assets', utils => | ||
defaultProposalBuilder(utils, opts), | ||
); | ||
}; |
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
30 changes: 30 additions & 0 deletions
30
multichain-testing/test/scripts/make-bank-asset-info.test.ts
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,30 @@ | ||
import test from 'ava'; | ||
import { execFileSync } from 'node:child_process'; | ||
|
||
test('make-bank-asset-info', async t => { | ||
const stdout = execFileSync('./scripts/make-bank-asset-info.ts', { | ||
encoding: 'utf8', | ||
}); | ||
|
||
const assetInfo = JSON.parse(stdout); | ||
|
||
t.like(assetInfo, [ | ||
{ | ||
issuerName: 'ATOM', | ||
decimalPlaces: 6, | ||
}, | ||
{ | ||
issuerName: 'OSMO', | ||
decimalPlaces: 6, | ||
}, | ||
{ | ||
issuerName: 'ION', | ||
decimalPlaces: 6, | ||
}, | ||
]); | ||
|
||
for (const { denom } of assetInfo) { | ||
t.regex(denom, /^ibc\//); | ||
t.is(denom.length, 68); | ||
} | ||
}); |
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.