From 6ef6062a4b69b0d44b18dc576021bbbaf372b3b2 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Fri, 17 Feb 2023 11:48:28 -0800 Subject: [PATCH 1/2] fix: multiple deposits of unknown brand --- .../test/smartWallet/test-psm-integration.js | 21 +++++-------------- packages/smart-wallet/src/smartWallet.js | 10 +++++---- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/packages/inter-protocol/test/smartWallet/test-psm-integration.js b/packages/inter-protocol/test/smartWallet/test-psm-integration.js index 5bcf83e9a97..b7558e3f9d8 100644 --- a/packages/inter-protocol/test/smartWallet/test-psm-integration.js +++ b/packages/inter-protocol/test/smartWallet/test-psm-integration.js @@ -307,26 +307,15 @@ test('govern offerFilter', async t => { // vote didn't raise an error. }); -test('deposit unknown brand', async t => { - const rial = withAmountUtils(makeIssuerKit('rial')); - assert(rial.mint); - - const wallet = await t.context.simpleProvideWallet('agoric1queue'); - - const payment = rial.mint.mintPayment(rial.make(1_000n)); - // @ts-expect-error deposit does take a FarRef - const result = await wallet.getDepositFacet().receive(harden(payment)); - // successful request but not deposited - t.deepEqual(result, { brand: rial.brand, value: 0n }); -}); - -test.failing('deposit > 1 payment to unknown brand #6961', async t => { +// XXX belongs in smart-wallet package, but needs lots of set-up that's handy here. +test('deposit multiple payments to unknown brand', async t => { const rial = withAmountUtils(makeIssuerKit('rial')); const wallet = await t.context.simpleProvideWallet('agoric1queue'); - for await (const _ of [1, 2]) { - const payment = rial.mint.mintPayment(rial.make(1_000n)); + // assume that if the call succeeds then it's in durable storage. + for await (const amt of [1n, 2n]) { + const payment = rial.mint.mintPayment(rial.make(amt)); // @ts-expect-error deposit does take a FarRef const result = await wallet.getDepositFacet().receive(harden(payment)); // successful request but not deposited diff --git a/packages/smart-wallet/src/smartWallet.js b/packages/smart-wallet/src/smartWallet.js index f9e20de8152..1ce1fadc1e9 100644 --- a/packages/smart-wallet/src/smartWallet.js +++ b/packages/smart-wallet/src/smartWallet.js @@ -354,7 +354,7 @@ export const prepareSmartWallet = (baggage, shared) => { /** * Put the assets from the payment into the appropriate purse. * - * If the purse doesn't exist, we hold the payment until it does. + * If the purse doesn't exist, we hold the payment in durable storage. * * @param {import('@endo/far').FarRef} payment * @returns {Promise} amounts for deferred deposits will be empty @@ -374,11 +374,13 @@ export const prepareSmartWallet = (baggage, shared) => { return E(invitationPurse).deposit(payment); } - // When there is no purse, queue the payment + // When there is no purse, save the payment into a queue. + // It's not yet ever read but a future version of the contract can if (queues.has(brand)) { - queues.get(brand).push(payment); + const extant = queues.get(brand); + queues.set(brand, harden([...extant, payment])); } else { - queues.init(brand, harden([payment])); // TODO: #6961 fix this. + queues.init(brand, harden([payment])); } return AmountMath.makeEmpty(brand); }, From 45bff8330e29906c31499a9fd411ddb028d08c58 Mon Sep 17 00:00:00 2001 From: Turadg Aleahmad Date: Thu, 16 Feb 2023 12:50:12 -0800 Subject: [PATCH 2/2] test(smoketest): realistic ATOM price --- packages/agoric-cli/test/agops-oracle-smoketest.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/agoric-cli/test/agops-oracle-smoketest.sh b/packages/agoric-cli/test/agops-oracle-smoketest.sh index d938a41c59a..bcd5e130d53 100755 --- a/packages/agoric-cli/test/agops-oracle-smoketest.sh +++ b/packages/agoric-cli/test/agops-oracle-smoketest.sh @@ -63,13 +63,14 @@ agd query vstorage keys published.priceFeed # verify that the round started agoric follow :published.priceFeed.ATOM-USD_price_feed.latestRound +# Set it to $13 per ATOM # second round, first oracle PROPOSAL_OFFER=$(mktemp -t agops.XXX) -bin/agops oracle pushPriceRound --price 1102 --roundId 2 --oracleAdminAcceptOfferId "$ORACLE_OFFER_ID" >|"$PROPOSAL_OFFER" +bin/agops oracle pushPriceRound --price 120000000 --roundId 2 --oracleAdminAcceptOfferId "$ORACLE_OFFER_ID" >|"$PROPOSAL_OFFER" agoric wallet send --offer "$PROPOSAL_OFFER" --from gov1 --keyring-backend="test" # second round, second oracle PROPOSAL_OFFER=$(mktemp -t agops.XXX) -bin/agops oracle pushPriceRound --price 1202 --roundId 2 --oracleAdminAcceptOfferId "$ORACLE2_OFFER_ID" >|"$PROPOSAL_OFFER" +bin/agops oracle pushPriceRound --price 14000000 --roundId 2 --oracleAdminAcceptOfferId "$ORACLE2_OFFER_ID" >|"$PROPOSAL_OFFER" agoric wallet send --offer "$PROPOSAL_OFFER" --from gov2 --keyring-backend="test" # see new price