Skip to content

Commit

Permalink
feat(fast-usdc): skipAdvance when preconditions fail
Browse files Browse the repository at this point in the history
  • Loading branch information
samsiegart committed Feb 13, 2025
1 parent 729fe8e commit 430a488
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
4 changes: 2 additions & 2 deletions multichain-testing/test/fast-usdc/fast-usdc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ test.serial('insufficient LP funds; forward path', async t => {
await useChain(eudChain).getRestEndpoint(),
);

await assertTxStatus(evidence.txHash, 'OBSERVED');
await assertTxStatus(evidence.txHash, 'ADVANCE_SKIPPED');

nobleTools.mockCctpMint(mintAmt, userForwardingAddr);

Expand Down Expand Up @@ -788,7 +788,7 @@ test.serial('insufficient LP funds and forward failed', async t => {
// submit evidences
await Promise.all(txOracles.map(async o => o.submit(evidence)));

await assertTxStatus(evidence.txHash, 'OBSERVED');
await assertTxStatus(evidence.txHash, 'ADVANCE_SKIPPED');

nobleTools.mockCctpMint(mintAmt, userForwardingAddr);

Expand Down
2 changes: 1 addition & 1 deletion packages/fast-usdc/src/exos/advancer.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export const prepareAdvancerKit = (
});
} catch (error) {
log('Advancer error:', error);
statusManager.observe(evidence);
statusManager.skipAdvance(evidence, ['PRECONDITIONS_FAILED']);
}
},
/** @param {ChainAddress} intermediateRecipient */
Expand Down
25 changes: 17 additions & 8 deletions packages/fast-usdc/test/exos/advancer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ test('updates status to ADVANCING in happy path', async t => {
]);
});

test('updates status to OBSERVED on insufficient pool funds', async t => {
test('updates status to ADVANCE_SKIPPED on insufficient pool funds', async t => {
const {
brands: { usdc },
bootstrap: { storage },
Expand Down Expand Up @@ -310,8 +310,11 @@ test('updates status to OBSERVED on insufficient pool funds', async t => {

t.deepEqual(
storage.getDeserialized(`fun.txns.${evidence.txHash}`),
[{ evidence, status: PendingTxStatus.Observed }],
'OBSERVED status on insufficient pool funds',
[
{ evidence, status: PendingTxStatus.Observed },
{ risksIdentified: ['PRECONDITIONS_FAILED'], status: 'ADVANCE_SKIPPED' },
],
'ADVANCE_SKIPPED status on insufficient pool funds',
);

t.deepEqual(inspectLogs(), [
Expand All @@ -325,7 +328,7 @@ test('updates status to OBSERVED on insufficient pool funds', async t => {
]);
});

test('updates status to OBSERVED if makeChainAddress fails', async t => {
test('updates status to ADVANCE_SKIPPED if makeChainAddress fails', async t => {
const {
bootstrap: { storage },
extensions: {
Expand All @@ -340,8 +343,11 @@ test('updates status to OBSERVED if makeChainAddress fails', async t => {

t.deepEqual(
storage.getDeserialized(`fun.txns.${evidence.txHash}`),
[{ evidence, status: PendingTxStatus.Observed }],
'OBSERVED status on makeChainAddress failure',
[
{ evidence, status: PendingTxStatus.Observed },
{ risksIdentified: ['PRECONDITIONS_FAILED'], status: 'ADVANCE_SKIPPED' },
],
'ADVANCE_SKIPPED status on makeChainAddress failure',
);

t.deepEqual(inspectLogs(), [
Expand Down Expand Up @@ -547,8 +553,11 @@ test('updates status to OBSERVED if pre-condition checks fail', async t => {

t.deepEqual(
storage.getDeserialized(`fun.txns.${evidence.txHash}`),
[{ evidence, status: PendingTxStatus.Observed }],
'tx is recorded as OBSERVED',
[
{ evidence, status: PendingTxStatus.Observed },
{ risksIdentified: ['PRECONDITIONS_FAILED'], status: 'ADVANCE_SKIPPED' },
],
'tx is recorded as ADVANCE_SKIPPED',
);

t.deepEqual(inspectLogs(), [
Expand Down

0 comments on commit 430a488

Please sign in to comment.