Skip to content

Commit

Permalink
Local test for drift (#84)
Browse files Browse the repository at this point in the history
Localnet test cases
1. drift initialize
2. drift update trader 

Other tests cannot be easily realized in localnet due to the lack of
usdc holding.
  • Loading branch information
yurushao authored Apr 22, 2024
1 parent f7b2050 commit 6962afb
Show file tree
Hide file tree
Showing 11 changed files with 216 additions and 330 deletions.
15 changes: 12 additions & 3 deletions anchor/Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,17 @@ address = "6ZBb3LRddLtBq6DeNtSaUrMipieaFJgTETgTBoiAGBCC"
[[test.validator.clone]]
address = "CWb949XA3vrdiEp2BFtjr9MbUonHke8CVdTb8Cr7Hctd"

[[test.validator.account]]
# Drift program
# solana account -u d --output json --output-file drift.json dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH
[[test.genesis]]
address = "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH"
filename = "drift.json"
program = "fixtures/drift.so"

# Drift state account
[[test.validator.clone]]
address = "5zpq7DvB6UdFFvpmBPspGPNfUGoBRRCE2HHg5u3gxcsN"
[[test.validator.clone]]
address = "GXWqPpjQpdz7KZw9p7f5PX2eGxHAhvpNXiviFkAB8zXg"
[[test.validator.clone]]
address = "3x85u7SWkmmr7YQGYhtjARgxwegTLJgkSLRprfXod6rh"
[[test.validator.clone]]
address = "6gMq3mRCKf8aP3ttTyYhuijVZ2LGi14oDsBbkgubfLB3"
14 changes: 0 additions & 14 deletions anchor/drift.json

This file was deleted.

Binary file added anchor/fixtures/drift.so
Binary file not shown.
3 changes: 2 additions & 1 deletion anchor/programs/glam/src/instructions/drift.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use anchor_lang::prelude::*;
use anchor_spl::token::Token;
use anchor_spl::associated_token::AssociatedToken;
use anchor_spl::token::{Mint, Token};
use anchor_spl::token_interface::TokenAccount;

use crate::error::ManagerError;
Expand Down
29 changes: 17 additions & 12 deletions anchor/target/idl/glam.json
Original file line number Diff line number Diff line change
Expand Up @@ -683,33 +683,38 @@
"errors": [
{
"code": 6000,
"name": "FundNotActive",
"msg": "Fund is not active"
"name": "CloseNotEmptyError",
"msg": "Error closing account: not empty"
},
{
"code": 6001,
"name": "InvalidShareClass",
"msg": "Share class not allowed to subscribe"
"name": "NotAuthorizedError",
"msg": "Error: not authorized"
},
{
"code": 6002,
"name": "InvalidAssetSubscribe",
"msg": "Asset not allowed to subscribe"
"name": "InvalidFundName",
"msg": "Invalid fund name: max 30 chars"
},
{
"code": 6003,
"name": "InvalidPricingOracle",
"msg": "Invalid oracle for asset price"
"name": "InvalidFundSymbol",
"msg": "Too many assets: max 50"
},
{
"code": 6004,
"name": "InvalidAssetsRedeem",
"msg": "Invalid assets in redeem"
"name": "InvalidFundUri",
"msg": "Too many assets: max 20"
},
{
"code": 6005,
"name": "InvalidTreasuryAccount",
"msg": "Invalid treasury account"
"name": "InvalidAssetsLen",
"msg": "Too many assets: max 100"
},
{
"code": 6006,
"name": "InvalidAssetsWeights",
"msg": "Number of weights should match number of assets"
}
],
"types": [
Expand Down
29 changes: 17 additions & 12 deletions anchor/target/types/glam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -689,33 +689,38 @@ export type Glam = {
"errors": [
{
"code": 6000,
"name": "fundNotActive",
"msg": "Fund is not active"
"name": "closeNotEmptyError",
"msg": "Error closing account: not empty"
},
{
"code": 6001,
"name": "invalidShareClass",
"msg": "Share class not allowed to subscribe"
"name": "notAuthorizedError",
"msg": "Error: not authorized"
},
{
"code": 6002,
"name": "invalidAssetSubscribe",
"msg": "Asset not allowed to subscribe"
"name": "invalidFundName",
"msg": "Invalid fund name: max 30 chars"
},
{
"code": 6003,
"name": "invalidPricingOracle",
"msg": "Invalid oracle for asset price"
"name": "invalidFundSymbol",
"msg": "Too many assets: max 50"
},
{
"code": 6004,
"name": "invalidAssetsRedeem",
"msg": "Invalid assets in redeem"
"name": "invalidFundUri",
"msg": "Too many assets: max 20"
},
{
"code": 6005,
"name": "invalidTreasuryAccount",
"msg": "Invalid treasury account"
"name": "invalidAssetsLen",
"msg": "Too many assets: max 100"
},
{
"code": 6006,
"name": "invalidAssetsWeights",
"msg": "Number of weights should match number of assets"
}
],
"types": [
Expand Down
234 changes: 0 additions & 234 deletions anchor/tests-old/policy.spec.ts

This file was deleted.

Loading

0 comments on commit 6962afb

Please sign in to comment.