def test_main_from_json_with_vote_list(): prev_hash = "1" miner = "2" difficulty = "3" mb = MainBlock(prev_hash, miner, difficulty, get_vote_list(10), [], []) mb_copy = main_block.from_json(mb.string(True, False, False)) assert mb.string() == mb_copy.string() assert mb.hash() == mb_copy.hash() assert mb.vote_count == 10 assert mb_copy.vote_count == 10
def test_main_from_json_with_all_lists(): prev_hash = "1" miner = "2" difficulty = "3" mb = MainBlock(prev_hash, miner, difficulty, get_vote_list(10), get_shard_list(10), get_vtx_list(10)) mb_copy = main_block.from_json(mb.string(True, True, True)) assert mb.string() == mb_copy.string() assert mb.string(True, True, True) == mb_copy.string(True, True, True) assert mb.hash() == mb_copy.hash()
def test_main_from_json(): prev_hash = "1" miner = "2" difficulty = "3" mb = MainBlock(prev_hash, miner, difficulty, [], [], []) mb.height = 1 # make sure height is copied time.sleep(1 / 1000) # make sure time is copied mb.nonce = "abcdabcdabcdabcd" # make sure nonce is copied # make sure shard producers are copied mb.next_shard_producers = ["a", "b", "c"] mb_copy = main_block.from_json(mb.string()) assert mb.string() == mb_copy.string() assert mb.hash() == mb_copy.hash()