Skip to content
Closed
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
9 changes: 7 additions & 2 deletions packages/chain/test/evm-adapter-pca-enrich.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ describe('PCA write methods enrich opaque custom-error reverts on rethrow (codex
});

it('non-Error / non-custom-error throws propagate unchanged (helper must not swallow or rewrite)', async () => {
// (a) plain Error with no revert data — message stays byte-identical.
// (a) plain Error with no revert data — the PCA-enrichment helper
// must not rewrite or swallow the inner classification. The
// transport (`sendContractTransaction`) is allowed to prefix
// operator context (RPC endpoint exhaustion) and attach the
// original via `.cause`, so we assert the original message is
// preserved as a substring rather than byte-identical.
const plain = adapterWithFakeNft({
settle: async () => {
throw new Error('connect ECONNREFUSED 127.0.0.1:8545');
Expand All @@ -132,7 +137,7 @@ describe('PCA write methods enrich opaque custom-error reverts on rethrow (codex
.then(() => null)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Issue: Relaxing this to toContain(...) weakens the regression quite a bit: the test now passes even if the original transport error is mostly rewritten, as long as that substring survives somewhere in the wrapper message. If the intended contract is "wrapped with operator context and preserved via .cause", assert that explicitly (for example, check e1.cause is the original Error with this exact message) so the test still guards the propagation behavior instead of only substring retention.

.catch((e) => e as Error);
expect(e1).toBeInstanceOf(Error);
expect(e1!.message).toBe('connect ECONNREFUSED 127.0.0.1:8545');
expect(e1!.message).toContain('connect ECONNREFUSED 127.0.0.1:8545');

// (b) non-Error throw (string) — propagated as-is, not wrapped.
const nonError = adapterWithFakeNft({
Expand Down
Loading