Exemple #1
0
def test_sign_verify_good(key_hex: str, pub_key_hex: str,
                          rev_address: str) -> None:
    key = PrivateKey.from_hex(key_hex)
    pub_key = PublicKey.from_hex(pub_key_hex)
    message = 'hello rchain'.encode()
    signature = key.sign(message)
    pub_key.verify(signature, message)
def faucetPost(faucetRequest: FaucetRequest, request: Request):
    address = faucetRequest.address
    ip = ipaddress.ip_address(request.client.host)
    if ip.is_private:
        host = request.headers.get('X-Real-IP')
        if host:
            addr = ipaddress.ip_address(host)
        else:
            addr = request.client.host
    else:
        addr = request.client.host
    request_before = request_faucet_TTCache.get(addr)
    if request_before:
        return FaucetResponse(deployID=request_before[1],
                              message='IP:{}, Your request for testnet rev to {} is too high. Try later'.format(
                                  addr, request_before[0]))
    else:
        try:
            with RClient(setting.TARGET_TESTNET_HOST, setting.TARGET_TESTNET_PORT) as client:
                vault = VaultAPI(client)
                private = PrivateKey.from_hex(setting.TESTNET_FAUCET_PRIVATE_KEY)
                deployId = vault.transfer_ensure(private.get_public_key().get_rev_address(), address,
                                                 setting.TESTNET_FAUCET_AMOUNT, private)
                request_faucet_TTCache[addr] = (address, deployId, request.client.host)
                return FaucetResponse(deployID=deployId,
                                      message="Transfer to your address is done. You will receive the rev in some time")
        except RClientException as e:
            return FaucetResponse(deployID='',
                                  message="There is something with server {}. "
                                          "Please contact the maintainer to solve it.".format(e))
Exemple #3
0
def sign_deploy(private_key: str, term: str, phlo_price: int, phlo_limit: int,
                valid_after_block_number: int, timestamp: int,
                sig_algorithm: str) -> None:
    pri = PrivateKey.from_hex(private_key)
    signed_deploy = create_deploy_data(pri, term, phlo_price, phlo_limit,
                                       valid_after_block_number, timestamp)
    click.echo(signed_deploy.sig.hex())
    def __init__(self, config):
        self.setup_error_log(config['error_logs'])
        logging.info("Initialing dispatcher")
        self._config = config

        self.clients = {}
        for server in config['servers']:
            for host_name, host_config in server.items():
                self.clients[host_name] = init_client(host_name, host_config)

        logging.info("Read the deploying contract {}".format(
            config['deploy']['contract']))
        with open(config['deploy']['contract']) as f:
            self.contract = f.read()
        logging.info("Checking if deploy key is valid.")
        self.deploy_key = PrivateKey.from_hex(config['deploy']['deploy_key'])

        self.phlo_limit = int(config['deploy']['phlo_limit'])
        self.phlo_price = int(config['deploy']['phlo_price'])

        self.wait_timeout = int(config['waitTimeout'])
        self.wait_interval = int(config['waitInterval'])

        self.error_node_records = config['error_node_records']

        self.init_queue()

        self._running = False
def faucet(address: str, request: Request):
    request_before = request_faucet_TTCache.get(request.client.host)
    if request_before:
        return FaucetResponse(
            deployID='',
            message='Your request for testnet rev is too high. Try later.')
    else:
        try:
            with RClient(setting.TARGET_TESTNET_HOST,
                         setting.TARGET_TESTNET_PORT) as client:
                vault = VaultAPI(client)
                private = PrivateKey.from_hex(
                    setting.TESTNET_FAUCET_PRIVATE_KEY)
                deployId = vault.transfer(
                    private.get_public_key().get_rev_address(), address,
                    setting.TESTNET_FAUCET_AMOUNT, private)
                request_faucet_TTCache[request.client.host] = address
                return FaucetResponse(
                    deployID=deployId,
                    message=
                    "Transfer to your address is done. You will receive the rev in some time"
                )
        except RClientException as e:
            return FaucetResponse(
                deployID='',
                message="There is something with server {}. "
                "Please contact the maintainer to solve it.".format(e))
Exemple #6
0
def test_publickey_from_hex(key_hex: str, pub_key_hex: str,
                            rev_address: str) -> None:
    key = PrivateKey.from_hex(key_hex)
    pub_key = PublicKey.from_hex(pub_key_hex)
    expected_pub_key_bytes = key.get_public_key().to_bytes()
    actual_pub_key_bytes = pub_key.to_bytes()
    assert expected_pub_key_bytes == actual_pub_key_bytes
