Skip to content

Commit

Permalink
[cli] fix claim withdraw request
Browse files Browse the repository at this point in the history
  • Loading branch information
ochaloup committed Jan 13, 2025
1 parent e9404d7 commit da6bd05
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,50 @@ describe('Claim withdraw request using CLI', () => {
).toEqual(1)
})

it('claim withdraw request with stake account', async () => {
const stakeAccount = await createBondsFundedStakeAccount({
program,
provider,
configAccount,
lamports: withdrawRequestLamports,
voteAccount,
})

const user = await createUserAndFund({ provider })

// waiting for next epoch, otherwise the merge fails as stake accounts are in different states (0x6)
// + needed to wait 1 epoch for the withdraw request to be claimable (config set 'withdrawLockupEpochs' to 0)
await waitForNextEpoch(provider.connection, 15)

await (
expect([
'pnpm',
[
'cli',
'-u',
provider.connection.rpcEndpoint,
'--program-id',
program.programId.toBase58(),
'claim-withdraw-request',
voteAccount.toBase58(),
'--config',
configAccount.toBase58(),
'--authority',
validatorIdentityPath,
'--withdrawer',
pubkey(user).toBase58(),
'--stake-account',
stakeAccount.toBase58(),
],
// eslint-disable-next-line @typescript-eslint/no-explicit-any
]) as any
).toHaveMatchingSpawnOutput({
code: 0,
// stderr: '',
stdout: /successfully claimed/,
})
})

it('claim withdraw request in print-only mode', async () => {
await createBondsFundedStakeAccount({
program,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ async function manageClaimWithdrawRequest({
let stakeAccountsToWithdraw: PublicKey[] = []
if (stakeAccount !== undefined) {
// forced to use provided stake account
const { instruction, withdrawRequestAccount } =
const { instruction, withdrawRequestAccount, splitStakeAccount } =
await claimWithdrawRequestInstruction({
program,
withdrawRequestAccount: withdrawRequestAddress,
Expand All @@ -189,6 +189,7 @@ async function manageClaimWithdrawRequest({
splitStakeRentPayer,
withdrawer,
})
signers.push(splitStakeAccount)
withdrawRequestAddress = withdrawRequestAccount
instructionsToProcess = [instruction]
stakeAccountsToWithdraw = [stakeAccount]
Expand Down

0 comments on commit da6bd05

Please sign in to comment.