assertNone() not ignoring the txn errors
stegaBOB opened this issue · 0 comments
stegaBOB commented
When using the built-in sendAndConfirmTransaction, assertNone doesn't seem to register and still returns the errors.
Example code:
await handler
.sendAndConfirmTransaction(with_system_txn, [], { skipPreflight: true }, 'noSystemProgram')
.assertNone();
Expected output:
nothing I dont think lel
Actual output:
## Problem
When skipping preflight you need to call ‘assertSuccess’ or ‘assertError’
directly on the Promise that is returned by the amman TransactionHandler.
Otherwise transaction errors go unhandled.
NOTE: that when no ‘skipPreflight’ option is provided then it defaults to ‘true’.
## Examples:
await txHandler.sendAndConfirmTransaction(
tx,
signers,
).assertSuccess(t)
await txHandler.sendAndConfirmTransaction(
tx,
signers,
{ skipPreflight: true, commitment: ‘confirmed’ },
)
.assertError(t, StakeDoesNotMatchError)
.then((res: ConfirmedTransactionDetails) => console.log(res.txSignature))
## Workaround
Alternatively you can ignore this error by calling ‘assertNone’ on the returned Promise.
await txHandler.sendAndConfirmTransaction(
tx,
signers,
).assertNone()
## Origin
at PayerTransactionHandler.sendAndConfirmTransaction (/Users/sammyharris/metaplex-studios/sammy/cpi-test/node_modules/@metaplex-foundation/amman-client/src/transactions/transaction-handler.ts:61:12)
at main (/Users/sammyharris/metaplex-studios/sammy/cpi-test/packages/test/src/test.ts:32:17)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Immediate.<anonymous> (/Users/sammyharris/metaplex-studios/sammy/cpi-test/node_modules/@metaplex-foundation/amman-client/src/transactions/confirmed-transaction-assertable-promise.ts:75:17)
at processImmediate (node:internal/timers:466:21)