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