Skip to content

Commit

Permalink
[sdk] claim withdraw request - contract fixes & testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ochaloup committed Jan 16, 2024
1 parent d9165c8 commit 55c2f0d
Show file tree
Hide file tree
Showing 17 changed files with 840 additions and 181 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"ts-jest": "^29.1.1",
"ts-node": "^10.9.1",
"typescript": "4.9.5",
"@marinade.finance/jest-utils": "^2.1.0"
"@marinade.finance/jest-utils": "^2.1.1"
},
"pnpm": {
"peerDependencyRules": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import {
AnchorExtendedProvider,
initTest,
waitForNextEpoch,
} from '@marinade.finance/validator-bonds-sdk/__tests__/test-validator/testValidator'
import { executeInitConfigInstruction } from '@marinade.finance/validator-bonds-sdk/__tests__/utils/testTransactions'
import {
Expand All @@ -23,6 +24,10 @@ describe('Merge stake accounts using CLI', () => {
beforeAll(async () => {
shellMatchers()
;({ provider, program } = await initTest())
// we want to be at the beginning of the epoch
// otherwise the merge instruction could fail as the stake account is in different state (0x6)
// https://github.com/solana-labs/solana/blob/v1.17.15/sdk/program/src/stake/instruction.rs#L42
await waitForNextEpoch(provider.connection, 15)
})

beforeEach(async () => {
Expand Down
12 changes: 6 additions & 6 deletions packages/validator-bonds-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
"@marinade.finance/validator-bonds-sdk": "^1.1.5",
"@coral-xyz/anchor": "^0.29.0",
"@solana/web3.js": "^1.87.6",
"@marinade.finance/cli-common": "^2.1.0",
"@marinade.finance/anchor-common": "^2.1.0",
"@marinade.finance/web3js-common": "^2.1.0",
"@marinade.finance/ledger-utils": "^2.1.0",
"@marinade.finance/ts-common": "^2.1.0",
"@marinade.finance/cli-common": "^2.1.1",
"@marinade.finance/anchor-common": "^2.1.1",
"@marinade.finance/web3js-common": "^2.1.1",
"@marinade.finance/ledger-utils": "^2.1.1",
"@marinade.finance/ts-common": "^2.1.1",
"bn.js": "^5.2.1",
"jsbi": "^4.3.0",
"commander": "^9.5.0",
Expand All @@ -41,6 +41,6 @@
"yaml": "^2.3.3"
},
"devDependencies": {
"@marinade.finance/jest-utils": "^2.1.0"
"@marinade.finance/jest-utils": "^2.1.1"
}
}
9 changes: 5 additions & 4 deletions packages/validator-bonds-sdk/__tests__/bankrun/bankrun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ValidatorBondsProgram, getProgram } from '../../src'
import { BanksTransactionMeta, startAnchor } from 'solana-bankrun'
import { BankrunProvider } from 'anchor-bankrun'
import {
Keypair,
PublicKey,
Signer,
Transaction,
Expand All @@ -17,7 +18,7 @@ export class BankrunExtendedProvider
implements ExtendedProvider
{
async sendIx(
signers: (WalletInterface | Signer)[],
signers: (WalletInterface | Signer | Keypair)[],
...ixes: (
| Transaction
| TransactionInstruction
Expand Down Expand Up @@ -62,7 +63,7 @@ export async function bankrunTransaction(

export async function bankrunExecuteIx(
provider: BankrunProvider,
signers: (WalletInterface | Signer)[],
signers: (WalletInterface | Signer | Keypair)[],
...ixes: (
| Transaction
| TransactionInstruction
Expand All @@ -76,13 +77,13 @@ export async function bankrunExecuteIx(

export async function bankrunExecute(
provider: BankrunProvider,
signers: (WalletInterface | Signer)[],
signers: (WalletInterface | Signer | Keypair)[],
tx: Transaction
): Promise<BanksTransactionMeta> {
for (const signer of signers) {
if (instanceOfWallet(signer)) {
await signer.signTransaction(tx)
} else if ('secretKey' in signer) {
} else if (signer instanceof Keypair || 'secretKey' in signer) {
tx.partialSign(signer)
} else {
throw new Error(
Expand Down
Loading

0 comments on commit 55c2f0d

Please sign in to comment.