Testnet2 test fixes (#870)

* use dev genesis for automated tests

* never test block time on automated tests

* automated genesis block creation
This commit is contained in:
Yeastplume 2018-03-26 12:07:04 +01:00 committed by GitHub
parent 327293d28e
commit 6f264b2f7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 4 deletions

View file

@ -237,8 +237,10 @@ fn validate_header(header: &BlockHeader, ctx: &mut BlockContext) -> Result<(), E
return Err(Error::InvalidBlockVersion(header.version)); return Err(Error::InvalidBlockVersion(header.version));
} }
// TODO: remove CI check from here somehow
if header.timestamp if header.timestamp
> time::now_utc() + time::Duration::seconds(12 * (consensus::BLOCK_TIME_SEC as i64)) > time::now_utc() + time::Duration::seconds(12 * (consensus::BLOCK_TIME_SEC as i64))
&& !global::is_automated_testing_mode()
{ {
// refuse blocks more than 12 blocks intervals in future (as in bitcoin) // refuse blocks more than 12 blocks intervals in future (as in bitcoin)
// TODO add warning in p2p code if local time is too different from peers // TODO add warning in p2p code if local time is too different from peers

View file

@ -84,9 +84,10 @@ listener automatically on start.
# Configuration # Configuration
Grin has a good defaults, a configuration file `grin.toml` that's documented Grin attempts to run with sensible defaults, and can be further configured via
inline that can override the defaults, and command line switches that has top the `grin.toml` file. You should always ensure that this file is available to grin.
priority and overrides all others. The supplied `grin.toml` contains inline documentation on all configuration
options, and should be the first point of reference for all options.
The `grin.toml` file can placed in one of several locations, using the first one it finds: The `grin.toml` file can placed in one of several locations, using the first one it finds:
@ -94,6 +95,10 @@ The `grin.toml` file can placed in one of several locations, using the first one
2. In the directory that holds the grin executable 2. In the directory that holds the grin executable
3. {USER_HOME}/.grin 3. {USER_HOME}/.grin
While it's recommended that you perform all grin server configuration via
`grin.toml`, it's also possible to supply command line switches to grin that
override any settings in the `grin.toml` file.
For help on grin commands and their switches, try: For help on grin commands and their switches, try:
``` ```

View file

@ -100,6 +100,7 @@ impl Server {
let genesis = match config.chain_type { let genesis = match config.chain_type {
global::ChainTypes::Testnet1 => genesis::genesis_testnet1(), global::ChainTypes::Testnet1 => genesis::genesis_testnet1(),
global::ChainTypes::Testnet2 => genesis::genesis_testnet2(), global::ChainTypes::Testnet2 => genesis::genesis_testnet2(),
global::ChainTypes::AutomatedTesting => genesis::genesis_dev(),
_ => pow::mine_genesis_block(config.mining_config.clone())?, _ => pow::mine_genesis_block(config.mining_config.clone())?,
}; };
info!(LOGGER, "Starting server, genesis block: {}", genesis.hash(),); info!(LOGGER, "Starting server, genesis block: {}", genesis.hash(),);

View file

@ -86,7 +86,7 @@ pub fn mine_genesis_block(
miner_config: Option<types::MinerConfig>, miner_config: Option<types::MinerConfig>,
) -> Result<core::core::Block, Error> { ) -> Result<core::core::Block, Error> {
let mut gen = genesis::genesis_testnet2(); let mut gen = genesis::genesis_testnet2();
if global::is_user_testing_mode() { if global::is_user_testing_mode() || global::is_automated_testing_mode() {
gen = genesis::genesis_dev(); gen = genesis::genesis_dev();
gen.header.timestamp = time::now(); gen.header.timestamp = time::now();
} }