From 0fdf898be8a4d8e39423784875a2338c8c0c70ba Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Tue, 25 Jun 2024 18:06:22 -0700 Subject: [PATCH] test: Verify patch for @cosmjs/math --- packages/agoric-cli/test/bundle-cosmjs-math.js | 1 + .../agoric-cli/test/bundle-cosmjs-math.test.js | 18 ++++++++++++++++++ packages/cosmic-proto/package.json | 2 ++ .../cosmic-proto/test/bundle-cosmjs-math.js | 1 + .../test/bundle-cosmjs-math.test.js | 18 ++++++++++++++++++ 5 files changed, 40 insertions(+) create mode 100644 packages/agoric-cli/test/bundle-cosmjs-math.js create mode 100644 packages/agoric-cli/test/bundle-cosmjs-math.test.js create mode 100644 packages/cosmic-proto/test/bundle-cosmjs-math.js create mode 100644 packages/cosmic-proto/test/bundle-cosmjs-math.test.js diff --git a/packages/agoric-cli/test/bundle-cosmjs-math.js b/packages/agoric-cli/test/bundle-cosmjs-math.js new file mode 100644 index 000000000000..7b09232d149c --- /dev/null +++ b/packages/agoric-cli/test/bundle-cosmjs-math.js @@ -0,0 +1 @@ +export { Decimal } from '@cosmjs/math'; diff --git a/packages/agoric-cli/test/bundle-cosmjs-math.test.js b/packages/agoric-cli/test/bundle-cosmjs-math.test.js new file mode 100644 index 000000000000..557b2894c85c --- /dev/null +++ b/packages/agoric-cli/test/bundle-cosmjs-math.test.js @@ -0,0 +1,18 @@ +// A test to verify that importing @cosmsjs/math into an ESM via bundleSource +// can see the exported Decimal constructor, which was at time of writing obscured +// by https://github.com/endojs/endo/pull/2330, temporarily mitigated by a patch. +// Placed here only because Agoric CLI depends on both bundleSource and CosmJS math. + +import test from '@endo/ses-ava/prepare-endo.js'; +import url from 'url'; +import bundleSource from '@endo/bundle-source'; +import { importBundle } from '@endo/import-bundle'; + +test('bundled @comjs/math exports Decimal', async t => { + const entryPath = url.fileURLToPath( + new URL('bundle-cosmjs-math.js', import.meta.url), + ); + const bundle = await bundleSource(entryPath); + const ns = await importBundle(bundle); + t.not(ns.Decimal === undefined); +}); diff --git a/packages/cosmic-proto/package.json b/packages/cosmic-proto/package.json index 62f85cd9b4cc..c38417f528c5 100644 --- a/packages/cosmic-proto/package.json +++ b/packages/cosmic-proto/package.json @@ -133,6 +133,8 @@ "@agoric/cosmos": "^0.34.1", "@ava/typescript": "^4.1.0", "@cosmology/telescope": "^1.7.1", + "@endo/bundle-source": "^3.2.3", + "@endo/import-bundle": "^1.1.2", "ava": "^5.3.1", "rimraf": "^5.0.0", "tsd": "^0.30.7", diff --git a/packages/cosmic-proto/test/bundle-cosmjs-math.js b/packages/cosmic-proto/test/bundle-cosmjs-math.js new file mode 100644 index 000000000000..7b09232d149c --- /dev/null +++ b/packages/cosmic-proto/test/bundle-cosmjs-math.js @@ -0,0 +1 @@ +export { Decimal } from '@cosmjs/math'; diff --git a/packages/cosmic-proto/test/bundle-cosmjs-math.test.js b/packages/cosmic-proto/test/bundle-cosmjs-math.test.js new file mode 100644 index 000000000000..c8a8d386ab5c --- /dev/null +++ b/packages/cosmic-proto/test/bundle-cosmjs-math.test.js @@ -0,0 +1,18 @@ +// A test to verify that importing @cosmsjs/math into an ESM via bundleSource +// can see the exported Decimal constructor, which was at time of writing obscured +// by https://github.com/endojs/endo/pull/2330, temporarily mitigated by a patch. +// Placed here only because Agoric CLI depends on both bundleSource and CosmJS math. + +import test from '@endo/ses-ava/prepare-endo.js'; +import url from 'url'; +import bundleSource from '@endo/bundle-source'; +import { importBundle } from '@endo/import-bundle'; + +test('bundled @comjs/math exports Decimal', async t => { + const entryPath = url.fileURLToPath( + new URL('bundle-cosmjs-math.js', import.meta.url), + ); + const bundle = await bundleSource(entryPath); + const ns = await importBundle(bundle); + t.not(ns.Decimal, undefined); +});