Ejemplo n.º 1
0
def gen(testdb, request):
    gen = data.testnet14(testdb)
    chain = gen.chain
    blocks = gen.blocks

    # Test block with an interesting transaction.
    blocks.append(
        gen.block(
            prev=blocks[-1],
            transactions=[
                gen.coinbase(value=50.01e8),
                gen.tx(txIn=[gen.txin(prevout=blocks[1]['transactions'][0]['txOut'][0], scriptSig='XXX')],
                       txOut=[gen.txout(addr='n1pTUVnjZ6GHxujaoJ62P9NBMNjLr5N2EQ', value=9.99e8),
                              gen.txout(addr='2NFTctsgcAmrgtiboLJUx9q8qu5H1qVpcAb', value=20e8),
                              gen.txout(multisig={"m":2, "pubkeys":data.PUBKEYS[2:5]}, value=20e8)])]) )

    if 'ABE_TEST_SAVE_BLKFILE' in os.environ:
        gen.save_blkfile(os.environ['ABE_TEST_SAVE_BLKFILE'], blocks)

    # XXX Lots of code duplicated in test_block_order.py.
    datadir = py.path.local(tempfile.mkdtemp(prefix='abe-test-'))
    request.addfinalizer(datadir.remove)
    gen.save_blkfile(str(datadir.join('blk0001.dat')), blocks)

    gen.store = testdb.load('--datadir', json.dumps([{
                    'dirname': str(datadir),
                    'chain': chain.name,
                    'loader': 'blkfile'}]))
    gen.chain = gen.store.get_chain_by_name(chain.name)

    return gen
Ejemplo n.º 2
0
def gen(testdb, request):
    gen = data.testnet14(testdb)
    chain = gen.chain
    blocks = gen.blocks

    # Test block with an interesting transaction.
    blocks.append(
        gen.block(
            prev=blocks[-1],
            transactions=[
                gen.coinbase(value=50.01e8),
                gen.tx(txIn=[gen.txin(prevout=blocks[1]['transactions'][0]['txOut'][0], scriptSig='XXX')],
                       txOut=[gen.txout(addr='n1pTUVnjZ6GHxujaoJ62P9NBMNjLr5N2EQ', value=9.99e8),
                              gen.txout(addr='2NFTctsgcAmrgtiboLJUx9q8qu5H1qVpcAb', value=20e8),
                              gen.txout(multisig={"m":2, "pubkeys":data.PUBKEYS[2:5]}, value=20e8)])]) )

    if 'ABE_TEST_SAVE_BLKFILE' in os.environ:
        gen.save_blkfile(os.environ['ABE_TEST_SAVE_BLKFILE'], blocks)

    # XXX Lots of code duplicated in test_block_order.py.
    datadir = py.path.local(tempfile.mkdtemp(prefix='abe-test-'))
    request.addfinalizer(datadir.remove)
    gen.save_blkfile(str(datadir.join('blk0001.dat')), blocks)

    gen.store = testdb.load('--datadir', json.dumps([{
                    'dirname': str(datadir),
                    'chain': chain.name,
                    'loader': 'blkfile'}]))
    gen.chain = gen.store.get_chain_by_name(chain.name)

    return gen
Ejemplo n.º 3
0
def gen(testdb, request):
    gen = data.testnet14(testdb)
    chain = gen.chain
    blocks = gen.blocks

    # A - C* - D**
    #   \
    #     E  - B*
    #
    # * contains tx1
    # ** contains tx2

    tx1 = gen.tx(txIn=[
        gen.txin(prevout=blocks[1]['transactions'][0]['txOut'][0],
                 scriptSig='XXX')
    ],
                 txOut=[
                     gen.txout(addr='n1pTUVnjZ6GHxujaoJ62P9NBMNjLr5N2EQ',
                               value=50e8)
                 ])
    A = blocks[-1]
    C = gen.block(prev=A, transactions=[gen.coinbase(), tx1])
    E = gen.block(prev=A)
    B = gen.block(prev=E, transactions=[gen.coinbase(), tx1])

    tx2 = gen.tx(txIn=[
        gen.txin(prevout=C['transactions'][1]['txOut'][0], scriptSig='YYY')
    ],
                 txOut=[
                     gen.txout(addr='2NFTctsgcAmrgtiboLJUx9q8qu5H1qVpcAb',
                               value=50e8)
                 ])

    D = gen.block(prev=C, transactions=[gen.coinbase(), tx2])

    blocks += [B, C, D, E]

    # XXX Lots of code duplicated in test_std_tx.py.
    datadir = py.path.local(tempfile.mkdtemp(prefix='abe-test-'))
    request.addfinalizer(datadir.remove)
    gen.save_blkfile(str(datadir.join('blk0001.dat')), blocks)

    gen.store = testdb.load(
        '--datadir',
        json.dumps([{
            'dirname': str(datadir),
            'chain': chain.name,
            'loader': 'blkfile'
        }]))
    gen.chain = gen.store.get_chain_by_name(chain.name)

    return gen
Ejemplo n.º 4
0
def gen(testdb, request):
    gen = data.testnet14(testdb)
    chain = gen.chain
    blocks = gen.blocks

    # A - C* - D**
    #   \
    #     E  - B*
    #
    # * contains tx1
    # ** contains tx2

    tx1 = gen.tx(txIn=[gen.txin(prevout=blocks[1]['transactions'][0]['txOut'][0], scriptSig='XXX')],
                 txOut=[gen.txout(addr='n1pTUVnjZ6GHxujaoJ62P9NBMNjLr5N2EQ', value=50e8)])
    A = blocks[-1]
    C = gen.block(prev=A, transactions=[gen.coinbase(), tx1])
    E = gen.block(prev=A)
    B = gen.block(prev=E, transactions=[gen.coinbase(), tx1])

    tx2 = gen.tx(txIn=[gen.txin(prevout=C['transactions'][1]['txOut'][0], scriptSig='YYY')],
                 txOut=[gen.txout(addr='2NFTctsgcAmrgtiboLJUx9q8qu5H1qVpcAb', value=50e8)])

    D = gen.block(prev=C, transactions=[gen.coinbase(), tx2])

    blocks += [B, C, D, E]

    # XXX Lots of code duplicated in test_std_tx.py.
    datadir = py.path.local(tempfile.mkdtemp(prefix='abe-test-'))
    request.addfinalizer(datadir.remove)
    gen.save_blkfile(str(datadir.join('blk0001.dat')), blocks)

    gen.store = testdb.load('--datadir', json.dumps([{
                    'dirname': str(datadir),
                    'chain': chain.name,
                    'loader': 'blkfile'}]))
    gen.chain = gen.store.get_chain_by_name(chain.name)

    return gen