Skip to content

Commit

Permalink
Add more test cases to Sol Anchor (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
enoldev authored Jan 9, 2025
1 parent 7caf4e4 commit 5127e5d
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
CI: "true"
CODEGEN_MAINNET_API_KEY: ${{ secrets.CODEGEN_MAINNET_API_KEY }}
REGISTRY: ghcr.io
BUF_TOKEN: ${{ secrets.BUF_TOKEN }}
steps:
- name: Check out code
uses: actions/checkout@v3
Expand Down Expand Up @@ -54,7 +55,7 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run Tests
run: go test -v ./...
run: go test -v ./... -timeout 1800s

- name: Build
run: go build ./...
28 changes: 28 additions & 0 deletions tests/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,34 @@ func TestIntegration(t *testing.T) {
name: "sol-anchor-pump-fun",
stateFile: "./sol-anchor/pump-fun.json",
},
{
name: "sol-anchor-jupiter-governance",
stateFile: "./sol-anchor/jupiter-governance.json",
},
{
name: "sol-anchor-jupiter-staking",
stateFile: "./sol-anchor/jupiter-staking.json",
},
{
name: "sol-anchor-raydium-cp-swap.json",
stateFile: "./sol-anchor/raydium-cp-swap.json",
},
{
name: "sol-anchor-oasis.json",
stateFile: "./sol-anchor/oasis.json",
},
{
name: "sol-anchor-lifinity.json",
stateFile: "./sol-anchor/lifinity.json",
},
{
name: "sol-anchor-bonkswap.json",
stateFile: "./sol-anchor/bonkswap.json",
},
{
name: "sol-anchor-sanctum.json",
stateFile: "./sol-anchor/sanctum.json",
},
}

