Beispiel #1
0
def test_mining_doesnt_always_return_the_same_value():
    easy_difficulty1 = int_to_bytes(int(2**256 * 0.999))
    # 1 in 1000 difficulty
    easy_difficulty2 = int_to_bytes(int(2**256 * 0.001))
    assert easy_difficulty1 != easy_difficulty2
    cache = pyethash.mkcache_bytes(
              1024,
              "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
    full_size = 1024 * 32
    header = "~~~~~X~~~~~~~~~~~~~~~~~~~~~~~~~~"
    dataset = pyethash.calc_dataset_bytes(full_size, cache)
    # Check type of outputs
    assert pyethash.mine(dataset, header, easy_difficulty1)['nonce'] != pyethash.mine(dataset, header, easy_difficulty2)['nonce']
Beispiel #2
0
def test_mining_doesnt_always_return_the_same_value():
    easy_difficulty1 = int_to_bytes(int(2**256 * 0.999))
    # 1 in 1000 difficulty
    easy_difficulty2 = int_to_bytes(int(2**256 * 0.001))
    assert easy_difficulty1 != easy_difficulty2
    cache = pyethash.mkcache_bytes(1024, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
    full_size = 1024 * 32
    header = "~~~~~X~~~~~~~~~~~~~~~~~~~~~~~~~~"
    dataset = pyethash.calc_dataset_bytes(full_size, cache)
    # Check type of outputs
    assert pyethash.mine(dataset, header,
                         easy_difficulty1)['nonce'] != pyethash.mine(
                             dataset, header, easy_difficulty2)['nonce']
Beispiel #3
0
def test_light_and_full_agree():
    cache = pyethash.mkcache_bytes(1024, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
    full_size = 1024 * 32
    header = "~~~~~X~~~~~~~~~~~~~~~~~~~~~~~~~~"
    light_result = pyethash.hashimoto_light(full_size, cache, header, 0)
    dataset = pyethash.calc_dataset_bytes(full_size, cache)
    full_result = pyethash.hashimoto_full(dataset, header, 0)
    assert light_result["mix digest"] != None
    assert len(light_result["mix digest"]) == 32
    assert light_result["mix digest"] == full_result["mix digest"]
    assert light_result["result"] != None
    assert len(light_result["result"]) == 32
    assert light_result["result"] == full_result["result"]
Beispiel #4
0
def test_mining_basic():
    easy_difficulty = int_to_bytes(2**256 - 1)
    assert easy_difficulty.encode('hex') == 'f' * 64
    cache = pyethash.mkcache_bytes(
              1024,
              "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
    full_size = 1024 * 32
    header = "~~~~~X~~~~~~~~~~~~~~~~~~~~~~~~~~"
    dataset = pyethash.calc_dataset_bytes(full_size, cache)
    # Check type of outputs
    assert type(pyethash.mine(dataset,header,easy_difficulty)) == dict
    assert type(pyethash.mine(dataset,header,easy_difficulty)["nonce"]) == long
    assert type(pyethash.mine(dataset,header,easy_difficulty)["mix digest"]) == str
    assert type(pyethash.mine(dataset,header,easy_difficulty)["result"]) == str
Beispiel #5
0
def test_light_and_full_agree():
    cache = pyethash.mkcache_bytes(
              1024,
              "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
    full_size = 1024 * 32
    header = "~~~~~X~~~~~~~~~~~~~~~~~~~~~~~~~~"
    light_result = pyethash.hashimoto_light(full_size, cache, header, 0)
    dataset = pyethash.calc_dataset_bytes(full_size, cache)
    full_result = pyethash.hashimoto_full(dataset, header, 0)
    assert light_result["mix digest"] != None
    assert len(light_result["mix digest"]) == 32
    assert light_result["mix digest"] == full_result["mix digest"]
    assert light_result["result"] != None
    assert len(light_result["result"]) == 32
    assert light_result["result"] == full_result["result"]
Beispiel #6
0
def test_mining_basic():
    easy_difficulty = int_to_bytes(2**256 - 1)
    assert easy_difficulty.encode('hex') == 'f' * 64
    cache = pyethash.mkcache_bytes(1024, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
    full_size = 1024 * 32
    header = "~~~~~X~~~~~~~~~~~~~~~~~~~~~~~~~~"
    dataset = pyethash.calc_dataset_bytes(full_size, cache)
    # Check type of outputs
    assert type(pyethash.mine(dataset, header, easy_difficulty)) == dict
    assert type(pyethash.mine(dataset, header,
                              easy_difficulty)["nonce"]) == long
    assert type(pyethash.mine(dataset, header,
                              easy_difficulty)["mix digest"]) == str
    assert type(pyethash.mine(dataset, header,
                              easy_difficulty)["result"]) == str
Beispiel #7
0
def test_calc_dataset_is_not_None():
    cache = pyethash.mkcache_bytes(
              1024,
              "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
    assert pyethash.calc_dataset_bytes(1024 * 32, cache) != None
Beispiel #8
0
def test_calc_dataset_is_not_None():
    cache = pyethash.mkcache_bytes(1024, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
    assert pyethash.calc_dataset_bytes(1024 * 32, cache) != None