Exemplo n.º 1
0
    get_skips_and_block_making_time, sign_block, get_contract_code, \
    casper_config, get_casper_ct, get_casper_code, get_rlp_decoder_code, \
    get_hash_without_ed_code, make_casper_genesis, get_timestamp, \
    make_withdrawal_signature
from biblecoin.block_creation import make_head_candidate
from biblecoin.transaction_queue import TransactionQueue
from biblecoin.slogging import LogRecorder, configure_logging, set_level
import serpent
from biblecoin.config import default_config, Env
import copy
import time
import rlp

# config_string = ':info,bible.vm.log:trace,bible.vm.op:trace,bible.vm.stack:trace,bible.vm.exit:trace,bible.pb.msg:trace,bible.pb.tx:debug'
config_string = ':info,bible.vm.log:trace'
configure_logging(config_string=config_string)

NUM_PARTICIPANTS = 10
BLOCK_MAKING_PPB = 10

print('Initializing privkeys, addresses and randaos for validators')
privkeys = [utils.sha3(str(i)) for i in range(NUM_PARTICIPANTS)]
addrs = [utils.privtoaddr(k) for k in privkeys]
randaos = [RandaoManager(utils.sha3(str(i))) for i in range(NUM_PARTICIPANTS)]
deposit_sizes = [i * 500 + 500 for i in range(NUM_PARTICIPANTS)]
vcodes = [generate_validation_code(a) for a in addrs]
vchashes = [utils.sha3(c) for c in vcodes]
assert len(privkeys) == len(addrs) == len(randaos) == len(
    deposit_sizes) == len(vcodes) == len(vchashes) == NUM_PARTICIPANTS

# Creating casper contract translator
Exemplo n.º 2
0
import json
import sys
from biblecoin.tools import testutils
from biblecoin.slogging import get_logger, configure_logging
logger = get_logger()
# customize VM log output to your needs
# hint: use 'py.test' with the '-s' option to dump logs to the console
if '--trace' in sys.argv:  # not default
    configure_logging(':trace')
    sys.argv.remove('trace')


def test_vm(filename, testname, testdata):
    testutils.check_vm_test(testdata)


def pytest_generate_tests(metafunc):
    testutils.generate_test_params('VMTests', metafunc)


def main():
    if len(sys.argv) == 1:
        # read fixture from stdin
        fixtures = {'stdin': json.load(sys.stdin)}
    else:
        # load fixtures from specified file or dir
        try:
            fixtures = testutils.get_tests_from_file_or_dir(sys.argv[1])
        except BaseException:
            fixtures = {'stdin': json.loads(sys.argv[1])}
    for filename, tests in list(fixtures.items()):