Exemple #7
0
def test_sign_block_hash_verify_good(key_hex: str, pub_key_hex: str,
                                     rev_address: str) -> None:
    key = PrivateKey.from_hex(key_hex)
    pub_key = PublicKey.from_hex(pub_key_hex)
    message = 'hello rchain'.encode()
    digest = blake2b_32(message).digest()
    signature = key.sign_block_hash(digest)
    pub_key.verify_block_hash(signature, digest)
def test_make_wallets_file_lines() -> None:
    wallets_map = {
        PrivateKey.from_hex("80366db5fbb8dad7946f27037422715e4176dda41d582224db87b6c3b783d709"):
        40,
        PrivateKey.from_hex("120d42175739387af0264921bb117e4c4c05fbe2ce5410031e8b158c6e414bb5"):
        45,
        PrivateKey.from_hex("1f52d0bce0a92f5c79f2a88aae6d391ddf853e2eb8e688c5aa68002205f92dad"):
        26
    }

    output = make_wallets_file_lines(wallets_map)

    assert output == [
        '26218db6e5a2eed1901f72cea58fda7ef1f602c6,40,0',
        '42c828c183163cb50f6ad5207a10899b59aae91c,45,0',
        '2a11fd494610330f3b522562f7204670f8928133,26,0',
    ]
Exemple #9
0
def test_sign_verify_bad(key_hex: str, pub_key_hex: str,
                         rev_address: str) -> None:
    key = PrivateKey.from_hex(key_hex)
    pub_key = PublicKey.from_hex(pub_key_hex)
    sign_message = 'hello rchain'.encode()
    verify_message = 'hello world'.encode()
    signature = key.sign(sign_message)
    with pytest.raises(BadSignatureError):
        pub_key.verify(signature, verify_message)
Exemple #10
0
def test_sign_block_hash_verify_bad(key_hex: str, pub_key_hex: str,
                                    rev_address: str) -> None:
    key = PrivateKey.from_hex(key_hex)
    pub_key = PublicKey.from_hex(pub_key_hex)
    sign_message = 'hello rchain'.encode()
    verify_message = 'hello world'.encode()
    block_hash = blake2b_32(sign_message).digest()
    signature = key.sign_block_hash(block_hash)
    verify_digest = blake2b_32(verify_message).digest()
    with pytest.raises(BadSignatureError):
        pub_key.verify_block_hash(signature, verify_digest)
Exemple #11
0
def get_rev_addr(input_type: str, input: str) -> None:
    if input_type == 'eth':
        click.echo(generate_rev_addr_from_eth(input))
    elif input_type == 'public':
        pub = PublicKey.from_hex(input)
        click.echo(pub.get_rev_address())
    elif input_type == 'private':
        private = PrivateKey.from_hex(input)
        click.echo(private.get_public_key().get_rev_address())
    else:
        raise NotImplementedError("Not supported type {}".format(input_type))
def faucetPost(faucetRequest: FaucetRequest, request: Request):
    address = faucetRequest.address
    realIp = request.headers.get('X-Real-IP')
    if realIp:
        addr = ipaddress.ip_address(realIp)
    else:
        addr = request.client.host
    request_before = request_faucet_TTCache.get(addr)
    if request_before:
        return FaucetResponse(
            deployID=request_before[1],
            message=
            'IP:{}, Your request for testnet rev to {} is too high. Try later'.
            format(addr, request_before[0]))
    else:
        try:
            with RClient(setting.TARGET_TESTNET_HOST,
                         setting.TARGET_TESTNET_PORT) as client:
                private = PrivateKey.from_hex(
                    setting.TESTNET_FAUCET_PRIVATE_KEY)
                contract = render_contract_template(
                    TRANSFER_ENSURE_TO_RHO_TPL, {
                        'from': private.get_public_key().get_rev_address(),
                        'to': address,
                        'amount': str(setting.TESTNET_FAUCET_AMOUNT)
                    })
                timestamp_mill = int(time.time() * 1000)
                deployId = client.deploy_with_vabn_filled(
                    private, contract, TRANSFER_PHLO_PRICE,
                    TRANSFER_PHLO_LIMIT, timestamp_mill,
                    setting.TESTNET_FAUCET_SHARDID)
                request_faucet_TTCache[addr] = (address, deployId,
                                                request.client.host)
                return FaucetResponse(
                    deployID=deployId,
                    message=
                    "Transfer to your address is done. You will receive the rev in some time"
                )
        except RClientException as e:
            return FaucetResponse(
                deployID='',
                message="There is something with server {}. "
                "Please contact the maintainer to solve it.".format(e))
