Skip to content

Commit

Permalink
chore: settler: don't forward without evidence
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc committed Nov 27, 2024
1 parent 49bd809 commit dcc6feb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
10 changes: 6 additions & 4 deletions packages/fast-usdc/src/exos/settler.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,13 @@ export const prepareSettler = (
this.state.mintedEarly.add(makeMintedEarlyKey(sender, amount));
return;

case undefined:
case PendingTxStatus.Observed:
case PendingTxStatus.AdvanceFailed:
return self.forward(found.txHash, sender, amount, EUD);

case undefined:
default:
return self.forward(found?.txHash, sender, amount, EUD);
log('⚠️ tap: no status for ', sender, amount);
}
},
},
Expand Down Expand Up @@ -247,7 +249,7 @@ export const prepareSettler = (
statusManager.disbursed(txHash);
},
/**
* @param {EvmHash | undefined} txHash
* @param {EvmHash} txHash
* @param {NobleAddress} sender
* @param {NatValue} fullValue
* @param {string} EUD
Expand Down Expand Up @@ -275,7 +277,7 @@ export const prepareSettler = (
* @param {SettlerTransferCtx} ctx
*
* @typedef {{
* txHash: EvmHash | undefined;
* txHash: EvmHash;
* sender: NobleAddress;
* fullValue: NatValue;
* }} SettlerTransferCtx
Expand Down
23 changes: 10 additions & 13 deletions packages/fast-usdc/test/exos/settler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ const makeTestContext = async t => {
feeConfig: common.commonPrivateArgs.feeConfig,
vowTools: common.bootstrap.vowTools,
chainHub,
log,
});

const defaultSettlerParams = harden({
Expand Down Expand Up @@ -307,7 +308,6 @@ test('Settlement for unknown transaction', async t => {
peekCalls,
inspectLogs,
} = t.context;
const { usdc } = common.brands;

const settler = makeSettler({
repayer,
Expand All @@ -319,22 +319,19 @@ test('Settlement for unknown transaction', async t => {
void settler.tap.receiveUpcall(MockVTransferEvents.AGORIC_PLUS_OSMO());
await eventLoopIteration();

t.log('USDC was forwarded');
t.log('Nothing was transferrred');
t.deepEqual(peekCalls(), []);
t.deepEqual(accounts.settlement.callLog, [
t.deepEqual(accounts.settlement.callLog, []);
t.like(inspectLogs(), [
['config', { sourceChannel: 'channel-21' }],
['upcall event'],
['dequeued', undefined],
[
'transfer',
{
chainId: 'osmosis-1',
encoding: 'bech32',
value: 'osmo183dejcnmkka5dzcu9xw6mywq0p2m5peks28men',
},
usdc.units(150),
'⚠️ tap: no status for ',
'noble1x0ydg69dh6fqvr27xjvp6maqmrldam6yfelqkd',
150000000n,
],
]);
t.deepEqual(inspectLogs(0), [
'⚠️ Forwarded minted amount 150000000 from account noble1x0ydg69dh6fqvr27xjvp6maqmrldam6yfelqkd before it was observed.',
]);
});

test.todo("StatusManager does not receive update when we can't settle");

0 comments on commit dcc6feb

Please sign in to comment.