Skip to content

Commit 44f6bf8

Browse files
onspeedhpclaude
andcommitted
fix(tests-sdk): include expiry_offset in deferred-execution signed payload
The Authorize instruction binds expiry_offset to the Secp256r1 signature hash via signed_payload = instructions_hash || accounts_hash || expiry_offset (u16 LE). Test code was building signed_payload without the expiryBuf, causing all 7 deferred tests to fail with InvalidMessageHash (3005). Add expiryBuf at all 6 sign sites; values match the corresponding createAuthorizeIx expiryOffset arg (4 × 300, 1 × 9000, 1 × 10). Verification: 65/65 vitest pass against live validator (was 58/65 before). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 810975e commit 44f6bf8

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

tests-sdk/tests/08-deferred.test.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,10 @@ describe('Deferred Execution', () => {
116116
];
117117
const accountsHash = computeAccountsHash(tx2AccountMetas, compactIxs);
118118

119-
// Build signed_payload = instructions_hash || accounts_hash
120-
const signedPayload = Buffer.concat([instructionsHash, accountsHash]);
119+
// Build signed_payload = instructions_hash || accounts_hash || expiry_offset (u16 LE)
120+
const expiryBuf = Buffer.alloc(2);
121+
expiryBuf.writeUInt16LE(300);
122+
const signedPayload = Buffer.concat([instructionsHash, accountsHash, expiryBuf]);
121123

122124
// Sign with Secp256r1
123125
const { authPayload, precompileIx } = await signSecp256r1({
@@ -240,7 +242,9 @@ describe('Deferred Execution', () => {
240242
{ pubkey: recipient3, isSigner: false, isWritable: true },
241243
];
242244
const accountsHash = computeAccountsHash(tx2AccountMetas, compactIxs);
243-
const signedPayload = Buffer.concat([instructionsHash, accountsHash]);
245+
const expiryBuf = Buffer.alloc(2);
246+
expiryBuf.writeUInt16LE(300);
247+
const signedPayload = Buffer.concat([instructionsHash, accountsHash, expiryBuf]);
244248

245249
// Counter is now 2 (after first test incremented to 1)
246250
const { authPayload, precompileIx } = await signSecp256r1({
@@ -380,7 +384,9 @@ describe('Deferred Execution', () => {
380384
{ pubkey: recipient, isSigner: false, isWritable: true },
381385
];
382386
const accountsHash = computeAccountsHash(tx2AccountMetas, compactIxs);
383-
const signedPayload = Buffer.concat([instructionsHash, accountsHash]);
387+
const expiryBuf = Buffer.alloc(2);
388+
expiryBuf.writeUInt16LE(300);
389+
const signedPayload = Buffer.concat([instructionsHash, accountsHash, expiryBuf]);
384390

385391
const { authPayload, precompileIx } = await signSecp256r1({
386392
key: ownerKey,
@@ -504,7 +510,9 @@ describe('Deferred Execution', () => {
504510
{ pubkey: recipient, isSigner: false, isWritable: true },
505511
];
506512
const accountsHash = computeAccountsHash(tx2AccountMetas, compactIxs);
507-
const signedPayload = Buffer.concat([instructionsHash, accountsHash]);
513+
const expiryBuf = Buffer.alloc(2);
514+
expiryBuf.writeUInt16LE(300);
515+
const signedPayload = Buffer.concat([instructionsHash, accountsHash, expiryBuf]);
508516

509517
const { authPayload, precompileIx } = await signSecp256r1({
510518
key: ownerKey,
@@ -610,7 +618,9 @@ describe('Deferred Execution', () => {
610618
{ pubkey: recipient, isSigner: false, isWritable: true },
611619
];
612620
const accountsHash = computeAccountsHash(tx2AccountMetas, compactIxs);
613-
const signedPayload = Buffer.concat([instructionsHash, accountsHash]);
621+
const expiryBuf = Buffer.alloc(2);
622+
expiryBuf.writeUInt16LE(9000);
623+
const signedPayload = Buffer.concat([instructionsHash, accountsHash, expiryBuf]);
614624

615625
const { authPayload, precompileIx } = await signSecp256r1({
616626
key: ownerKey,
@@ -710,7 +720,9 @@ describe('Deferred Execution', () => {
710720
{ pubkey: recipient, isSigner: false, isWritable: true },
711721
];
712722
const accountsHash = computeAccountsHash(tx2AccountMetas, compactIxs);
713-
const signedPayload = Buffer.concat([instructionsHash, accountsHash]);
723+
const expiryBuf = Buffer.alloc(2);
724+
expiryBuf.writeUInt16LE(10);
725+
const signedPayload = Buffer.concat([instructionsHash, accountsHash, expiryBuf]);
714726

715727
const { authPayload, precompileIx } = await signSecp256r1({
716728
key: ownerKey,

0 commit comments

Comments
 (0)