Exemple #13
0
#!/usr/bin/python

import time

from rchain.client import RClient
from rchain.crypto import PrivateKey

from pyrgov.rgov import rgovAPI

RCHAIN_SERVER = ['localhost', 'rhobot']

admin = PrivateKey.from_hex(
    '28a5c9ac133b4449ca38e9bdf7cacdce31079ef6b3ac2f0a080af83ecff98b36')
alpha = PrivateKey.from_hex(
    '7139b72b9939334ff76e1479072c0558dca2c3620971c2bb233a7b25a690d610')
bravo = PrivateKey.from_hex(
    'dd0dd23cd51460e6c42a154623df19372be332f0a61a51755603ab897f6ede39')
#alpha = PrivateKey.generate()
#bravo = PrivateKey.generate()
charlie = PrivateKey.generate()


def print_balances(rgov: rgovAPI):
    # get balance of vault
    admin_balance = rgov.checkBalance(admin.get_public_key().get_rev_address())
    print("admin Balance ", admin_balance, " REV ",
          admin.get_public_key().get_rev_address())
    charlie_balance = rgov.checkBalance(
        charlie.get_public_key().get_rev_address())
    print("charlie Balance ", charlie_balance, " REV ",
          charlie.get_public_key().get_rev_address())
Exemple #14
0
from .conftest import (
    testing_context, )
from .rnode import (
    Node,
    started_bootstrap_with_network,
)
from .common import (
    TestingContext,
    TransderFundsError,
)
from .wait import (wait_for_log_match_result, wait_for_log_match_result_raise,
                   wait_for_approved_block_received_handler_state,
                   WaitTimeoutError)

ALICE_KEY = PrivateKey.from_hex(
    "b2527b00340a83e302beae2a8daf6d654e8e57541acfa261cc1b5635eb16aa15")
BOB_KEY = PrivateKey.from_hex(
    "9a801debae8bb97fe54c99389cafa576c60612503348578125b65ab182ff5850")
CHARLIE_KEY = PrivateKey.from_hex(
    "567ea426deaeb8233f134c3a266149fb196d6eea7d28b447dfefff92002cb400")


def wait_transfer_result(context: TestingContext, node: Node,
                         transfer_funds_result_pattern: Pattern) -> None:
    transfer_result_match = wait_for_log_match_result_raise(
        context, node, transfer_funds_result_pattern)
    reason = transfer_result_match.group('reason')
    if reason != "Nil":
        raise TransderFundsError(reason)

Exemple #15
0
# Requires the following line in wallets.txt
#
# 0x06a441c277bf454c5d159b0e5bdafca69b296733,1000000,0

import grpc

from rchain.crypto import PrivateKey
from rchain.client import RClient

from rchain.vault import VaultAPI

alice_key = PrivateKey.from_hex(
    "2a6cd3b196a0b154446a23443cee70629cdb3db0398ea6fb099175708f47f590")
alice_public_key = alice_key.get_public_key()

print("Private key is " + alice_key.to_hex())
print("Public key is " + alice_public_key.to_hex())
print("Eth address is " + alice_public_key.get_eth_address())
print("Rev address is " + alice_public_key.get_rev_address())

with grpc.insecure_channel('localhost:10401') as channel:
    client = RClient(channel)

    alice_vault_api = VaultAPI(client, alice_key)
    alice_vault_api.bond(amount=100)

    alice_bal_deploy_id = alice_vault_api.deploy_get_balance()
    client.propose()

    alice_bal = alice_vault_api.get_balance_from_deploy_id(alice_bal_deploy_id)
    assert alice_bal == 999900
Exemple #16
0
from .common import (
    CommandLineOptions,
)
from .rnode import (
    started_peer,
    started_bootstrap_with_network,
)
from .wait import (
    wait_for_block_approval,
    wait_for_approved_block_received_handler_state,
    wait_for_sent_approved_block,
)



CEREMONY_MASTER_KEYPAIR = PrivateKey.from_hex("80366db5fbb8dad7946f27037422715e4176dda41d582224db87b6c3b783d709")
VALIDATOR_A_KEYPAIR = PrivateKey.from_hex("120d42175739387af0264921bb117e4c4c05fbe2ce5410031e8b158c6e414bb5")
VALIDATOR_B_KEYPAIR = PrivateKey.from_hex("1f52d0bce0a92f5c79f2a88aae6d391ddf853e2eb8e688c5aa68002205f92dad")
VALIDATOR_C_KEYPAIR = PrivateKey.from_hex("5322dbb1828bdb44cb3275d35672bb3453347ee249a1f32d3c035e5ec3bfad1a")
READONLY_A_KEYPAIR = PrivateKey.from_hex("632a21e0176c4daed1ca78f08f98885f61d2050e0391e31eae59ff1a35ccca7f")


def test_successful_genesis_ceremony(command_line_options: CommandLineOptions, random_generator: Random, docker_client: DockerClient) -> None:
    """
    https://docs.google.com/document/d/1Z5Of7OVVeMGl2Fw054xrwpRmDmKCC-nAoIxtIIHD-Tc/
    """
    bootstrap_cli_options = {
        '--deploy-timestamp'   : '1',
        '--required-signatures': '2',
        '--approve-duration'   : '1min',
        '--approve-interval'   : '10sec',
Exemple #17
0
#!/usr/bin/python

import time

from rchain.client import RClient
from rchain.crypto import PrivateKey
from rchain.util import create_deploy_data

from pyrgov.rgov import rgovAPI

RCHAIN_SERVER = ['localhost', 'rhobot', 'testnet', 'demo', 'mainnet']

TRANSFER_PHLO_LIMIT = 10000000
TRANSFER_PHLO_PRICE = 1

admin = PrivateKey.from_hex('28a5c9ac133b4449ca38e9bdf7cacdce31079ef6b3ac2f0a080af83ecff98b36')
alpha = PrivateKey.from_hex('7139b72b9939334ff76e1479072c0558dca2c3620971c2bb233a7b25a690d610')
bravo = PrivateKey.from_hex('dd0dd23cd51460e6c42a154623df19372be332f0a61a51755603ab897f6ede39')
charlie = PrivateKey.from_hex('79cf7604de08deee525ac9f500e118eef6036c56b175adf5afac94bb9542c5c1')

def print_balances(rgov: rgovAPI):
    # get balance of vault
    admin_balance = rgov.checkBalance(admin.get_public_key().get_rev_address())
    print("admin Balance ", admin_balance, " REV ", admin.get_public_key().get_rev_address())
    bravo_balance = rgov.checkBalance(bravo.get_public_key().get_rev_address())
    print("bravo Balance ", bravo_balance, " REV ", bravo.get_public_key().get_rev_address())


rgov = rgovAPI(RCHAIN_SERVER[0])

result = rgov.newInbox(alpha)
Exemple #18
0
    'node1.root-shard.mainnet.rchain.coop',
    'node2.root-shard.mainnet.rchain.coop',
    'node3.root-shard.mainnet.rchain.coop',
    'node4.root-shard.mainnet.rchain.coop',
    'node5.root-shard.mainnet.rchain.coop',
    'node6.root-shard.mainnet.rchain.coop',
    'node7.root-shard.mainnet.rchain.coop',
    'node8.root-shard.mainnet.rchain.coop'
]
READONLY_SERVER = [
    'observer-asia.services.mainnet.rchain.coop',
    'observer-us.services.mainnet.rchain.coop',
    'observer-eu.services.mainnet.rchain.coop'
]

alice = PrivateKey.from_hex(
    '61e594124ca6af84a5468d98b34a4f3431ef39c54c6cf07fe6fbf8b079ef64f6')
bob = PrivateKey.generate()

exploratory_term = 'new return in{return!("a")}'

with RClient(READONLY_SERVER[0], 40401) as client:
    vault = VaultAPI(client)
    # get the balance of a vault
    # get balance can only perform in the read-only node
    bob_balance = vault.get_balance(bob.get_public_key().get_rev_address())

