fix: add split to stake test
This commit is contained in:
committed by
Michael Vines
parent
3595892fab
commit
8541868587
@ -381,6 +381,7 @@ export class StakeProgram {
|
|||||||
this.space,
|
this.space,
|
||||||
this.programId,
|
this.programId,
|
||||||
);
|
);
|
||||||
|
transaction.instructions[0].keys[0].isSigner = false;
|
||||||
const type = StakeInstructionLayout.Split;
|
const type = StakeInstructionLayout.Split;
|
||||||
const data = encodeData(type, {lamports});
|
const data = encodeData(type, {lamports});
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ test('live staking actions', async () => {
|
|||||||
seed,
|
seed,
|
||||||
new Authorized(authorized.publicKey, authorized.publicKey),
|
new Authorized(authorized.publicKey, authorized.publicKey),
|
||||||
new Lockup(0, 0, new PublicKey('0x00')),
|
new Lockup(0, 0, new PublicKey('0x00')),
|
||||||
2 * minimumAmount + 42,
|
3 * minimumAmount + 42,
|
||||||
);
|
);
|
||||||
|
|
||||||
await sendAndConfirmRecentTransaction(
|
await sendAndConfirmRecentTransaction(
|
||||||
@ -275,7 +275,7 @@ test('live staking actions', async () => {
|
|||||||
from,
|
from,
|
||||||
);
|
);
|
||||||
let originalStakeBalance = await connection.getBalance(newAccountPubkey);
|
let originalStakeBalance = await connection.getBalance(newAccountPubkey);
|
||||||
expect(originalStakeBalance).toEqual(2 * minimumAmount + 42);
|
expect(originalStakeBalance).toEqual(3 * minimumAmount + 42);
|
||||||
|
|
||||||
let delegation = StakeProgram.delegate(
|
let delegation = StakeProgram.delegate(
|
||||||
newAccountPubkey,
|
newAccountPubkey,
|
||||||
@ -296,6 +296,21 @@ test('live staking actions', async () => {
|
|||||||
sendAndConfirmRecentTransaction(connection, withdraw, authorized),
|
sendAndConfirmRecentTransaction(connection, withdraw, authorized),
|
||||||
).rejects.toThrow();
|
).rejects.toThrow();
|
||||||
|
|
||||||
|
// Split stake
|
||||||
|
const newStake = new Account();
|
||||||
|
let split = StakeProgram.split(
|
||||||
|
newAccountPubkey,
|
||||||
|
authorized.publicKey,
|
||||||
|
minimumAmount + 20,
|
||||||
|
newStake.publicKey,
|
||||||
|
);
|
||||||
|
await sendAndConfirmRecentTransaction(
|
||||||
|
connection,
|
||||||
|
split,
|
||||||
|
authorized,
|
||||||
|
newStake,
|
||||||
|
);
|
||||||
|
|
||||||
// Authorize to new account
|
// Authorize to new account
|
||||||
const newAuthorized = new Account();
|
const newAuthorized = new Account();
|
||||||
await connection.requestAirdrop(newAuthorized.publicKey, LAMPORTS_PER_SOL);
|
await connection.requestAirdrop(newAuthorized.publicKey, LAMPORTS_PER_SOL);
|
||||||
@ -344,7 +359,7 @@ test('live staking actions', async () => {
|
|||||||
);
|
);
|
||||||
await sendAndConfirmRecentTransaction(connection, withdraw, newAuthorized);
|
await sendAndConfirmRecentTransaction(connection, withdraw, newAuthorized);
|
||||||
const balance = await connection.getBalance(newAccountPubkey);
|
const balance = await connection.getBalance(newAccountPubkey);
|
||||||
expect(balance).toEqual(minimumAmount + 22);
|
expect(balance).toEqual(minimumAmount + 2);
|
||||||
const recipientBalance = await connection.getBalance(recipient.publicKey);
|
const recipientBalance = await connection.getBalance(recipient.publicKey);
|
||||||
expect(recipientBalance).toEqual(minimumAmount + 20);
|
expect(recipientBalance).toEqual(minimumAmount + 20);
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user