fix: Update signature status result type
This commit is contained in:
parent
f2b38bcc56
commit
7f72bbeba3
|
@ -124,13 +124,13 @@ const ConfirmTransactionRpcResult = jsonRpcResult('boolean');
|
|||
* Expected JSON RPC response for the "getSignatureStatus" message
|
||||
*/
|
||||
const GetSignatureStatusRpcResult = jsonRpcResult(
|
||||
struct.enum([
|
||||
'AccountInUse',
|
||||
'Confirmed',
|
||||
'GenericFailure',
|
||||
'ProgramRuntimeError',
|
||||
'SignatureNotFound',
|
||||
]),
|
||||
struct.union([
|
||||
'null',
|
||||
struct.union([
|
||||
struct({Ok: 'null'}),
|
||||
struct({Err: 'string'})
|
||||
])
|
||||
])
|
||||
);
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,7 @@ export async function sendAndConfirmTransaction(
|
|||
let statusRetries = 6;
|
||||
for (;;) {
|
||||
status = await connection.getSignatureStatus(signature);
|
||||
if (status !== 'SignatureNotFound') {
|
||||
if (status) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ export async function sendAndConfirmTransaction(
|
|||
await sleep((500 * DEFAULT_TICKS_PER_SLOT) / NUM_TICKS_PER_SECOND);
|
||||
}
|
||||
|
||||
if (status === 'Confirmed') {
|
||||
if ('Ok' in status) {
|
||||
break;
|
||||
}
|
||||
if (--sendRetries <= 0) {
|
||||
|
@ -51,7 +51,7 @@ export async function sendAndConfirmTransaction(
|
|||
);
|
||||
}
|
||||
|
||||
if (status !== 'AccountInUse' && status !== 'SignatureNotFound') {
|
||||
if ('Err' in status && !status.includes('AccountInUse')) {
|
||||
throw new Error(`Transaction ${signature} failed (${status})`);
|
||||
}
|
||||
|
||||
|
|
|
@ -341,8 +341,8 @@ test('transaction', async () => {
|
|||
result: 'Confirmed',
|
||||
},
|
||||
]);
|
||||
await expect(connection.getSignatureStatus(signature)).resolves.toBe(
|
||||
'Confirmed',
|
||||
await expect(connection.getSignatureStatus(signature)).resolves.toEqual(
|
||||
{'Ok': null},
|
||||
);
|
||||
|
||||
mockRpc.push([
|
||||
|
@ -410,8 +410,8 @@ test('multi-instruction transaction', async () => {
|
|||
expect(++i).toBeLessThan(10);
|
||||
await sleep(500);
|
||||
}
|
||||
await expect(connection.getSignatureStatus(signature)).resolves.toBe(
|
||||
'Confirmed',
|
||||
await expect(connection.getSignatureStatus(signature)).resolves.toEqual(
|
||||
{'Ok': null},
|
||||
);
|
||||
|
||||
expect(await connection.getBalance(accountFrom.publicKey)).toBe(12);
|
||||
|
@ -466,7 +466,7 @@ test('account change notification', async () => {
|
|||
|
||||
await connection.removeAccountChangeListener(subscriptionId);
|
||||
|
||||
expect(mockCallback.mock.calls[0][0].lamports).toBe(41);
|
||||
expect(mockCallback.mock.calls[0][0].lamports).toBe(42);
|
||||
expect(mockCallback.mock.calls[0][0].owner).toEqual(BpfLoader.programId);
|
||||
expect(mockCallback.mock.calls[0][0].executable).toBe(false);
|
||||
expect(mockCallback.mock.calls[0][0].data).toEqual(Buffer.from([1, 2, 3]));
|
||||
|
@ -523,7 +523,7 @@ test('program account change notification', async () => {
|
|||
expect(mockCallback.mock.calls[0][0].accountId).toEqual(
|
||||
programAccount.publicKey.toString(),
|
||||
);
|
||||
expect(mockCallback.mock.calls[0][0].accountInfo.lamports).toBe(41);
|
||||
expect(mockCallback.mock.calls[0][0].accountInfo.lamports).toBe(42);
|
||||
expect(mockCallback.mock.calls[0][0].accountInfo.owner).toEqual(
|
||||
BpfLoader.programId,
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue