Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: Add solana-test-validator control to Anchor.toml #834

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e481a8b
Add validator config struct
tomlinton Aug 30, 2021
2c15392
Update handling of optional entries
tomlinton Aug 30, 2021
77a7293
Skip serializing nulls and remove default test ledger directory
tomlinton Sep 1, 2021
4087f7b
Handle non standard port
tomlinton Sep 1, 2021
4854df0
Make validator key optional
tomlinton Sep 1, 2021
d110a2f
Merge branch 'master' into tomlinton/validator-anchor-toml-control
tomlinton Sep 13, 2021
399932a
Any local validator is localnet
tomlinton Sep 14, 2021
a2c4f80
Add more solana-test-validator config options
tomlinton Sep 14, 2021
567dd57
Checkpoint
tomlinton Sep 14, 2021
7331a82
WIP
tomlinton Sep 30, 2021
0a87b34
Merge branch 'master' into tomlinton/validator-anchor-toml-control
tomlinton Sep 30, 2021
b7df324
Merge branch 'master' into tomlinton/validator-anchor-toml-control
tomlinton Oct 4, 2021
88d727e
Remove extra file
tomlinton Oct 4, 2021
0bd4341
Handle custom URL properly
tomlinton Oct 4, 2021
405a4cf
Revert "Remove extra file"
tomlinton Oct 4, 2021
62163ee
Remove unnecessary code
tomlinton Oct 4, 2021
3e963ae
Fix missing args
tomlinton Oct 4, 2021
41a8bf4
Handle log stream for custom URL
tomlinton Oct 4, 2021
9cc060e
Ledger arg handling
tomlinton Oct 4, 2021
ce414bf
Clone support
tomlinton Oct 4, 2021
e030c12
Change URL in arg
tomlinton Oct 4, 2021
c841a7e
Better config and URL handling
tomlinton Oct 4, 2021
bfc5b99
Stream logs after validator starts in localnet command
tomlinton Oct 4, 2021
528827b
Update comment
tomlinton Oct 4, 2021
f90a34a
Make validator key optional
tomlinton Oct 5, 2021
03b938f
Add comment back
tomlinton Oct 5, 2021
30fc3d9
Update changelog
tomlinton Oct 5, 2021
4933ca4
Clippy
tomlinton Oct 5, 2021
3991847
Always provide ledger dir argument
tomlinton Oct 5, 2021
e457f38
Merge remote-tracking branch 'origin' into tomlinton/validator-anchor…
tomlinton Oct 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)).

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