Ejemplo n.º 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']
Ejemplo n.º 2
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