with RClient(MAINNET_SERVER[0], 40401) as client:
    # because transfer need a valid deploy
    # the transfer need the private to perform signing
    vault = VaultAPI(client)
    deployId = vault.transfer(alice.get_public_key().get_rev_address(),
import grpc
import logging
import sys
from rchain.crypto import PrivateKey
from rchain.client import RClient
import time
import subprocess

root = logging.getLogger()
root.setLevel(logging.DEBUG)

config_path = str(sys.argv[3])

with grpc.insecure_channel('localhost:40401') as channel:
    client = RClient(channel)
    with open(sys.argv[2]) as file:
        data = file.read()
        start_time = time.time()
        client.deploy_with_vabn_filled(PrivateKey.from_hex(sys.argv[1]), data,
                                       1, 1000000000)
        dur = time.time() - start_time
        subprocess.run([
            'python3', 'reportInfluxDBMetric.py', 'pyrchain.deploytime',
            str(dur), config_path
        ])
import pytest

from rchain.crypto import PrivateKey
from . import conftest
from .common import (
    CommandLineOptions,
    SynchronyConstraintError,
)
from .rnode import (
    bootstrap_connected_peer,
    ready_bootstrap_with_network,
)
from .wait import (
    wait_for_node_sees_block, )

BOOTSTRAP_NODE_KEYS = PrivateKey.from_hex(
    "80366db5fbb8dad7946f27037422715e4176dda41d582224db87b6c3b783d709")
BONDED_VALIDATOR_KEY_1 = PrivateKey.from_hex(
    "120d42175739387af0264921bb117e4c4c05fbe2ce5410031e8b158c6e414bb5")
BONDED_VALIDATOR_KEY_2 = PrivateKey.from_hex(
    "f7bfb2b3f2be909dd50beac05bece5940b1e7266816d7294291a2ff66a5d660b")
BONDED_VALIDATOR_KEY_3 = PrivateKey.from_hex(
    "2b173084083291ac6850cb734dffb69dfcb280aeb152f0d5be979bea7827c03a")


def test_synchrony_constraint(command_line_options: CommandLineOptions,
                              random_generator: Random,
                              docker_client: DockerClient) -> None:
    """
    Create a network with 4 validators.

    Validator config situation:
Exemple #21
0
from random import Random
import os
import re
from docker.client import DockerClient
from rchain.crypto import PrivateKey

from .common import (
    CommandLineOptions,
    random_string,
)

from .conftest import testing_context
from .rnode import ready_bootstrap_with_network
from .wait import wait_for_log_match

USER_KEY = PrivateKey.from_hex(
    "3596e2e5fd14b24a6d84af04b7f0a8f13e3e68ee2ca91dc4b19550f12e61502c")


def test_data_is_stored_and_served_by_node(
        command_line_options: CommandLineOptions, docker_client: DockerClient,
        random_generator: Random) -> None:
    wallets_map = {USER_KEY: 100000000}
    with testing_context(command_line_options,
                         random_generator,
                         docker_client,
                         wallets_dict=wallets_map) as context:
        with ready_bootstrap_with_network(context=context) as bootstrap_node:
            store_data_contract = os.path.join('resources/storage',
                                               "store-data.rho")
            read_data_contract = os.path.join('resources/storage',
                                              "read-data.rho")
Exemple #22
0
from random import Random
from typing import Generator

import pytest
from rchain.crypto import PrivateKey
from docker.client import DockerClient

from .common import CommandLineOptions
from .conftest import testing_context
from .rnode import (SynchronyConstraintError, started_bootstrap_with_network,
                    started_peer)
from .test_wallets import get_vault_balance
from .wait import (wait_for_approved_block_received_handler_state,
                   wait_for_peers_count_at_least)

CEREMONY_MASTER_PRIVATE = PrivateKey.from_hex(
    "80366db5fbb8dad7946f27037422715e4176dda41d582224db87b6c3b783d709")
VALIDATOR_A_PRIVATE = PrivateKey.from_hex(
    "120d42175739387af0264921bb117e4c4c05fbe2ce5410031e8b158c6e414bb5")
VALIDATOR_B_PRIVATE = PrivateKey.from_hex(
    "1f52d0bce0a92f5c79f2a88aae6d391ddf853e2eb8e688c5aa68002205f92dad")


@contextlib.contextmanager
def temp_rnode_data() -> Generator[str, None, None]:
    with tempfile.TemporaryDirectory() as temp_dir:
        with tarfile.open('resources/rnode_data/bootstrap') as tar:
            tar.extractall(os.path.join(temp_dir, 'bootstrap'))
        with tarfile.open('resources/rnode_data/validatorA') as tar:
            tar.extractall(os.path.join(temp_dir, 'validatorA'))
        with tarfile.open('resources/rnode_data/validatorB') as tar:
            tar.extractall(os.path.join(temp_dir, 'validatorB'))
Exemple #23
0
from docker.client import DockerClient

from rchain.crypto import PrivateKey
from rchain.pb.DeployServiceCommon_pb2 import BlockInfo
from . import conftest
from .common import (CommandLineOptions, NotAnActiveValidatorError)
from .rnode import (
    bootstrap_connected_peer,
    ready_bootstrap_with_network,
)
from .wait import (
    wait_for_node_sees_block, )

from .test_wallets import get_vault_balance

BOOTSTRAP_KEY = PrivateKey.from_hex(
    "b2527b00340a83e302beae2a8daf6d654e8e57541acfa261cc1b5635eb16aa15")
VALIDATOR_KEY_1 = PrivateKey.from_hex(
    "9a801debae8bb97fe54c99389cafa576c60612503348578125b65ab182ff5850")
VALIDATOR_KEY_2 = PrivateKey.from_hex(
    "2bdedd2e4dd2e7b5f176b7a5bc155f10fafd3fbd9c03fb7556f2ffd22c786f8b")
VALIDATOR_KEY_3 = PrivateKey.from_hex(
    "632a21e0176c4daed1ca78f08f98885f61d2050e0391e31eae59ff1a35ccca7f")


def get_total_cost_from_block(block_info: BlockInfo) -> int:
    """get the total costs in the block"""
    total_cost = 0
    for deploy in block_info.deploys:
        total_cost += deploy.cost
    return total_cost
from random import Random
import pytest
from rchain.crypto import PrivateKey
from docker.client import DockerClient

from . import conftest
from .common import (
    CommandLineOptions, )
from .rnode import (ready_bootstrap_with_network)

BOOTSTRAP_NODE_KEYS = PrivateKey.from_hex(
    "80366db5fbb8dad7946f27037422715e4176dda41d582224db87b6c3b783d709")
BONDED_VALIDATOR_KEY_1 = PrivateKey.from_hex(
    "120d42175739387af0264921bb117e4c4c05fbe2ce5410031e8b158c6e414bb5")


def test_deploy_with_not_enough_phlo(command_line_options: CommandLineOptions,
                                     random_generator: Random,
                                     docker_client: DockerClient) -> None:
    genesis_vault = {
        BOOTSTRAP_NODE_KEYS: 500000000000,
        BONDED_VALIDATOR_KEY_1: 500000000000,
    }

    with conftest.testing_context(command_line_options, random_generator, docker_client,
                                  wallets_dict=genesis_vault) as context, \
            ready_bootstrap_with_network(context=context, synchrony_constraint_threshold=0) as bootstrap_node:
        contract = "/opt/docker/examples/tut-hello.rho"
        # deploy with not enough phlo
        bootstrap_node.deploy(contract,
                              BOOTSTRAP_NODE_KEYS,
from docker.client import DockerClient

from . import conftest
from .common import CommandLineOptions
from .wait import (
    wait_for_node_sees_block,
    wait_for_peers_count_at_least,
    wait_for_block_finalized,
)
from .rnode import (
    bootstrap_connected_peer,
    ready_bootstrap_with_network,
)


BOOTSTRAP_NODE_KEY = PrivateKey.from_hex("ff2ba092524bafdbc85fa0c7eddb2b41c69bc9bf066a4711a8a16f749199e5be")
BONDED_VALIDATOR_KEY_1 = PrivateKey.from_hex("597623f0b50e82008d52644983699724538b4307efbe3d0b992c651ca7f860c8")
BONDED_VALIDATOR_KEY_2 = PrivateKey.from_hex("9a32ff7b7c6e25527e0b4e5bec70596c6094e6529d56bf61cbd1ca26d3e92b10")
BONDED_VALIDATOR_KEY_3 = PrivateKey.from_hex("af47862137d4e772f540029ae73ee01443c61288f3df9307a13d681de6ad2de4")
BONDED_VALIDATOR_KEY_4 = PrivateKey.from_hex("2a6018851984203e0983f0671e94fcf649ec04b614e5924f435081f7d1e3b44b")



def test_finalizes_block(command_line_options: CommandLineOptions, random_generator: Random, docker_client: DockerClient) -> None:
    """
    ^
    |
    |                               b7=-1.0
    |                                                   b6=-1.0
    |                               b5=-1.0
    |           b4=0.2631579
from rchain.crypto import PrivateKey

PREGENERATED_KEYPAIRS = [
    PrivateKey.from_hex(
        "80366db5fbb8dad7946f27037422715e4176dda41d582224db87b6c3b783d709"),
    PrivateKey.from_hex(
        "120d42175739387af0264921bb117e4c4c05fbe2ce5410031e8b158c6e414bb5"),
    PrivateKey.from_hex(
        "1f52d0bce0a92f5c79f2a88aae6d391ddf853e2eb8e688c5aa68002205f92dad"),
    PrivateKey.from_hex(
        "5322dbb1828bdb44cb3275d35672bb3453347ee249a1f32d3c035e5ec3bfad1a"),
    PrivateKey.from_hex(
        "632a21e0176c4daed1ca78f08f98885f61d2050e0391e31eae59ff1a35ccca7f"),
    PrivateKey.from_hex(
        "2bdedd2e4dd2e7b5f176b7a5bc155f10fafd3fbd9c03fb7556f2ffd22c786f8b"),
    PrivateKey.from_hex(
        "ff2ba092524bafdbc85fa0c7eddb2b41c69bc9bf066a4711a8a16f749199e5be")
]
Exemple #27
0
def test_privatekey_function(key_hex: str, pub_key_hex: str,
                             rev_address: str) -> None:
    key = PrivateKey.from_hex(key_hex)
    pub_key = key.get_public_key()
    actual_pub_key_hex = pub_key.to_bytes().hex()
    assert pub_key_hex == actual_pub_key_hex
from . import conftest
from .common import (
    CommandLineOptions,
    NonZeroExitCodeError,
)
from .rnode import (
    bootstrap_connected_peer,
    ready_bootstrap_with_network,
)

from .wait import (wait_for_node_sees_block, wait_for_peers_count_at_least,
                   wait_for_approved_block_received_handler_state)

from .test_wallets import get_vault_balance

BOOTSTRAP_KEY = PrivateKey.from_hex(
    "b2527b00340a83e302beae2a8daf6d654e8e57541acfa261cc1b5635eb16aa15")
BONDED_VALIDATOR_KEY = PrivateKey.from_hex(
    "9a801debae8bb97fe54c99389cafa576c60612503348578125b65ab182ff5850")
JOINING_VALIDATOR_KEY = PrivateKey.from_hex(
    "567ea426deaeb8233f134c3a266149fb196d6eea7d28b447dfefff92002cb400")
READONLY_PEER_KEY = PrivateKey.from_hex(
    "3596e2e5fd14b24a6d84af04b7f0a8f13e3e68ee2ca91dc4b19550f12e61502c")


def test_bonding_validators(command_line_options: CommandLineOptions,
                            random_generator: Random,
                            docker_client: DockerClient) -> None:
    genesis_vault = {
        BOOTSTRAP_KEY: 50000000,
        BONDED_VALIDATOR_KEY: 50000000,
        JOINING_VALIDATOR_KEY: 50000000,
Exemple #29
0
                    help="private key of the sender vault")
parser.add_argument("-r",
                    "--receiver",
                    action="store",
                    type=str,
                    required=True,
                    dest="receiver",
                    help="receiver of the transfer")
parser.add_argument("-a",
                    "--amount",
                    action="store",
                    type=int,
                    required=True,
                    dest="amount",
                    help="the amount of the transfer")

args = parser.parse_args()
try:
    private_key = PrivateKey.from_hex(args.private_key)
except:
    logging.error("The private you provided is not valid")
    sys.exit(1)

with grpc.insecure_channel('localhost:40401') as channel:
    client = RClient(channel)
    vault = VaultAPI(client, private_key)
    vault.transfer(from_addr=None, to_addr=args.receiver, amount=args.amount)
    logging.info("Succeed transfer {} from {} to {} .".format(
        args.amount,
        private_key.get_public_key().get_rev_address(), args.receiver))
Exemple #30
0
def test_key_to_hex(key_hex: str, pub_key_hex: str, rev_address: str) -> None:
    private_key = PrivateKey.from_hex(key_hex)
    assert private_key.to_hex() == key_hex
    public_key = PublicKey.from_hex(pub_key_hex)
    assert public_key.to_hex() == pub_key_hex