feat: allow passing seed to createNonceAccount

This commit is contained in:
Justin Starry
2020-05-05 13:30:55 +08:00
committed by Michael Vines
parent 5662808b4c
commit c5802bcbb6
5 changed files with 240 additions and 27 deletions

View File

@ -112,6 +112,43 @@ test('createNonceAccount', () => {
);
});
test('createNonceAccount with seed', () => {
const fromPubkey = new Account().publicKey;
const params = {
fromPubkey,
noncePubkey: new Account().publicKey,
authorizedPubkey: fromPubkey,
basePubkey: fromPubkey,
seed: 'hi there',
lamports: 123,
};
const transaction = SystemProgram.createNonceAccount(params);
expect(transaction.instructions).toHaveLength(2);
const [createInstruction, initInstruction] = transaction.instructions;
const createParams = {
fromPubkey: params.fromPubkey,
newAccountPubkey: params.noncePubkey,
basePubkey: fromPubkey,
seed: 'hi there',
lamports: params.lamports,
space: NONCE_ACCOUNT_LENGTH,
programId: SystemProgram.programId,
};
expect(createParams).toEqual(
SystemInstruction.decodeCreateWithSeed(createInstruction),
);
const initParams = {
noncePubkey: params.noncePubkey,
authorizedPubkey: fromPubkey,
};
expect(initParams).toEqual(
SystemInstruction.decodeNonceInitialize(initInstruction),
);
});
test('nonceAdvance', () => {
const params = {
noncePubkey: new Account().publicKey,