Skip to content

Commit

Permalink
cli: Add solana-test-validator control to Anchor.toml (#834)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlinton committed Oct 5, 2021
1 parent dbb5f48 commit 54a6e9c
Show file tree
Hide file tree
Showing 3 changed files with 206 additions and 62 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ incremented for features.

### Features

* cli: Add support for configuration options for `solana-test-validator` in Anchor.toml ([#834](https://github.com/project-serum/anchor/pull/834)).
* cli: `target/types` directory now created on build to store a TypeScript types file for each program's IDL ([#795](https://github.com/project-serum/anchor/pull/795)).
* ts: `Program<T>` can now be typed with an IDL type ([#795](https://github.com/project-serum/anchor/pull/795)).
* lang: Add `mint::freeze_authority` keyword for mint initialization within `#[derive(Accounts)]` ([#835](https://github.com/project-serum/anchor/pull/835)).
Expand Down
62 changes: 61 additions & 1 deletion cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,9 @@ fn deser_programs(

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Test {
pub genesis: Vec<GenesisEntry>,
pub genesis: Option<Vec<GenesisEntry>>,
pub clone: Option<Vec<CloneEntry>>,
pub validator: Option<Validator>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand All @@ -470,6 +472,64 @@ pub struct GenesisEntry {
pub program: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CloneEntry {
// Base58 pubkey string.
pub address: String,
}

#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct Validator {
// IP address to bind the validator ports. [default: 0.0.0.0]
#[serde(default = "default_bind_address")]
pub bind_address: String,
// Range to use for dynamically assigned ports. [default: 1024-65535]
#[serde(skip_serializing_if = "Option::is_none")]
pub dynamic_port_range: Option<String>,
// Enable the faucet on this port [deafult: 9900].
#[serde(skip_serializing_if = "Option::is_none")]
pub faucet_port: Option<u16>,
// Give the faucet address this much SOL in genesis. [default: 1000000]
#[serde(skip_serializing_if = "Option::is_none")]
pub faucet_sol: Option<String>,
// Gossip DNS name or IP address for the validator to advertise in gossip. [default: 127.0.0.1]
#[serde(skip_serializing_if = "Option::is_none")]
pub gossip_host: Option<String>,
// Gossip port number for the validator
#[serde(skip_serializing_if = "Option::is_none")]
pub gossip_port: Option<u16>,
// URL for Solana's JSON RPC or moniker.
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
// Use DIR as ledger location
#[serde(default = "default_ledger_path")]
pub ledger: String,
// Keep this amount of shreds in root slots. [default: 10000]
#[serde(skip_serializing_if = "Option::is_none")]
pub limit_ledger_size: Option<String>,
// Enable JSON RPC on this port, and the next port for the RPC websocket. [default: 8899]
#[serde(default = "default_rpc_port")]
pub rpc_port: u16,
// Override the number of slots in an epoch.
#[serde(skip_serializing_if = "Option::is_none")]
pub slots_per_epoch: Option<String>,
// Warp the ledger to WARP_SLOT after starting the validator.
#[serde(skip_serializing_if = "Option::is_none")]
pub warp_slot: Option<String>,
}

fn default_ledger_path() -> String {
".anchor/test-ledger".to_string()
}

fn default_bind_address() -> String {
"0.0.0.0".to_string()
}

fn default_rpc_port() -> u16 {
8899
}

#[derive(Debug, Clone)]
pub struct Program {
pub lib_name: String,
Expand Down
Loading

0 comments on commit 54a6e9c

Please sign in to comment.