-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
291 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
//! clap [Args](clap::Args) for Dev testnet configuration | ||
use std::time::Duration; | ||
|
||
use clap::Args; | ||
use humantime::parse_duration; | ||
|
||
/// Parameters for Dev testnet configuration | ||
#[derive(Debug, Args, PartialEq, Default, Clone, Copy)] | ||
#[command(next_help_heading = "Dev testnet")] | ||
pub struct DevArgs { | ||
/// Start the node in dev mode | ||
/// | ||
/// This mode uses a local proof-of-authority consensus engine with either fixed block times | ||
/// or automatically mined blocks. | ||
/// Disables network discovery and enables local http server. | ||
/// Prefunds 20 accounts derived by mnemonic "test test test test test test test test test test | ||
/// test junk" with 10 000 ETH each. | ||
#[arg(long = "dev", alias = "auto-mine", help_heading = "Dev testnet", verbatim_doc_comment)] | ||
pub dev: bool, | ||
|
||
/// How many transactions to mine per block. | ||
#[arg( | ||
long = "dev.block_max_transactions", | ||
help_heading = "Dev testnet", | ||
conflicts_with = "block_time" | ||
)] | ||
pub block_max_transactions: Option<usize>, | ||
|
||
/// Interval between blocks. | ||
/// | ||
/// Parses strings using [humantime::parse_duration] | ||
/// --dev.block_time 12s | ||
#[arg( | ||
long = "dev.block_time", | ||
help_heading = "Dev testnet", | ||
conflicts_with = "block_max_transactions", | ||
value_parser = parse_duration, | ||
verbatim_doc_comment | ||
)] | ||
pub block_time: Option<Duration>, | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use clap::Parser; | ||
|
||
/// A helper type to parse Args more easily | ||
#[derive(Parser)] | ||
struct CommandParser<T: Args> { | ||
#[clap(flatten)] | ||
args: T, | ||
} | ||
|
||
#[test] | ||
fn test_parse_dev_args() { | ||
let args = CommandParser::<DevArgs>::parse_from(["reth"]).args; | ||
assert_eq!(args, DevArgs { dev: false, block_max_transactions: None, block_time: None }); | ||
|
||
let args = CommandParser::<DevArgs>::parse_from(["reth", "--dev"]).args; | ||
assert_eq!(args, DevArgs { dev: true, block_max_transactions: None, block_time: None }); | ||
|
||
let args = CommandParser::<DevArgs>::parse_from(["reth", "--auto-mine"]).args; | ||
assert_eq!(args, DevArgs { dev: true, block_max_transactions: None, block_time: None }); | ||
|
||
let args = CommandParser::<DevArgs>::parse_from([ | ||
"reth", | ||
"--dev", | ||
"--dev.block_max_transactions", | ||
"2", | ||
]) | ||
.args; | ||
assert_eq!(args, DevArgs { dev: true, block_max_transactions: Some(2), block_time: None }); | ||
|
||
let args = | ||
CommandParser::<DevArgs>::parse_from(["reth", "--dev", "--dev.block_time", "1s"]).args; | ||
assert_eq!( | ||
args, | ||
DevArgs { | ||
dev: true, | ||
block_max_transactions: None, | ||
block_time: Some(std::time::Duration::from_secs(1)) | ||
} | ||
); | ||
} | ||
|
||
#[test] | ||
fn test_parse_dev_args_conflicts() { | ||
let args = CommandParser::<DevArgs>::try_parse_from([ | ||
"reth", | ||
"--dev", | ||
"--dev.block_max_transactions", | ||
"2", | ||
"--dev.block_time", | ||
"1s", | ||
]); | ||
assert!(args.is_err()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
{ | ||
"nonce": "0x0", | ||
"timestamp": "0x6490fdd2", | ||
"extraData": "0x", | ||
"gasLimit": "0x1c9c380", | ||
"difficulty": "0x0", | ||
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"coinbase": "0x0000000000000000000000000000000000000000", | ||
"stateRoot": "0x5eb6e371a698b8d68f665192350ffcecbbbf322916f4b51bd79bb6887da3f494", | ||
"alloc": { | ||
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266": { | ||
"balance": "0xD3C21BCECCEDA1000000" | ||
}, | ||
"0x70997970C51812dc3A010C7d01b50e0d17dc79C8": { | ||
"balance": "0xD3C21BCECCEDA1000000" | ||
}, | ||
"0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC": { | ||
"balance": "0xD3C21BCECCEDA1000000" | ||
}, | ||
"0x90F79bf6EB2c4f870365E785982E1f101E93b906": { | ||
"balance": "0xD3C21BCECCEDA1000000" | ||
}, | ||
"0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65": { | ||
"balance": "0xD3C21BCECCEDA1000000" | ||
}, | ||
"0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc": { | ||
"balance": "0xD3C21BCECCEDA1000000" | ||
}, | ||
"0x976EA74026E726554dB657fA54763abd0C3a0aa9": { | ||
"balance": "0xD3C21BCECCEDA1000000" | ||
}, | ||
"0x14dC79964da2C08b23698B3D3cc7Ca32193d9955": { | ||
"balance": "0xD3C21BCECCEDA1000000" | ||
}, | ||
"0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f": { | ||
"balance": "0xD3C21BCECCEDA1000000" | ||
}, | ||
"0xa0Ee7A142d267C1f36714E4a8F75612F20a79720": { | ||
"balance": "0xD3C21BCECCEDA1000000" | ||
}, | ||
"0xBcd4042DE499D14e55001CcbB24a551F3b954096": { | ||
"balance": "0xD3C21BCECCEDA1000000" | ||
}, | ||
"0x71bE63f3384f5fb98995898A86B02Fb2426c5788": { | ||
"balance": "0xD3C21BCECCEDA1000000" | ||
}, | ||
"0xFABB0ac9d68B0B445fB7357272Ff202C5651694a": { | ||
"balance": "0xD3C21BCECCEDA1000000" | ||
}, | ||
"0x1CBd3b2770909D4e10f157cABC84C7264073C9Ec": { | ||
"balance": "0xD3C21BCECCEDA1000000" | ||
}, | ||
"0xdF3e18d64BC6A983f673Ab319CCaE4f1a57C7097": { | ||
"balance": "0xD3C21BCECCEDA1000000" | ||
}, | ||
"0xcd3B766CCDd6AE721141F452C550Ca635964ce71": { | ||
"balance": "0xD3C21BCECCEDA1000000" | ||
}, | ||
"0x2546BcD3c84621e976D8185a91A922aE77ECEc30": { | ||
"balance": "0xD3C21BCECCEDA1000000" | ||
}, | ||
"0xbDA5747bFD65F08deb54cb465eB87D40e51B197E": { | ||
"balance": "0xD3C21BCECCEDA1000000" | ||
}, | ||
"0xdD2FD4581271e230360230F9337D5c0430Bf44C0": { | ||
"balance": "0xD3C21BCECCEDA1000000" | ||
}, | ||
"0x8626f6940E2eb28930eFb4CeF49B2d1F2C9C1199": { | ||
"balance": "0xD3C21BCECCEDA1000000" | ||
} | ||
}, | ||
"number": "0x0", | ||
"gasUsed": "0x0", | ||
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.