Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fast-usdc): skipAdvance when preconditions fail #11005

Merged
merged 1 commit into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, [error.message]);
}
},
/** @param {ChainAddress} intermediateRecipient */
Expand Down
38 changes: 29 additions & 9 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,16 @@ 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: [
'Cannot borrow. Requested {"brand":"[Alleged: USDC brand]","value":"[293999999n]"} must be less than pool balance {"brand":"[Alleged: USDC brand]","value":"[1n]"}.',
],
status: 'ADVANCE_SKIPPED',
},
],
'ADVANCE_SKIPPED status on insufficient pool funds',
);

t.deepEqual(inspectLogs(), [
Expand All @@ -325,7 +333,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 +348,14 @@ 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: ['Chain info not found for bech32Prefix "random"'],
status: 'ADVANCE_SKIPPED',
},
],
'ADVANCE_SKIPPED status on makeChainAddress failure',
);

t.deepEqual(inspectLogs(), [
Expand Down Expand Up @@ -531,7 +545,7 @@ test('logs error if returnToPool fails during AdvanceFailed recovery', async t =
]);
});

test('updates status to OBSERVED if pre-condition checks fail', async t => {
test('updates status to ADVANCE_SKIPPED if pre-condition checks fail', async t => {
const {
bootstrap: { storage },
extensions: {
Expand All @@ -547,8 +561,14 @@ 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: ['query: {} - Must have missing properties ["EUD"]'],
status: 'ADVANCE_SKIPPED',
},
],
'tx is recorded as ADVANCE_SKIPPED',
);

t.deepEqual(inspectLogs(), [
Expand Down
Loading