diff --git a/packages/orchestration/src/examples/staking-combinations.flows.js b/packages/orchestration/src/examples/staking-combinations.flows.js index 2961ee96dac..c7ab71afc32 100644 --- a/packages/orchestration/src/examples/staking-combinations.flows.js +++ b/packages/orchestration/src/examples/staking-combinations.flows.js @@ -76,9 +76,8 @@ export const depositAndDelegate = async ( try { await contractState.localAccount.transfer(give.Stake, address); } catch (cause) { - // TODO, put funds back on user seat and exit - // https://github.com/Agoric/agoric-sdk/issues/9925 - throw makeError('ibc transfer failed', undefined, { cause }); + await zoeTools.withdrawToSeat(contractState.localAccount, seat, give); + throw seat.fail(makeError('ibc transfer failed', undefined, { cause })); } seat.exit(); await account.delegate(validator, give.Stake); diff --git a/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.md b/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.md index 8fa76401b61..5b0b7e27271 100644 --- a/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.md +++ b/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.md @@ -51,6 +51,8 @@ Generated by [AVA](https://avajs.dev). zoeTools: { localTransfer_kindHandle: 'Alleged: kind', localTransfer_singleton: 'Alleged: localTransfer', + withdrawToSeat_kindHandle: 'Alleged: kind', + withdrawToSeat_singleton: 'Alleged: withdrawToSeat', }, }, }, @@ -76,6 +78,8 @@ Generated by [AVA](https://avajs.dev). zoeTools: { localTransfer_kindHandle: 'Alleged: kind', localTransfer_singleton: 'Alleged: localTransfer', + withdrawToSeat_kindHandle: 'Alleged: kind', + withdrawToSeat_singleton: 'Alleged: withdrawToSeat', }, }, }, @@ -101,6 +105,8 @@ Generated by [AVA](https://avajs.dev). zoeTools: { localTransfer_kindHandle: 'Alleged: kind', localTransfer_singleton: 'Alleged: localTransfer', + withdrawToSeat_kindHandle: 'Alleged: kind', + withdrawToSeat_singleton: 'Alleged: withdrawToSeat', }, }, }, diff --git a/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.snap b/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.snap index 0419690848f..baa5d7049ab 100644 Binary files a/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.snap and b/packages/orchestration/test/examples/snapshots/staking-combinations.test.ts.snap differ diff --git a/packages/orchestration/test/examples/staking-combinations.test.ts b/packages/orchestration/test/examples/staking-combinations.test.ts index a7540dd8a0c..7a9c61ac010 100644 --- a/packages/orchestration/test/examples/staking-combinations.test.ts +++ b/packages/orchestration/test/examples/staking-combinations.test.ts @@ -12,6 +12,7 @@ import { MsgTransferResponse, } from '@agoric/cosmic-proto/ibc/applications/transfer/v1/tx.js'; import { IBCMethod } from '@agoric/vats'; +import { SIMULATED_ERRORS } from '@agoric/vats/tools/fake-bridge.js'; import { protoMsgMocks, UNBOND_PERIOD_SECONDS } from '../ibc-mocks.js'; import { commonSetup } from '../supports.js'; import { @@ -205,4 +206,37 @@ test('start', async t => { // snapshot the resulting contract baggage const tree = inspectMapStore(contractBaggage); t.snapshot(tree, 'contract baggage after start'); + + { + t.log('payments from failed transfers are returned'); + const bldAmt = bld.make(SIMULATED_ERRORS.TIMEOUT); + + const seat = await E(zoe).offer( + await E(result.invitationMakers).DepositAndDelegate(), + { + give: { Stake: bldAmt }, + exit: { waived: null }, + }, + { + Stake: await pourPayment(bldAmt), + }, + { + validator: { + chainId: 'cosmoshub', + value: 'cosmosvaloper1test', + encoding: 'bech32', + }, + }, + ); + await t.throwsAsync(vt.when(E(seat).getOfferResult()), { + message: 'ibc transfer failed', + }); + await vt.when(E(seat).hasExited()); + const payouts = await E(seat).getPayouts(); + t.deepEqual( + await bld.issuer.getAmountOf(payouts.Stake), + bldAmt, + 'Stake is returned', + ); + } });