feat: add support for more system instructions

This commit is contained in:
Justin Starry
2020-05-09 18:33:36 +08:00
committed by Michael Vines
parent 09d1b7f39f
commit c584fbdf39
5 changed files with 323 additions and 44 deletions

View File

@ -49,9 +49,36 @@ test('transfer', () => {
expect(params).toEqual(SystemInstruction.decodeTransfer(systemInstruction));
});
test('allocate', () => {
const params = {
accountPubkey: new Account().publicKey,
space: 42,
};
const transaction = SystemProgram.allocate(params);
expect(transaction.instructions).toHaveLength(1);
const [systemInstruction] = transaction.instructions;
expect(params).toEqual(SystemInstruction.decodeAllocate(systemInstruction));
});
test('allocateWithSeed', () => {
const params = {
accountPubkey: new Account().publicKey,
basePubkey: new Account().publicKey,
seed: '你好',
space: 42,
programId: new Account().publicKey,
};
const transaction = SystemProgram.allocate(params);
expect(transaction.instructions).toHaveLength(1);
const [systemInstruction] = transaction.instructions;
expect(params).toEqual(
SystemInstruction.decodeAllocateWithSeed(systemInstruction),
);
});
test('assign', () => {
const params = {
fromPubkey: new Account().publicKey,
accountPubkey: new Account().publicKey,
programId: new Account().publicKey,
};
const transaction = SystemProgram.assign(params);
@ -60,6 +87,21 @@ test('assign', () => {
expect(params).toEqual(SystemInstruction.decodeAssign(systemInstruction));
});
test('assignWithSeed', () => {
const params = {
accountPubkey: new Account().publicKey,
basePubkey: new Account().publicKey,
seed: '你好',
programId: new Account().publicKey,
};
const transaction = SystemProgram.assign(params);
expect(transaction.instructions).toHaveLength(1);
const [systemInstruction] = transaction.instructions;
expect(params).toEqual(
SystemInstruction.decodeAssignWithSeed(systemInstruction),
);
});
test('createAccountWithSeed', () => {
const fromPubkey = new Account().publicKey;
const params = {