thread local chain type vs global chain type (#3327)

* Introduce GLOBAL_CHAIN_TYPE and make CHAIN_TYPE thread_local.
This makes testing more explicit and significantly more robust.

* set_local_chain_type() in tests

* cleanup - weird

* get pool tests working with explicit local chain_type config

* core tests working with explicit local chain_type

* p2p tests working with explicit local chain_type

* store tests working

* cleanup, feedback
This commit is contained in:
Antioch Peverell
2020-05-22 12:51:58 +01:00
committed by GitHub
parent 096b6924ce
commit 6faa0e8d75
33 changed files with 192 additions and 114 deletions
+3 -3
View File
@@ -92,7 +92,7 @@ fn main() {
{
// setup a tmp chain to set block header roots
core::global::set_mining_mode(core::global::ChainTypes::UserTesting);
core::global::set_local_chain_type(core::global::ChainTypes::UserTesting);
let tmp_chain = setup_chain(".grin.tmp", core::pow::mine_genesis_block().unwrap());
tmp_chain.set_txhashset_roots(&mut gen).unwrap();
}
@@ -103,7 +103,7 @@ fn main() {
gen.header.prev_root = core::core::hash::Hash::from_hex(&h1).unwrap();
// mine a Cuckaroo29 block
core::global::set_mining_mode(core::global::ChainTypes::Mainnet);
core::global::set_local_chain_type(core::global::ChainTypes::Mainnet);
let plugin_lib = cuckoo::PluginLibrary::new(PLUGIN_PATH).unwrap();
let mut params = plugin_lib.get_default_params();
params.mutate_nonce = false;
@@ -216,7 +216,7 @@ fn update_genesis_rs(gen: &core::core::Block) {
"excess".to_string(),
format!(
"Commitment::from_vec(util::from_hex({:x?}.to_string()).unwrap())",
gen.kernels()[0].excess.to_hex())
gen.kernels()[0].excess.to_hex()
),
));
replacements.push((