Exemple #1
0
def test_set_custom_network():
    epoch_time = datetime(2017, 1, 1, 13, 00, 00)
    set_custom_network(epoch_time, 11, 130)
    result = get_network()
    assert result['version'] == 11
    assert result['wif'] == 130
    assert result['epoch'] == epoch_time
    set_network(Devnet)  # set back to devnet so other tests don't fail
Exemple #2
0
def generate_passphrases(p_count, possible_words, desired_address, quit,
                         found):
    set_network(Mainnet)
    calculations_counter = 0
    milestone = 0
    print('Processes {} started.'.format(p_count))

    if not quit.is_set():
        for words in itertools.product(*possible_words):
            if quit.is_set():
                break
            passphrase = " ".join(words)
            if p_count == 0:
                calculations_counter += 1
                if calculations_counter - milestone >= 200000:
                    print("{} calculations complete on each process".format(
                        calculations_counter))
                    milestone = calculations_counter
            if address_from_passphrase(passphrase) == desired_address:
                print('Passphrase found: {}'.format(passphrase))
                found.set()
                break
        print('Processes {} closed.'.format(p_count))
Exemple #3
0
def test_set_network():
    # test main net
    set_network(Mainnet)
    result = get_network()
    assert result['version'] == 23
    assert result['wif'] == 170
    # test test net
    set_network(Testnet)
    result = get_network()
    assert result['version'] == 23
    assert result['wif'] == 186
    set_network(Devnet)  # set back to devnet so other tests don't fail
Exemple #4
0
from crypto.configuration.network import set_network
from crypto.constants import TRANSACTION_HTLC_LOCK, TRANSACTION_TYPE_GROUP
from crypto.networks.devnet import Devnet
from crypto.transactions.builder.htlc_lock import HtlcLock
import pytest

set_network(Devnet)


def test_htlc_lock_transation_amount_not_int():
    with pytest.raises(ValueError):
        """Test error handling in constructor for non-integer amount
        """
        HtlcLock(
            recipient_id='AGeYmgbg2LgGxRW2vNNJvQ88PknEJsYizC',
            amount='bad amount number',
            secret_hash=
            '0f128d401958b1b30ad0d10406f47f9489321017b4614e6cb993fc63913c5454',
            expiration_type=1,
            expiration_value=1573455822)


def test_htlc_lock_transation_amount_zero():
    with pytest.raises(ValueError):
        """Test error handling in constructor for non-integer amount
        """
        HtlcLock(
            recipient_id='AGeYmgbg2LgGxRW2vNNJvQ88PknEJsYizC',
            amount=0,
            secret_hash=
            '0f128d401958b1b30ad0d10406f47f9489321017b4614e6cb993fc63913c5454',
Exemple #5
0
def test_set_network():
    set_network(Mainnet)
    result = get_network()
    assert result['version'] == 23
    set_network(Devnet)  # set back to devnet so other tests don't fail