From 26ba326d2b43d4678038bfb4c2ba1701948701bf Mon Sep 17 00:00:00 2001 From: Callum Date: Mon, 25 Mar 2024 15:12:51 +0000 Subject: [PATCH] add missing compiledMessage field to tests --- .../signers/src/__tests__/fee-payer-signer-test.ts | 9 ++++++++- .../signers/src/__tests__/keypair-signer-test.ts | 4 +++- packages/signers/src/sign-transaction.ts | 6 ++++++ .../src/__tests__/waiters-test.ts | 4 +++- .../transactions/src/__tests__/blockhash-test.ts | 2 ++ .../transactions/src/__tests__/durable-nonce-test.ts | 2 ++ .../transactions/src/__tests__/fee-payer-test.ts | 2 ++ .../transactions/src/__tests__/instructions-test.ts | 5 +++++ .../transactions/src/__tests__/signatures-test.ts | 12 ++++++++++++ 9 files changed, 43 insertions(+), 3 deletions(-) diff --git a/packages/signers/src/__tests__/fee-payer-signer-test.ts b/packages/signers/src/__tests__/fee-payer-signer-test.ts index 7356015c8094..18fe8289ab89 100644 --- a/packages/signers/src/__tests__/fee-payer-signer-test.ts +++ b/packages/signers/src/__tests__/fee-payer-signer-test.ts @@ -1,7 +1,12 @@ import '@solana/test-matchers/toBeFrozenObject'; import { Address } from '@solana/addresses'; -import { BaseTransaction, ITransactionWithFeePayer, ITransactionWithSignatures } from '@solana/transactions'; +import { + BaseTransaction, + CompiledMessage, + ITransactionWithFeePayer, + ITransactionWithSignatures, +} from '@solana/transactions'; import { ITransactionWithFeePayerSigner, setTransactionFeePayerSigner } from '../fee-payer-signer'; import { TransactionSigner } from '../transaction-signer'; @@ -45,6 +50,7 @@ describe('setTransactionFeePayerSigner', () => { txWithFeePayerAndSignatures = { ...txWithFeePayerA, signatures: {}, + compiledMessage: {} as unknown as CompiledMessage, }; }); it('does not clear the signatures when the fee payer is the same as the current one', () => { @@ -85,6 +91,7 @@ describe('setTransactionFeePayerSigner', () => { txWithFeePayerAndSignatures = { ...txWithFeePayerA, signatures: {}, + compiledMessage: {} as unknown as CompiledMessage, }; }); it('does not clear the signatures when the fee payer is the same as the current one', () => { diff --git a/packages/signers/src/__tests__/keypair-signer-test.ts b/packages/signers/src/__tests__/keypair-signer-test.ts index 8bd196f3f0c1..c935b8df3c13 100644 --- a/packages/signers/src/__tests__/keypair-signer-test.ts +++ b/packages/signers/src/__tests__/keypair-signer-test.ts @@ -3,7 +3,7 @@ import '@solana/test-matchers/toBeFrozenObject'; import { address, getAddressFromPublicKey } from '@solana/addresses'; import { SOLANA_ERROR__SIGNER__EXPECTED_KEY_PAIR_SIGNER, SolanaError } from '@solana/errors'; import { generateKeyPair, SignatureBytes, signBytes } from '@solana/keys'; -import { CompilableTransaction, partiallySignTransaction } from '@solana/transactions'; +import { CompilableTransaction, CompiledMessage, partiallySignTransaction } from '@solana/transactions'; import { assertIsKeyPairSigner, @@ -151,10 +151,12 @@ describe('createSignerFromKeyPair', () => { jest.mocked(partiallySignTransaction).mockResolvedValueOnce({ ...mockTransactions[0], signatures: { [myAddress]: mockSignatures[0] }, + compiledMessage: {} as unknown as CompiledMessage, }); jest.mocked(partiallySignTransaction).mockResolvedValueOnce({ ...mockTransactions[1], signatures: { [myAddress]: mockSignatures[1] }, + compiledMessage: {} as unknown as CompiledMessage, }); // When we sign both transactions using that signer. diff --git a/packages/signers/src/sign-transaction.ts b/packages/signers/src/sign-transaction.ts index 52271a975498..9b9e4d306519 100644 --- a/packages/signers/src/sign-transaction.ts +++ b/packages/signers/src/sign-transaction.ts @@ -3,6 +3,7 @@ import { SignatureBytes } from '@solana/keys'; import { assertTransactionIsFullySigned, CompilableTransaction, + compileMessage, IFullySignedTransaction, ITransactionWithSignatures, } from '@solana/transactions'; @@ -192,6 +193,10 @@ async function signModifyingAndPartialTransactionSigners< return signatures; }), ); + let compiledMessage = modifiedTransaction.compiledMessage; + if (!compiledMessage) { + compiledMessage = compileMessage(modifiedTransaction); + } const signedTransaction: ITransactionWithSignatures & TTransaction = { ...modifiedTransaction, signatures: Object.freeze( @@ -199,6 +204,7 @@ async function signModifyingAndPartialTransactionSigners< return { ...signatures, ...signatureDictionary }; }, modifiedTransaction.signatures ?? {}), ), + compiledMessage, }; return Object.freeze(signedTransaction); diff --git a/packages/transaction-confirmation/src/__tests__/waiters-test.ts b/packages/transaction-confirmation/src/__tests__/waiters-test.ts index 33a6f5007057..70994af15e5d 100644 --- a/packages/transaction-confirmation/src/__tests__/waiters-test.ts +++ b/packages/transaction-confirmation/src/__tests__/waiters-test.ts @@ -3,7 +3,7 @@ import { SOLANA_ERROR__TRANSACTION__FEE_PAYER_SIGNATURE_MISSING, SolanaError } f import { AccountRole, ReadonlySignerAccount, WritableAccount } from '@solana/instructions'; import { Signature, SignatureBytes } from '@solana/keys'; import type { Blockhash } from '@solana/rpc-types'; -import { IDurableNonceTransaction, Nonce } from '@solana/transactions'; +import { CompiledMessage, IDurableNonceTransaction, Nonce } from '@solana/transactions'; import { waitForDurableNonceTransactionConfirmation, @@ -41,6 +41,7 @@ describe('waitForDurableNonceTransactionConfirmation', () => { signatures: { ['9'.repeat(44) as Address]: new Uint8Array(new Array(64).fill(0)) as SignatureBytes, } as const, + compiledMessage: {} as unknown as CompiledMessage, } as const; let getNonceInvalidationPromise: jest.Mock>; let getRecentSignatureConfirmationPromise: jest.Mock>; @@ -194,6 +195,7 @@ describe('waitForRecentTransactionConfirmation', () => { signatures: { ['9'.repeat(44) as Address]: new Uint8Array(new Array(64).fill(0)) as SignatureBytes, } as const, + compiledMessage: {} as unknown as CompiledMessage, } as const; let getBlockHeightExceedencePromise: jest.Mock>; let getRecentSignatureConfirmationPromise: jest.Mock>; diff --git a/packages/transactions/src/__tests__/blockhash-test.ts b/packages/transactions/src/__tests__/blockhash-test.ts index 107ba5f22d13..00830b2a1d8c 100644 --- a/packages/transactions/src/__tests__/blockhash-test.ts +++ b/packages/transactions/src/__tests__/blockhash-test.ts @@ -10,6 +10,7 @@ import { } from '../blockhash'; import { ITransactionWithSignatures } from '../signatures'; import { BaseTransaction } from '../types'; +import { CompiledMessage } from '../message'; jest.mock('@solana/codecs-strings', () => ({ ...jest.requireActual('@solana/codecs-strings'), @@ -135,6 +136,7 @@ describe('setTransactionLifetimeUsingBlockhash', () => { txWithBlockhashLifetimeConstraintAndSignatures = { ...txWithBlockhashLifetimeConstraint, signatures: {}, + compiledMessage: {} as unknown as CompiledMessage, }; }); it('does not clear the signatures when the blockhash lifetime constraint is the same as the current one', () => { diff --git a/packages/transactions/src/__tests__/durable-nonce-test.ts b/packages/transactions/src/__tests__/durable-nonce-test.ts index 2cb392b1cb1d..003c37405ab5 100644 --- a/packages/transactions/src/__tests__/durable-nonce-test.ts +++ b/packages/transactions/src/__tests__/durable-nonce-test.ts @@ -13,6 +13,7 @@ import { } from '../durable-nonce'; import { ITransactionWithSignatures } from '../signatures'; import { BaseTransaction } from '../types'; +import { CompiledMessage } from '../message'; function createMockAdvanceNonceAccountInstruction< TNonceAccountAddress extends string = string, @@ -257,6 +258,7 @@ describe('setTransactionLifetimeUsingDurableNonce', () => { durableNonceTxWithConstraintAAndSignatures = { ...durableNonceTxWithConstraintA, signatures: {}, + compiledMessage: {} as unknown as CompiledMessage, }; }); it('does not clear the signatures when the durable nonce constraint is the same as the current one', () => { diff --git a/packages/transactions/src/__tests__/fee-payer-test.ts b/packages/transactions/src/__tests__/fee-payer-test.ts index be6dc1a1fafc..451b56d440ab 100644 --- a/packages/transactions/src/__tests__/fee-payer-test.ts +++ b/packages/transactions/src/__tests__/fee-payer-test.ts @@ -5,6 +5,7 @@ import { Address } from '@solana/addresses'; import { ITransactionWithFeePayer, setTransactionFeePayer } from '../fee-payer'; import { ITransactionWithSignatures } from '../signatures'; import { BaseTransaction } from '../types'; +import { CompiledMessage } from '../message'; const EXAMPLE_FEE_PAYER_A = '7mvYAxeCui21xYkAyQSjh6iBVZPpgVyt7PYv9km8V5mE' as Address<'7mvYAxeCui21xYkAyQSjh6iBVZPpgVyt7PYv9km8V5mE'>; @@ -45,6 +46,7 @@ describe('setTransactionFeePayer', () => { txWithFeePayerAndSignatures = { ...txWithFeePayerA, signatures: {}, + compiledMessage: {} as unknown as CompiledMessage, }; }); it('does not clear the signatures when the fee payer is the same as the current one', () => { diff --git a/packages/transactions/src/__tests__/instructions-test.ts b/packages/transactions/src/__tests__/instructions-test.ts index 4423748a3e62..9382e72e4440 100644 --- a/packages/transactions/src/__tests__/instructions-test.ts +++ b/packages/transactions/src/__tests__/instructions-test.ts @@ -11,6 +11,7 @@ import { } from '../instructions'; import { ITransactionWithSignatures } from '../signatures'; import { BaseTransaction } from '../types'; +import { CompiledMessage } from '../message'; const PROGRAM_A = 'AALQD2dt1k43Acrkp4SvdhZaN4S115Ff2Bi7rHPti3sL' as Address<'AALQD2dt1k43Acrkp4SvdhZaN4S115Ff2Bi7rHPti3sL'>; @@ -50,6 +51,7 @@ describe('Transaction instruction helpers', () => { txWithSignatures = { ...baseTx, signatures: {}, + compiledMessage: {} as unknown as CompiledMessage, }; }); it('clears the transaction signatures', () => { @@ -81,6 +83,7 @@ describe('Transaction instruction helpers', () => { txWithSignatures = { ...baseTx, signatures: {}, + compiledMessage: {} as unknown as CompiledMessage, }; }); it('clears the transaction signatures', () => { @@ -108,6 +111,7 @@ describe('Transaction instruction helpers', () => { txWithSignatures = { ...baseTx, signatures: {}, + compiledMessage: {} as unknown as CompiledMessage, }; }); it('clears the transaction signatures', () => { @@ -139,6 +143,7 @@ describe('Transaction instruction helpers', () => { txWithSignatures = { ...baseTx, signatures: {}, + compiledMessage: {} as unknown as CompiledMessage, }; }); it('clears the transaction signatures', () => { diff --git a/packages/transactions/src/__tests__/signatures-test.ts b/packages/transactions/src/__tests__/signatures-test.ts index b056356337b5..d11681a7db36 100644 --- a/packages/transactions/src/__tests__/signatures-test.ts +++ b/packages/transactions/src/__tests__/signatures-test.ts @@ -37,6 +37,7 @@ describe('getSignatureFromTransaction', () => { signatures: { ['123' as Address]: new Uint8Array(new Array(64).fill(9)) as SignatureBytes, } as const, + compiledMessage: {} as unknown as CompiledMessage, }; expect(getSignatureFromTransaction(transactionWithoutFeePayerSignature)).toBe( 'BUguQsv2ZuHus54HAFzjdJHzZBkygAjKhEeYwSG19tUfUyvvz3worsdQCdAXDNjakJHioSiyxhFiDJrm8XpSXRA', @@ -49,6 +50,7 @@ describe('getSignatureFromTransaction', () => { // No signature by the fee payer. ['456' as Address]: new Uint8Array(new Array(64).fill(9)) as SignatureBytes, } as const, + compiledMessage: {} as unknown as CompiledMessage, }; expect(() => { getSignatureFromTransaction(transactionWithoutFeePayerSignature); @@ -401,6 +403,7 @@ describe('assertTransactionIsFullySigned', () => { instructions: [], lifetimeConstraint: mockBlockhashConstraint, signatures: {}, + compiledMessage: {} as unknown as CompiledMessage, version: 0, }; @@ -422,6 +425,7 @@ describe('assertTransactionIsFullySigned', () => { ], lifetimeConstraint: mockBlockhashConstraint, signatures: {}, + compiledMessage: {} as unknown as CompiledMessage, version: 0, }; @@ -450,6 +454,7 @@ describe('assertTransactionIsFullySigned', () => { signatures: { [mockPublicKeyAddressA]: mockSignatureA, }, + compiledMessage: {} as unknown as CompiledMessage, version: 0, }; @@ -478,6 +483,7 @@ describe('assertTransactionIsFullySigned', () => { signatures: { [mockPublicKeyAddressA]: mockSignatureA, }, + compiledMessage: {} as unknown as CompiledMessage, version: 0, }; @@ -516,6 +522,7 @@ describe('assertTransactionIsFullySigned', () => { [mockPublicKeyAddressA]: mockSignatureA, [mockPublicKeyAddressB]: mockSignatureB, }, + compiledMessage: {} as unknown as CompiledMessage, version: 0, }; @@ -534,6 +541,7 @@ describe('assertTransactionIsFullySigned', () => { signatures: { [mockPublicKeyAddressA]: mockSignatureA, }, + compiledMessage: {} as unknown as CompiledMessage, version: 0, }; @@ -559,6 +567,7 @@ describe('assertTransactionIsFullySigned', () => { [mockPublicKeyAddressA]: mockSignatureA, [mockPublicKeyAddressB]: mockSignatureB, }, + compiledMessage: {} as unknown as CompiledMessage, version: 0, }; @@ -594,6 +603,7 @@ describe('assertTransactionIsFullySigned', () => { [mockPublicKeyAddressB]: mockSignatureB, [mockPublicKeyAddressC]: mockSignatureC, }, + compiledMessage: {} as unknown as CompiledMessage, version: 0, }; @@ -618,6 +628,7 @@ describe('assertTransactionIsFullySigned', () => { signatures: { [mockPublicKeyAddressA]: mockSignatureA, }, + compiledMessage: {} as unknown as CompiledMessage, version: 0, }; @@ -636,6 +647,7 @@ describe('assertTransactionIsFullySigned', () => { signatures: { [mockPublicKeyAddressA]: mockSignatureA, }, + compiledMessage: {} as unknown as CompiledMessage, version: 0, };