fix: createProgramAddress now throws on an invalid seed length

This commit is contained in:
Michael Vines
2020-10-13 13:40:38 -07:00
parent f8d338c9cb
commit e84a91d417
5 changed files with 19 additions and 2 deletions

View File

@ -1,7 +1,7 @@
// @flow
import BN from 'bn.js';
import {PublicKey} from '../src/publickey';
import {PublicKey, MAX_SEED_LENGTH} from '../src/publickey';
test('invalid', () => {
expect(() => {
@ -279,6 +279,13 @@ test('createProgramAddress', async () => {
);
expect(programAddress.equals(programAddress2)).toBe(false);
await expect(
PublicKey.createProgramAddress(
[Buffer.alloc(MAX_SEED_LENGTH + 1)],
programId,
),
).rejects.toThrow('Max seed length exceeded');
// https://github.com/solana-labs/solana/issues/11950
{
let seeds = [