Merge pull request #1755 from yeastplume/t4-test-fix-1

fix tests, update new genesis block, change p2p header magic number
This commit is contained in:
hashmap 2018-10-16 11:57:27 +02:00 committed by GitHub
commit 5bcc4508fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View file

@ -111,11 +111,11 @@ pub fn genesis_testnet4() -> core::Block {
core::Block::with_header(core::BlockHeader { core::Block::with_header(core::BlockHeader {
height: 0, height: 0,
previous: core::hash::Hash([0xff; 32]), previous: core::hash::Hash([0xff; 32]),
timestamp: Utc.ymd(2018, 10, 15).and_hms(12, 0, 0), timestamp: Utc.ymd(2018, 10, 16).and_hms(9, 0, 0),
pow: ProofOfWork { pow: ProofOfWork {
total_difficulty: Difficulty::from_num(global::initial_block_difficulty()), total_difficulty: Difficulty::from_num(global::initial_block_difficulty()),
scaling_difficulty: 1, scaling_difficulty: 1,
nonce: 4956988373127691, nonce: 4956988373127692,
proof: Proof::new(vec![ proof: Proof::new(vec![
0xa420dc, 0xc8ffee, 0x10e433e, 0x1de9428, 0x2ed4cea, 0x52d907b, 0x5af0e3f, 0xa420dc, 0xc8ffee, 0x10e433e, 0x1de9428, 0x2ed4cea, 0x52d907b, 0x5af0e3f,
0x6b8fcae, 0x8319b53, 0x845ca8c, 0x8d2a13e, 0x8d6e4cc, 0x9349e8d, 0xa7a33c5, 0x6b8fcae, 0x8319b53, 0x845ca8c, 0x8d2a13e, 0x8d6e4cc, 0x9349e8d, 0xa7a33c5,

View file

@ -408,17 +408,17 @@ fn next_target_adjustment() {
let diff_one = Difficulty::one(); let diff_one = Difficulty::one();
assert_eq!( assert_eq!(
next_difficulty(1, vec![HeaderInfo::from_ts_diff(cur_time, diff_one)]), next_difficulty(1, vec![HeaderInfo::from_ts_diff(cur_time, diff_one)]),
HeaderInfo::from_diff_scaling(Difficulty::one(), 4), HeaderInfo::from_diff_scaling(Difficulty::one(), 2),
); );
assert_eq!( assert_eq!(
next_difficulty(1, vec![HeaderInfo::new(cur_time, diff_one, 10, true)]), next_difficulty(1, vec![HeaderInfo::new(cur_time, diff_one, 10, true)]),
HeaderInfo::from_diff_scaling(Difficulty::one(), 4), HeaderInfo::from_diff_scaling(Difficulty::one(), 2),
); );
let mut hi = HeaderInfo::from_diff_scaling(diff_one, 1); let mut hi = HeaderInfo::from_diff_scaling(diff_one, 1);
assert_eq!( assert_eq!(
next_difficulty(1, repeat(60, hi.clone(), DIFFICULTY_ADJUST_WINDOW, None)), next_difficulty(1, repeat(60, hi.clone(), DIFFICULTY_ADJUST_WINDOW, None)),
HeaderInfo::from_diff_scaling(Difficulty::one(), 4), HeaderInfo::from_diff_scaling(Difficulty::one(), 2),
); );
hi.is_secondary = true; hi.is_secondary = true;
assert_eq!( assert_eq!(
@ -520,7 +520,7 @@ fn secondary_pow_scale() {
// becomes easier to find a high difficulty block // becomes easier to find a high difficulty block
assert_eq!( assert_eq!(
secondary_pow_scaling(1, &(0..window).map(|_| hi.clone()).collect()), secondary_pow_scaling(1, &(0..window).map(|_| hi.clone()).collect()),
400 200
); );
// all secondary on 90%, factor should lose 10% // all secondary on 90%, factor should lose 10%
hi.is_secondary = true; hi.is_secondary = true;
@ -531,7 +531,7 @@ fn secondary_pow_scale() {
// all secondary on 1%, should be divided by 4 (max adjustment) // all secondary on 1%, should be divided by 4 (max adjustment)
assert_eq!( assert_eq!(
secondary_pow_scaling(890_000, &(0..window).map(|_| hi.clone()).collect()), secondary_pow_scaling(890_000, &(0..window).map(|_| hi.clone()).collect()),
25 50
); );
// same as above, testing lowest bound // same as above, testing lowest bound
let mut low_hi = HeaderInfo::from_diff_scaling(Difficulty::from_num(10), 3); let mut low_hi = HeaderInfo::from_diff_scaling(Difficulty::from_num(10), 3);
@ -572,7 +572,7 @@ fn secondary_pow_scale() {
.chain((0..(window * 4 / 10)).map(|_| hi.clone())) .chain((0..(window * 4 / 10)).map(|_| hi.clone()))
.collect() .collect()
), ),
112 100
); );
} }

View file

@ -35,7 +35,7 @@ pub const PROTOCOL_VERSION: u32 = 1;
pub const USER_AGENT: &'static str = concat!("MW/Grin ", env!("CARGO_PKG_VERSION")); pub const USER_AGENT: &'static str = concat!("MW/Grin ", env!("CARGO_PKG_VERSION"));
/// Magic number expected in the header of every message /// Magic number expected in the header of every message
const MAGIC: [u8; 2] = [0x1e, 0xc5]; const MAGIC: [u8; 2] = [0x47, 0x31];
/// Size in bytes of a message header /// Size in bytes of a message header
pub const HEADER_LEN: u64 = 11; pub const HEADER_LEN: u64 = 11;