var zlog, _ = logging.RootLogger("test", "test")
Expand Down
9 changes: 9 additions & 0 deletions tests/sol-anchor/bonkswap.json

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions tests/sol-anchor/jupiter-governance.json

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions tests/sol-anchor/jupiter-staking.json

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions tests/sol-anchor/lifinity.json

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions tests/sol-anchor/oasis.json

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions tests/sol-anchor/raydium-cp-swap.json

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions tests/sol-anchor/sanctum.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"generator": "sol-anchor-beta",
"state": {
"name": "my_project",
"chainName": "solana-mainnet",
"initialBlockSet": true,
"idlString": "{\"version\":\"0.1.0\",\"name\":\"stakedex\",\"instructions\":[{\"name\":\"StakeWrappedSol\",\"accounts\":[{\"name\":\"user\",\"isMut\":false,\"isSigner\":true,\"desc\":\"The authority of wsol_account\"},{\"name\":\"wsolFrom\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The wrapped SOL token account to stake wrapped SOL from\"},{\"name\":\"destTokenTo\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The liquid staked SOL token account to receive the resulting tokens\"},{\"name\":\"wsolBridgeIn\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The PDA that serves as the wSOL account to bridge user's wSOL to SOL. Pubkey::create_with_seed(). base = sol_bridge_out.pubkey, seed = 'wsol_bridge_in'. owner = token_program\"},{\"name\":\"solBridgeOut\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The PDA that serves as the system account to bridge user's wSOL to SOL. Seeds = ['sol_bridge_out']\"},{\"name\":\"destTokenFeeTokenAccount\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The liquid staked SOL token account collecting fees. PDA. Seeds = ['fee', dest_token_mint.pubkey]\"},{\"name\":\"destTokenMint\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The liquid staked SOL mint\"},{\"name\":\"wsolMint\",\"isMut\":false,\"isSigner\":false,\"desc\":\"wSOL token mint\"},{\"name\":\"tokenProgram\",\"isMut\":false,\"isSigner\":false},{\"name\":\"systemProgram\",\"isMut\":false,\"isSigner\":false,\"desc\":\"System program. The deposit SOL accounts slice follows.\"}],\"args\":[{\"name\":\"amount\",\"type\":\"u64\"}],\"discriminant\":{\"type\":\"u8\",\"value\":0}},{\"name\":\"SwapViaStake\",\"accounts\":[{\"name\":\"user\",\"isMut\":true,\"isSigner\":true,\"desc\":\"The authority of src_token_from. Needs to be mutable to support marinade deposit stake.\"},{\"name\":\"srcTokenFrom\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The token account to swap src tokens from\"},{\"name\":\"destTokenTo\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The token account to receive dest tokens to\"},{\"name\":\"bridgeStake\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The bridge stake account thats withdrawn then deposited. PDA. seeds = ['bridge_stake', user.pubkey, SwapArgs.bridge_stake_seed]. Might be long-lived, make sure the seed is not already in use\"},{\"name\":\"destTokenFeeTokenAccount\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The dest_token_mint token account collecting fees. PDA. Seeds = ['fee', dest_token_mint.pubkey]\"},{\"name\":\"srcTokenMint\",\"isMut\":true,\"isSigner\":false,\"desc\":\"Input token mint. If this is wrapped SOL, the account can be set to read-only\"},{\"name\":\"destTokenMint\",\"isMut\":true,\"isSigner\":false,\"desc\":\"Output token mint. If this is wrapped SOL, the account can be set to read-only. The withdraw stake and deposit stake accounts slices follow.\"}],\"args\":[{\"name\":\"args\",\"type\":{\"defined\":\"SwapViaStakeArgs\"}}],\"discriminant\":{\"type\":\"u8\",\"value\":1}},{\"name\":\"CreateFeeTokenAccount\",\"accounts\":[{\"name\":\"payer\",\"isMut\":true,\"isSigner\":true,\"desc\":\"The person paying for the new fee token account. Can be anyone.\"},{\"name\":\"feeTokenAccount\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The self-owned fee token account to be created. Seeds = ['fee', mint_pubkey]\"},{\"name\":\"mint\",\"isMut\":false,\"isSigner\":false},{\"name\":\"tokenProgram\",\"isMut\":false,\"isSigner\":false},{\"name\":\"systemProgram\",\"isMut\":false,\"isSigner\":false}],\"args\":[],\"discriminant\":{\"type\":\"u8\",\"value\":2}},{\"name\":\"CloseFeeTokenAccount\",\"accounts\":[{\"name\":\"admin\",\"isMut\":false,\"isSigner\":true,\"desc\":\"The authorized program admin\"},{\"name\":\"feeTokenAccount\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The self-owned fee token account to close. Must be empty or wrapped SOL. Seeds = ['fee', mint_pubkey]\"},{\"name\":\"closeTo\",\"isMut\":true,\"isSigner\":false,\"desc\":\"Refund fee_token_account's rent lamports to here\"},{\"name\":\"mint\",\"isMut\":false,\"isSigner\":false},{\"name\":\"tokenProgram\",\"isMut\":false,\"isSigner\":false}],\"args\":[],\"discriminant\":{\"type\":\"u8\",\"value\":3}},{\"name\":\"WithdrawFees\",\"accounts\":[{\"name\":\"admin\",\"isMut\":false,\"isSigner\":true,\"desc\":\"The authorized program admin\"},{\"name\":\"feeTokenAccount\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The self-owned fee token account to withdraw fees from. Seeds = ['fee', mint_pubkey]\"},{\"name\":\"withdrawTo\",\"isMut\":true,\"isSigner\":false,\"desc\":\"Withdraw accumulated fees to here\"},{\"name\":\"mint\",\"isMut\":false,\"isSigner\":false},{\"name\":\"tokenProgram\",\"isMut\":false,\"isSigner\":false}],\"args\":[],\"discriminant\":{\"type\":\"u8\",\"value\":4}},{\"name\":\"DepositStake\",\"accounts\":[{\"name\":\"user\",\"isMut\":true,\"isSigner\":true,\"desc\":\"The withdraw authority of stake_account. Needs to be mutable to support marinade deposit stake.\"},{\"name\":\"stakeAccount\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The stake account to deposit\"},{\"name\":\"destTokenTo\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The token account to receive dest tokens to\"},{\"name\":\"destTokenFeeTokenAccount\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The dest_token_mint token account collecting fees. PDA. Seeds = ['fee', dest_token_mint.pubkey]\"},{\"name\":\"destTokenMint\",\"isMut\":true,\"isSigner\":false,\"desc\":\"Output token mint. If this is wrapped SOL, the account can be set to read-only. The deposit stake accounts slice follows.\"}],\"args\":[],\"discriminant\":{\"type\":\"u8\",\"value\":5}},{\"name\":\"PrefundWithdrawStake\",\"accounts\":[{\"name\":\"user\",\"isMut\":true,\"isSigner\":true,\"desc\":\"The withdraw authority of stake_account. Needs to be mutable and system account to receive slumlord flash loan.\"},{\"name\":\"srcTokenFrom\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The token account to burn src tokens from in order to withdraw stake\"},{\"name\":\"bridgeStake\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The bridge stake account thats withdrawn and given to the user. PDA. seeds = ['bridge_stake', user.pubkey, SwapArgs.bridge_stake_seed]. Might be long-lived, make sure the seed is not already in use\"},{\"name\":\"srcTokenMint\",\"isMut\":true,\"isSigner\":false,\"desc\":\"Input LST token mint\"},{\"name\":\"prefunder\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The system account PDA that contains enough SOL to prefund 2 stake accounts for withdrawal. Someone must send SOL to here to initialize it. Seeds = ['prefunder']\"},{\"name\":\"slumdogStake\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The slumdog stake account is split from bridge_stake upon stake withdraw and instant unstaked to repay slumlord's flash loan. create_with_seed(bridge_stake.pubkey, 'slumdog', stake_program). Might be long-lived, but should be not in use as long as bridge_stake is not in use\"},{\"name\":\"unstakeitProgram\",\"isMut\":false,\"isSigner\":false,\"desc\":\"Sanctum unstake program. unpXTU2Ndrc7WWNyEhQWe4udTzSibLPi25SXv2xbCHQ\"},{\"name\":\"unstakePool\",\"isMut\":true,\"isSigner\":false,\"desc\":\"Sanctum unstake pool. FypPtwbY3FUfzJUtXHSyVRokVKG2jKtH29FmK4ebxRSd\"},{\"name\":\"poolSolReserves\",\"isMut\":true,\"isSigner\":false,\"desc\":\"Sanctum unstake pool SOL reserves. 3rBnnH9TTgd3xwu48rnzGsaQkSr1hR64nY71DrDt6VrQ\"},{\"name\":\"unstakeFee\",\"isMut\":false,\"isSigner\":false,\"desc\":\"Sanctum unstake pool Fee account. 5Pcu8WeQa3VbBz2vdBT49Rj4gbS4hsnfzuL1LmuRaKFY\"},{\"name\":\"slumdogStakeAccRecord\",\"isMut\":true,\"isSigner\":false,\"desc\":\"Sanctum unstake pool stake account record for slumdog stake. PDA of sanctum unstake program. Seeds = [unstakePool.pubkey, slumdogStake.pubkey].\"},{\"name\":\"unstakeProtocolFee\",\"isMut\":false,\"isSigner\":false,\"desc\":\"Sanctum unstake pool protocol fee account. 2hN9UhvRFVfPYKL6rZJ5YiLEPCLTpN755pgwDJHWgFbU\"},{\"name\":\"unstakeProtocolFeeDest\",\"isMut\":true,\"isSigner\":false,\"desc\":\"Sanctum unstake pool protocol fee destination. unstakeProtocolFee.destination\"},{\"name\":\"clock\",\"isMut\":false,\"isSigner\":false,\"desc\":\"sysvar clock\"},{\"name\":\"stakeProgram\",\"isMut\":false,\"isSigner\":false,\"desc\":\"stake program\"},{\"name\":\"systemProgram\",\"isMut\":false,\"isSigner\":false,\"desc\":\"System program. The withdraw stake accounts slices follow.\"}],\"args\":[{\"name\":\"args\",\"type\":{\"defined\":\"SwapViaStakeArgs\"}}],\"discriminant\":{\"type\":\"u8\",\"value\":6}},{\"name\":\"PrefundSwapViaStake\",\"accounts\":[{\"name\":\"user\",\"isMut\":true,\"isSigner\":true,\"desc\":\"The authority of src_token_from, mutable system account\"},{\"name\":\"srcTokenFrom\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The token account to swap src tokens from\"},{\"name\":\"destTokenTo\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The token account to receive dest tokens to\"},{\"name\":\"bridgeStake\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The bridge stake account thats withdrawn then deposited. PDA. seeds = ['bridge_stake', user.pubkey, SwapArgs.bridge_stake_seed]. Might be long-lived, make sure the seed is not already in use\"},{\"name\":\"destTokenFeeTokenAccount\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The dest_token_mint token account collecting fees. PDA. Seeds = ['fee', dest_token_mint.pubkey]\"},{\"name\":\"srcTokenMint\",\"isMut\":true,\"isSigner\":false,\"desc\":\"Input token mint. If this is wrapped SOL, the account can be set to read-only\"},{\"name\":\"destTokenMint\",\"isMut\":true,\"isSigner\":false,\"desc\":\"Output token mint. If this is wrapped SOL, the account can be set to read-only\"},{\"name\":\"prefunder\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The system account PDA that contains enough SOL to prefund 2 stake accounts for withdrawal. Someone must send SOL to here to initialize it. Seeds = ['prefunder']\"},{\"name\":\"slumdogStake\",\"isMut\":true,\"isSigner\":false,\"desc\":\"The slumdog stake account is split from bridge_stake upon stake withdraw and instant unstaked to refund user. create_with_seed(bridge_stake.pubkey, 'slumdog', stake_program). Might be long-lived, but should be not in use as long as bridge_stake is not in use\"},{\"name\":\"unstakeitProgram\",\"isMut\":false,\"isSigner\":false,\"desc\":\"Sanctum unstake program. unpXTU2Ndrc7WWNyEhQWe4udTzSibLPi25SXv2xbCHQ\"},{\"name\":\"unstakePool\",\"isMut\":true,\"isSigner\":false,\"desc\":\"Sanctum unstake pool. FypPtwbY3FUfzJUtXHSyVRokVKG2jKtH29FmK4ebxRSd\"},{\"name\":\"poolSolReserves\",\"isMut\":true,\"isSigner\":false,\"desc\":\"Sanctum unstake pool SOL reserves. 3rBnnH9TTgd3xwu48rnzGsaQkSr1hR64nY71DrDt6VrQ\"},{\"name\":\"unstakeFee\",\"isMut\":false,\"isSigner\":false,\"desc\":\"Sanctum unstake pool Fee account. 5Pcu8WeQa3VbBz2vdBT49Rj4gbS4hsnfzuL1LmuRaKFY\"},{\"name\":\"slumdogStakeAccRecord\",\"isMut\":true,\"isSigner\":false,\"desc\":\"Sanctum unstake pool stake account record for slumdog stake. PDA of sanctum unstake program. Seeds = [unstakePool.pubkey, slumdogStake.pubkey].\"},{\"name\":\"unstakeProtocolFee\",\"isMut\":false,\"isSigner\":false,\"desc\":\"Sanctum unstake pool protocol fee account. 2hN9UhvRFVfPYKL6rZJ5YiLEPCLTpN755pgwDJHWgFbU\"},{\"name\":\"unstakeProtocolFeeDest\",\"isMut\":true,\"isSigner\":false,\"desc\":\"Sanctum unstake pool protocol fee destination. unstakeProtocolFee.destination\"},{\"name\":\"clock\",\"isMut\":false,\"isSigner\":false,\"desc\":\"sysvar clock\"},{\"name\":\"stakeProgram\",\"isMut\":false,\"isSigner\":false,\"desc\":\"stake program\"},{\"name\":\"systemProgram\",\"isMut\":false,\"isSigner\":false,\"desc\":\"System program. The withdraw stake and deposit stake accounts slices follow.\"}],\"args\":[{\"name\":\"args\",\"type\":{\"defined\":\"SwapViaStakeArgs\"}}],\"discriminant\":{\"type\":\"u8\",\"value\":7}}],\"types\":[{\"name\":\"SwapViaStakeArgs\",\"type\":{\"kind\":\"struct\",\"fields\":[{\"name\":\"amount\",\"type\":\"u64\"},{\"name\":\"bridgeStakeSeed\",\"type\":\"u32\"}]}}],\"errors\":[{\"code\":0,\"name\":\"WrongWsolBridgeIn\",\"msg\":\"Wrong wsol_bridge_in account\"},{\"code\":1,\"name\":\"WrongSolBridgeOut\",\"msg\":\"Wrong sol_bridge_out account\"},{\"code\":2,\"name\":\"WrongFeeTokenAccount\",\"msg\":\"Wrong fee token account\"},{\"code\":3,\"name\":\"WrongTokenProgram\",\"msg\":\"Wrong token program\"},{\"code\":4,\"name\":\"NotSystemAccount\",\"msg\":\"Not system account\"},{\"code\":5,\"name\":\"NotWsolMint\",\"msg\":\"Not wSOL mint\"},{\"code\":6,\"name\":\"WrongStakePoolProgram\",\"msg\":\"Wrong stake pool program\"},{\"code\":7,\"name\":\"WrongBridgeStake\",\"msg\":\"Wrong bridge stake account\"},{\"code\":8,\"name\":\"WrongAdmin\",\"msg\":\"Wrong admin authority\"},{\"code\":9,\"name\":\"StakeAccInactive\",\"msg\":\"Stake account has no voter\"},{\"code\":10,\"name\":\"ValidatorNotPartOfStakePool\",\"msg\":\"Validator not part of stake pool\"},{\"code\":11,\"name\":\"NotSignedByAdmin\",\"msg\":\"Not signed by admin\"},{\"code\":12,\"name\":\"NumericalError\",\"msg\":\"Numerical error\"},{\"code\":13,\"name\":\"UnsupportedProgram\",\"msg\":\"Unsupported stake pool program\"},{\"code\":14,\"name\":\"UnreachableError\",\"msg\":\"If you see this, there's a serious bug somewhere\"},{\"code\":17,\"name\":\"SlumdogUnstakeTooSmall\",\"msg\":\"Instant unstake of slumdog stake was not enough to cover rent\"}],\"metadata\":{\"origin\":\"shank\",\"address\":\"stkitrT1Uoy18Dk1fTrgPw8W6MVzoCfYoAFT4MLsmhq\"}}"
}
}

0 comments on commit 5127e5d

Please sign in to comment.