def test_blockchain_get_work_required_main(self): # Simply copy previous difficulty if height % TARGET_INTERVAL != 0 main_difficulty_history_46367 = StaticDifficultyHistory({ 46366 : DifficultyIterator.Difficulty(time=1269210928, bits=473464687)}) self.assertEquals(get_work_required(46367, main_difficulty_history_46367, 1269212064, MAIN), 473464687) # Retarget if height % TARGET_INTERVAL == 0 # (block 46368 depends on block times of 44352, 46367 and target of block 46367) main_difficulty_history_46368 = StaticDifficultyHistory({ 44352 : DifficultyIterator.Difficulty(time=1268010873, bits=473464687) , 46367 : DifficultyIterator.Difficulty(time=1269211443, bits=473464687)}) self.assertEquals(get_work_required(46368, main_difficulty_history_46368, 1269212064, MAIN), 473437045)
def test_blockchain_get_work_required_testnet(self): # testnet adjusting algorithm (Min to the proof of work limit) difficulty_history = StaticDifficultyHistory({ 3500: DifficultyIterator.Difficulty(time=1357060298, bits=373464683) }) self.assertEquals( get_work_required(3501, difficulty_history, 1357061499, TESTNET), compact_difficulty(PROOF_OF_WORK_LIMIT[TESTNET]))
def test_blockchain_get_work_required_main(self): # Simply copy previous difficulty if height % TARGET_INTERVAL != 0 main_difficulty_history_46367 = StaticDifficultyHistory({ 46366: DifficultyIterator.Difficulty(time=1269210928, bits=473464687) }) self.assertEquals( get_work_required(46367, main_difficulty_history_46367, 1269212064, MAIN), 473464687) # Retarget if height % TARGET_INTERVAL == 0 # (block 46368 depends on block times of 44352, 46367 and target of block 46367) main_difficulty_history_46368 = StaticDifficultyHistory({ 44352: DifficultyIterator.Difficulty(time=1268010873, bits=473464687), 46367: DifficultyIterator.Difficulty(time=1269211443, bits=473464687) }) self.assertEquals( get_work_required(46368, main_difficulty_history_46368, 1269212064, MAIN), 473437045)
def test_blockchain_get_work_required_testnet(self): # testnet adjusting algorithm (Min to the proof of work limit) difficulty_history = StaticDifficultyHistory({ 3500 : DifficultyIterator.Difficulty(time=1357060298, bits=373464683)}) self.assertEquals(get_work_required(3501, difficulty_history, 1357061499, TESTNET), compact_difficulty(PROOF_OF_WORK_LIMIT[TESTNET]))