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
+1
View File
@@ -170,6 +170,7 @@ mod test {
#[test]
fn cuckaroo19_vectors() {
global::set_local_chain_type(global::ChainTypes::Mainnet);
let mut ctx = new_impl::<u64>(19, 42);
ctx.params.siphash_keys = V1_19_HASH;
assert!(ctx.verify(&Proof::new(V1_19_SOL.to_vec())).is_ok());
+1
View File
@@ -172,6 +172,7 @@ mod test {
#[test]
fn cuckarood19_29_vectors() {
global::set_local_chain_type(global::ChainTypes::Mainnet);
let mut ctx19 = new_impl::<u64>(19, 42);
ctx19.params.siphash_keys = V1_19_HASH;
assert!(ctx19.verify(&Proof::new(V1_19_SOL.to_vec())).is_ok());
+1
View File
@@ -165,6 +165,7 @@ mod test {
#[test]
fn cuckaroom19_29_vectors() {
global::set_local_chain_type(global::ChainTypes::Mainnet);
let mut ctx19 = new_impl::<u64>(19, 42);
ctx19.params.siphash_keys = V1_19_HASH;
assert!(ctx19.verify(&Proof::new(V1_19_SOL.to_vec())).is_ok());
+1
View File
@@ -367,6 +367,7 @@ mod test {
#[test]
fn cuckatoo() {
global::set_local_chain_type(global::ChainTypes::Mainnet);
let ret = basic_solve::<u32>();
if let Err(r) = ret {
panic!("basic_solve u32: Error: {}", r);
+2
View File
@@ -88,10 +88,12 @@ impl Lean {
#[cfg(test)]
mod test {
use super::*;
use crate::global;
use crate::pow::types::PoWContext;
#[test]
fn lean_miner() {
global::set_local_chain_type(global::ChainTypes::Mainnet);
let nonce = 15465723;
let header = [0u8; 84].to_vec(); // with nonce
let edge_bits = 19;
+1
View File
@@ -507,6 +507,7 @@ mod tests {
#[test]
fn test_proof_rw() {
global::set_local_chain_type(global::ChainTypes::Mainnet);
for edge_bits in 10..63 {
let mut proof = Proof::new(gen_proof(edge_bits as u32));
proof.edge_bits = edge_bits;