feat: add support for more system instructions
This commit is contained in:
committed by
Michael Vines
parent
09d1b7f39f
commit
c584fbdf39
@ -132,7 +132,7 @@ test('get program accounts', async () => {
|
||||
},
|
||||
]);
|
||||
let transaction = SystemProgram.assign({
|
||||
fromPubkey: account0.publicKey,
|
||||
accountPubkey: account0.publicKey,
|
||||
programId: programId.publicKey,
|
||||
});
|
||||
await sendAndConfirmTransaction(connection, transaction, account0);
|
||||
@ -176,7 +176,7 @@ test('get program accounts', async () => {
|
||||
},
|
||||
]);
|
||||
transaction = SystemProgram.assign({
|
||||
fromPubkey: account1.publicKey,
|
||||
accountPubkey: account1.publicKey,
|
||||
programId: programId.publicKey,
|
||||
});
|
||||
|
||||
|
@ -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 = {
|
||||
|
Reference in New Issue
Block a user