def scenario( wallets, **kw ):

    testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.next_block( **kw )

    testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.next_block( **kw )

    # wait for a bit...
    for i in xrange(0, 10):
        testlib.next_block( **kw )

    resp = testlib.blockstore_name_renew( "foo.test", wallets[3].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    global snv_consensus, snv_block_id
    snv_block_id = testlib.get_current_block()
    snv_consensus = testlib.get_consensus_at( snv_block_id )

    testlib.next_block( **kw )
def scenario(wallets, **kw):

    testlib.blockstore_namespace_preorder("test", wallets[1].addr, wallets[0].privkey)
    testlib.next_block(**kw)

    # NOTE: names expire in 13 blocks
    testlib.blockstore_namespace_reveal(
        "test",
        wallets[1].addr,
        13,
        250,
        4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        10,
        10,
        wallets[0].privkey,
    )
    testlib.next_block(**kw)

    testlib.blockstore_namespace_ready("test", wallets[1].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr)
    testlib.next_block(**kw)

    testlib.blockstore_name_register("foo.test", wallets[2].privkey, wallets[3].addr)
    testlib.next_block(**kw)

    for i in xrange(0, 15):
        testlib.next_block(**kw)
Esempio n. 3
0
def scenario(wallets, **kw):

    testlib.blockstore_namespace_preorder("test", wallets[1].addr,
                                          wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_reveal(
        "test", wallets[1].addr, 52595, 250, 4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10,
        wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_ready("test", wallets[1].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_name_preorder("foo.test", wallets[2].privkey,
                                     wallets[3].addr)
    testlib.next_block(**kw)

    testlib.blockstore_name_register("foo.test", wallets[2].privkey,
                                     wallets[3].addr)
    testlib.next_block(**kw)

    testlib.blockstore_name_update("foo.test", "11" * 20, wallets[3].privkey)
    testlib.next_block(**kw)

    # should fail--can't give a name to yourself
    testlib.blockstore_name_transfer("foo.test", wallets[4].addr, True,
                                     wallets[4].privkey)
    testlib.next_block(**kw)

    # should fail--can't steal a name
    testlib.blockstore_name_transfer("foo.test", wallets[4].addr, True,
                                     wallets[0].privkey)
    testlib.next_block(**kw)
def scenario( wallets, **kw ):

    global snv_block_id, last_consensus

    testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    testlib.next_block( **kw )

    # NOTE: names expire in 13 blocks
    testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 13, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.next_block( **kw )

    testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.next_block( **kw )

    snv_block_id = testlib.get_current_block()
    
    for i in xrange(0, 15):
        testlib.next_block( **kw )

    last_consensus = testlib.get_consensus_at( testlib.get_current_block() )
Esempio n. 5
0
def scenario(wallets, **kw):

    testlib.blockstore_namespace_preorder("test", wallets[1].addr,
                                          wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_reveal(
        "test", wallets[1].addr, 52595, 250, 4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10,
        wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_ready("test", wallets[1].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_name_preorder("foo.test", wallets[2].privkey,
                                     wallets[3].addr)
    testlib.next_block(**kw)

    testlib.blockstore_name_register("foo.test", wallets[2].privkey,
                                     wallets[3].addr)
    testlib.next_block(**kw)

    testlib.blockstore_name_update("foo.test", "11" * 20, wallets[3].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_name_renew("foo.test", wallets[3].privkey)
    testlib.next_block(**kw)
def scenario(wallets, **kw):

    testlib.blockstore_namespace_preorder("test", wallets[1].addr, wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_reveal(
        "test",
        wallets[1].addr,
        52595,
        250,
        4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        10,
        10,
        wallets[0].privkey,
    )
    testlib.next_block(**kw)

    testlib.blockstore_namespace_ready("test", wallets[1].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr)
    testlib.next_block(**kw)

    testlib.blockstore_name_register("foo.test", wallets[2].privkey, wallets[3].addr)
    testlib.next_block(**kw)
def scenario( wallets, **kw ):

    global working_dir 
    testlib.blockstore_namespace_preorder( "id", wallets[1].addr, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_reveal( "id", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_ready( "id", wallets[1].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_name_preorder( "judecn.id", wallets[2].privkey, wallets[3].addr )
    testlib.next_block( **kw )

    testlib.blockstore_name_register( "judecn.id", wallets[2].privkey, wallets[3].addr )
    testlib.next_block( **kw )

    resp = testlib.blockstore_announce( "hello world!", wallets[3].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    resp = testlib.blockstore_announce( "This should not appear", wallets[4].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # save...
    working_dir = testlib.get_working_dir( **kw )
def scenario(wallets, **kw):

    testlib.blockstore_namespace_preorder("test", wallets[1].addr,
                                          wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_reveal(
        "test", wallets[1].addr, 52595, 250, 4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10,
        wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_ready("test", wallets[1].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_name_preorder("foo.test", wallets[2].privkey,
                                     wallets[3].addr)
    testlib.next_block(**kw)

    testlib.blockstore_name_register("foo.test", wallets[2].privkey,
                                     wallets[3].addr)
    testlib.next_block(**kw)

    resp = testlib.blockstore_name_revoke("foo.test", wallets[3].privkey)
    print json.dumps(resp, indent=4)
    testlib.next_block(**kw)
def scenario( wallets, **kw ):

    testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.next_block( **kw )
    
    testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.next_block( **kw )

    testlib.blockstore_name_update( "foo.test", "11" * 20, wallets[3].privkey )
    testlib.next_block( **kw )

    consensus_hash = testlib.get_consensus_at( testlib.get_current_block( **kw ), **kw )

    # lots of blocks later...
    for i in xrange(0, 50):
        testlib.next_block( **kw )

    # update with stale consensus hash (should fail)
    testlib.blockstore_name_update( "foo.test", "22" * 20, wallets[3].privkey, consensus_hash=consensus_hash )
    testlib.next_block( **kw )
def scenario( wallets, **kw ):

    testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.next_block( **kw )

    testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.next_block( **kw )

    # wait for a bit...
    for i in xrange(0, 10):
        testlib.next_block( **kw )

    # has to be the same key that registered...
    resp = testlib.blockstore_name_renew( "foo.test", wallets[4].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )
    testlib.next_block( **kw )
def scenario( wallets, **kw ):

    testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    testlib.next_block( **kw )

    resp = testlib.blockstore_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr )
    if 'error' in resp:
        print json.dumps( resp )

    testlib.next_block( **kw )

    # wait for it to expire (takes a day) 
    for i in xrange(0, 145):
        testlib.next_block( **kw )

    # re-preorder it 
    resp = testlib.blockstore_name_preorder( "foo.test", wallets[3].privkey, wallets[4].addr )
    if 'error' in resp:
        print json.dumps( resp )

    testlib.next_block( **kw )

    # register it 
    resp = testlib.blockstore_name_register( "foo.test", wallets[3].privkey, wallets[4].addr )
    if 'error' in resp:
        print json.dumps( resp )

    testlib.next_block( **kw )
def scenario( wallets, **kw ):

    testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.next_block( **kw )
    
    testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.next_block( **kw )

    testlib.blockstore_name_update( "foo.test", "11" * 20, wallets[3].privkey )
    testlib.next_block( **kw )

    # should fail--can't give a name to yourself
    testlib.blockstore_name_transfer( "foo.test", wallets[4].addr, True, wallets[4].privkey ) 
    testlib.next_block( **kw )
    
    # should fail--can't steal a name
    testlib.blockstore_name_transfer( "foo.test", wallets[4].addr, True, wallets[0].privkey ) 
    testlib.next_block( **kw )
Esempio n. 13
0
def scenario(wallets, **kw):

    testlib.blockstore_namespace_preorder("test", wallets[1].addr,
                                          wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_reveal(
        "test", wallets[1].addr, 52595, 250, 4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10,
        wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_ready("test", wallets[1].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_name_preorder("foo.test", wallets[2].privkey,
                                     wallets[3].addr)
    testlib.next_block(**kw)

    # only wallets[3] should get it
    testlib.blockstore_name_register("foo.test", wallets[4].privkey,
                                     wallets[3].addr)
    testlib.blockstore_name_register("foo.test", wallets[2].privkey,
                                     wallets[3].addr)
    testlib.next_block(**kw)
Esempio n. 14
0
def scenario(wallets, **kw):

    global snv_consensus, snv_block_id

    testlib.blockstore_namespace_preorder("test", wallets[1].addr,
                                          wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_reveal(
        "test", wallets[1].addr, 52595, 250, 4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10,
        wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_ready("test", wallets[1].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_name_preorder("foo.test", wallets[2].privkey,
                                     wallets[3].addr)
    testlib.next_block(**kw)

    testlib.blockstore_name_register("foo.test", wallets[2].privkey,
                                     wallets[3].addr)
    testlib.next_block(**kw)

    snv_block_id = testlib.get_current_block()
    snv_consensus = testlib.get_consensus_at(snv_block_id)
Esempio n. 15
0
def scenario(wallets, **kw):

    testlib.blockstore_namespace_preorder("test", wallets[1].addr,
                                          wallets[0].privkey)
    testlib.next_block(**kw)

    # NOTE: names expire in 13 blocks
    testlib.blockstore_namespace_reveal(
        "test", wallets[1].addr, 13, 250, 4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10,
        wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_ready("test", wallets[1].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_name_preorder("foo.test", wallets[2].privkey,
                                     wallets[3].addr)
    testlib.next_block(**kw)

    testlib.blockstore_name_register("foo.test", wallets[2].privkey,
                                     wallets[3].addr)
    testlib.next_block(**kw)

    global snv_block_id, snv_consensus
    snv_block_id = testlib.get_current_block()
    snv_consensus = testlib.get_consensus_at(snv_block_id)

    for i in xrange(0, 15):
        testlib.next_block(**kw)
def scenario( wallets, **kw ):

    global snv_consensus, snv_block_id, last_consensus, last_block_id

    testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.next_block( **kw )
    
    testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.next_block( **kw )
    
    snv_block_id = testlib.get_current_block()
    snv_consensus = testlib.get_consensus_at( snv_block_id )

    testlib.blockstore_name_update( "foo.test", "11" * 20, wallets[3].privkey )
    testlib.next_block( **kw )
    
    last_block_id = testlib.get_current_block()
    last_consensus = testlib.get_consensus_at( last_block_id )
def scenario(wallets, **kw):

    testlib.blockstore_namespace_preorder("test", wallets[1].addr,
                                          wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_reveal(
        "test", wallets[1].addr, 52595, 250, 4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10,
        wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_ready("test", wallets[1].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_name_preorder("foo.test", wallets[2].privkey,
                                     wallets[3].addr)
    testlib.next_block(**kw)

    testlib.blockstore_name_register("foo.test", wallets[2].privkey,
                                     wallets[3].addr)
    testlib.next_block(**kw)

    # wait for a bit...
    for i in xrange(0, 10):
        testlib.next_block(**kw)

    resp = testlib.blockstore_name_renew("foo.test", wallets[3].privkey)
    if 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)
    testlib.next_block(**kw)
def scenario( wallets, **kw ):

    global txids
    global consensuses

    testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.next_block( **kw )
    
    testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.next_block( **kw )

    testlib.next_block( **kw )
    # do a sequence of updates, every other block
    for i in xrange( 0, 20 ):

        if (i % 2) != 0:
            update_hash = ("%02x" % (i)) * 20
            resp = testlib.blockstore_name_update( "foo.test", update_hash, wallets[3].privkey )

            txids[ update_hash ] = resp['transaction_hash']
            consensuses[ update_hash ] = testlib.get_consensus_at( testlib.get_current_block( **kw ), **kw )

        testlib.next_block( **kw )

    testlib.next_block( **kw )
def scenario( wallets, **kw ):

    global snv_block_id_foo, snv_serial_number_bar, snv_serial_number_baz, last_consensus, snv_txid_bar, snv_txid_baz

    testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.next_block( **kw )

    testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.next_block( **kw )

    snv_block_id_foo = testlib.get_current_block()

    testlib.next_block( **kw )
    testlib.next_block( **kw )
    testlib.next_block( **kw )
    testlib.next_block( **kw )
    testlib.next_block( **kw )

    bar_preorder = testlib.blockstore_name_preorder( "bar.test", wallets[4].privkey, wallets[5].addr )
    testlib.next_block( **kw )
    
    snv_serial_number_bar = "%s-%s" % (testlib.get_current_block(), 0 )
    snv_txid_bar = bar_preorder['transaction_hash']

    testlib.blockstore_name_register( "bar.test", wallets[4].privkey, wallets[5].addr )
    testlib.next_block( **kw )

    testlib.next_block( **kw )
    testlib.next_block( **kw )
    testlib.next_block( **kw )
    testlib.next_block( **kw )
    testlib.next_block( **kw )

    baz_preorder = testlib.blockstore_name_preorder( "baz.test", wallets[6].privkey, wallets[7].addr )
    testlib.next_block( **kw )
    
    snv_serial_number_baz = "%s-%s" % (testlib.get_current_block(), 0 )
    snv_txid_baz = baz_preorder['transaction_hash']

    testlib.blockstore_name_register( "baz.test", wallets[6].privkey, wallets[7].addr )
    testlib.next_block( **kw )

    last_consensus = testlib.get_consensus_at( testlib.get_current_block() )
def scenario(wallets, **kw):

    testlib.blockstore_namespace_preorder("test", wallets[1].addr, wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_reveal(
        "test",
        wallets[1].addr,
        52595,
        250,
        4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        10,
        10,
        wallets[0].privkey,
    )
    testlib.next_block(**kw)

    testlib.blockstore_namespace_ready("test", wallets[1].privkey)
    testlib.next_block(**kw)

    # try to exceed quota (currently 25)
    for i in xrange(0, 25):
        resp = testlib.blockstore_name_preorder("foo%s.test" % i, wallets[2].privkey, wallets[3].addr)
        if "error" in resp:
            print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    for i in xrange(0, 25):
        resp = testlib.blockstore_name_register("foo%s.test" % i, wallets[2].privkey, wallets[3].addr)
        if "error" in resp:
            print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_name_preorder("bar.test", wallets[2].privkey, wallets[3].addr)
    if "error" in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    # should fail
    resp = testlib.blockstore_name_register("bar.test", wallets[2].privkey, wallets[3].addr)
    if "error" in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)
def scenario(wallets, **kw):

    testlib.blockstore_namespace_preorder("test", wallets[1].addr,
                                          wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_reveal(
        "test", wallets[1].addr, 52595, 250, 4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10,
        wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_ready("test", wallets[1].privkey)
    testlib.next_block(**kw)

    # try to exceed quota (currently 25)
    for i in xrange(0, 25):
        resp = testlib.blockstore_name_preorder("foo%s.test" % i,
                                                wallets[2].privkey,
                                                wallets[3].addr)
        if 'error' in resp:
            print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    for i in xrange(0, 25):
        resp = testlib.blockstore_name_register("foo%s.test" % i,
                                                wallets[2].privkey,
                                                wallets[3].addr)
        if 'error' in resp:
            print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_name_preorder("bar.test", wallets[2].privkey,
                                            wallets[3].addr)
    if 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    # should fail
    resp = testlib.blockstore_name_register("bar.test", wallets[2].privkey,
                                            wallets[3].addr)
    if 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)
def scenario( wallets, **kw ):

    testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 1, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    testlib.next_block( **kw )

    # preorder, register, expire (multiple times)
    for i in xrange(2, 5):
        resp = testlib.blockstore_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr )
        if 'error' in resp:
            print json.dumps( resp, indent=4 )

        testlib.next_block( **kw )
    
        resp = testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[3].addr )
        if 'error' in resp:
            print json.dumps( resp, indent=4 )

        testlib.next_block( **kw )

        if i == 4:
            break

        testlib.next_block( **kw )
        testlib.next_block( **kw )
Esempio n. 23
0
def scenario( wallets, **kw ):

    testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 1, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    testlib.next_block( **kw )

    # preorder, register, update, expire (multiple times)
    for i in xrange(2, 11):
        resp = testlib.blockstore_name_preorder( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr )
        if 'error' in resp:
            print json.dumps( resp, indent=4 )

        testlib.next_block( **kw )
   
        resp = testlib.blockstore_name_register( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr )
        if 'error' in resp:
            print json.dumps( resp, indent=4 )

        testlib.next_block( **kw )

        resp = testlib.blockstore_name_update( "foo.test", ("%02x" % i) * 20, wallets[(i+1)%11].privkey )
        if 'error' in resp:
            print json.dumps( resp, indent=4 )

        testlib.next_block( **kw )

        if i == 10:
            break

        testlib.next_block( **kw )
def scenario(wallets, **kw):

    global debug

    resp = testlib.blockstore_namespace_preorder("test", wallets[1].addr,
                                                 wallets[0].privkey)
    if debug or 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_namespace_reveal(
        "test", wallets[1].addr, 52595, 250, 4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10,
        wallets[0].privkey)
    if debug or 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_namespace_ready("test", wallets[1].privkey)
    if debug or 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_name_preorder("foo.test", wallets[2].privkey,
                                            wallets[3].addr)
    if debug or 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_name_register("foo.test", wallets[2].privkey,
                                            wallets[3].addr)
    if debug or 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_name_transfer("foo.test", wallets[4].addr, True,
                                            wallets[3].privkey)
    if debug or 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_name_transfer("foo.test", wallets[0].addr, True,
                                            wallets[4].privkey)
    if debug or 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_name_update("foo.test", "11" * 20,
                                          wallets[0].privkey)
    if debug or 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)
def scenario(wallets, **kw):

    global debug

    resp = testlib.blockstore_namespace_preorder("test", wallets[1].addr, wallets[0].privkey)
    if debug or "error" in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_namespace_reveal(
        "test",
        wallets[1].addr,
        52595,
        250,
        4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        10,
        10,
        wallets[0].privkey,
    )
    if debug or "error" in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_namespace_ready("test", wallets[1].privkey)
    if debug or "error" in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr)
    if debug or "error" in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_name_register("foo.test", wallets[2].privkey, wallets[3].addr)
    if debug or "error" in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_name_update("foo.test", "11" * 20, wallets[3].privkey)
    if debug or "error" in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey)
    if debug or "error" in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)
Esempio n. 26
0
def scenario(wallets, **kw):

    global txids
    global consensuses

    testlib.blockstore_namespace_preorder("test", wallets[1].addr,
                                          wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_reveal(
        "test", wallets[1].addr, 52595, 250, 4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10,
        wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_ready("test", wallets[1].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_name_preorder("foo.test", wallets[2].privkey,
                                     wallets[3].addr)
    testlib.next_block(**kw)

    testlib.blockstore_name_register("foo.test", wallets[2].privkey,
                                     wallets[3].addr)
    testlib.next_block(**kw)

    testlib.next_block(**kw)
    # do a sequence of updates, every other block
    for i in xrange(0, 20):

        if (i % 2) != 0:
            update_hash = ("%02x" % (i)) * 20
            resp = testlib.blockstore_name_update("foo.test", update_hash,
                                                  wallets[3].privkey)

            txids[update_hash] = resp['transaction_hash']
            consensuses[update_hash] = testlib.get_consensus_at(
                testlib.get_current_block(**kw), **kw)

        testlib.next_block(**kw)

    testlib.next_block(**kw)
Esempio n. 27
0
def scenario( wallets, **kw ):

    testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    testlib.next_block( **kw )

    # NOTE: names expire in 13 blocks
    testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 13, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.next_block( **kw )

    testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.next_block( **kw )

    for i in xrange(0, 15):
        testlib.next_block( **kw )
Esempio n. 28
0
def scenario(wallets, **kw):

    testlib.blockstore_namespace_preorder("test", wallets[1].addr,
                                          wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_reveal(
        "test", wallets[1].addr, 52595, 250, 4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10,
        wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_ready("test", wallets[1].privkey)
    testlib.next_block(**kw)

    resp = testlib.blockstore_name_preorder("foo.test", wallets[2].privkey,
                                            wallets[3].addr)
    if 'error' in resp:
        print json.dumps(resp)

    testlib.next_block(**kw)

    # wait for it to expire (takes a day)
    for i in xrange(0, 145):
        testlib.next_block(**kw)

    # re-preorder it
    resp = testlib.blockstore_name_preorder("foo.test", wallets[3].privkey,
                                            wallets[4].addr)
    if 'error' in resp:
        print json.dumps(resp)

    testlib.next_block(**kw)

    # register it
    resp = testlib.blockstore_name_register("foo.test", wallets[3].privkey,
                                            wallets[4].addr)
    if 'error' in resp:
        print json.dumps(resp)

    testlib.next_block(**kw)
def scenario(wallets, **kw):

    global debug

    resp = testlib.blockstore_namespace_preorder("test", wallets[1].addr, wallets[0].privkey)
    if debug or "error" in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_namespace_reveal(
        "test",
        wallets[1].addr,
        52595,
        250,
        4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        10,
        10,
        wallets[0].privkey,
    )
    if debug or "error" in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_namespace_ready("test", wallets[1].privkey)
    if debug or "error" in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr)
    if debug or "error" in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_name_register("foo.test", wallets[2].privkey, wallets[3].addr)
    if debug or "error" in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey)
    if debug or "error" in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    global snv_consensus, snv_block_id
    snv_block_id = testlib.get_current_block()
    snv_consensus = testlib.get_consensus_at(snv_block_id)
def scenario(wallets, **kw):

    testlib.blockstore_namespace_preorder("test", wallets[1].addr,
                                          wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_reveal(
        "test", wallets[1].addr, 52595, 250, 4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10,
        wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_ready("test", wallets[1].privkey)
    testlib.next_block(**kw)

    resp = testlib.blockstore_name_preorder("foo.test", wallets[2].privkey,
                                            wallets[3].addr)
    if 'error' in resp:
        print json.dumps(resp)

    testlib.next_block(**kw)

    # no name operations should work on this name, except register
    resp = testlib.blockstore_name_update("foo.test", "11" * 20,
                                          wallets[3].privkey)
    if 'error' in resp:
        print json.dumps(resp)

    testlib.next_block(**kw)

    resp = testlib.blockstore_name_renew("foo.test", wallets[3].privkey)
    if 'error' in resp:
        print json.dumps(resp)

    testlib.next_block(**kw)

    resp = testlib.blockstore_name_transfer("foo.test", wallets[4].addr, True,
                                            wallets[3].privkey)
    if 'error' in resp:
        print json.dumps(resp)

    testlib.next_block(**kw)

    # try both addresses (should both fail)
    resp = testlib.blockstore_name_revoke("foo.test", wallets[4].privkey)
    if 'error' in resp:
        print json.dumps(resp)

    testlib.next_block(**kw)

    resp = testlib.blockstore_name_revoke("foo.test", wallets[3].privkey)
    if 'error' in resp:
        print json.dumps(resp)
def scenario(wallets, **kw):

    global working_dir
    testlib.blockstore_namespace_preorder("id", wallets[1].addr,
                                          wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_reveal(
        "id", wallets[1].addr, 52595, 250, 4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10,
        wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_ready("id", wallets[1].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_name_preorder("judecn.id", wallets[2].privkey,
                                     wallets[3].addr)
    testlib.next_block(**kw)

    testlib.blockstore_name_register("judecn.id", wallets[2].privkey,
                                     wallets[3].addr)
    testlib.next_block(**kw)

    resp = testlib.blockstore_announce("hello world!", wallets[3].privkey)
    if 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_announce("This should not appear",
                                       wallets[4].privkey)
    if 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    # save...
    working_dir = testlib.get_working_dir(**kw)
def scenario(wallets, **kw):

    testlib.blockstore_namespace_preorder("test", wallets[1].addr,
                                          wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_reveal(
        "test", wallets[1].addr, 52595, 250, 4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10,
        wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_ready("test", wallets[1].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_name_preorder("foo.test", wallets[2].privkey,
                                     wallets[3].addr)
    testlib.next_block(**kw)

    testlib.blockstore_name_register("foo.test", wallets[2].privkey,
                                     wallets[3].addr)
    testlib.next_block(**kw)

    testlib.blockstore_name_update("foo.test", "11" * 20, wallets[3].privkey)
    testlib.next_block(**kw)

    consensus_hash = testlib.get_consensus_at(testlib.get_current_block(**kw),
                                              **kw)

    # lots of blocks later...
    for i in xrange(0, 50):
        testlib.next_block(**kw)

    # update with stale consensus hash (should fail)
    testlib.blockstore_name_update("foo.test",
                                   "22" * 20,
                                   wallets[3].privkey,
                                   consensus_hash=consensus_hash)
    testlib.next_block(**kw)
def scenario(wallets, **kw):

    testlib.blockstore_namespace_preorder("test", wallets[1].addr, wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_reveal(
        "test", wallets[1].addr, 2, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey
    )
    testlib.next_block(**kw)

    testlib.blockstore_namespace_ready("test", wallets[1].privkey)
    testlib.next_block(**kw)

    # preorder, register, update, expire (multiple times)
    for i in xrange(2, 11):
        resp = testlib.blockstore_name_preorder("foo.test", wallets[i].privkey, wallets[(i + 1) % 11].addr)
        if "error" in resp:
            print json.dumps(resp, indent=4)

        testlib.next_block(**kw)

        resp = testlib.blockstore_name_register("foo.test", wallets[i].privkey, wallets[(i + 1) % 11].addr)
        if "error" in resp:
            print json.dumps(resp, indent=4)

        testlib.next_block(**kw)

        resp = testlib.blockstore_name_update("foo.test", ("%02x" % i) * 20, wallets[(i + 1) % 11].privkey)
        if "error" in resp:
            print json.dumps(resp, indent=4)

        testlib.next_block(**kw)

        resp = testlib.blockstore_name_transfer("foo.test", wallets[i].addr, True, wallets[(i + 1) % 11].privkey)
        if "error" in resp:
            print json.dumps(resp, indent=4)

        testlib.next_block(**kw)

        resp = testlib.blockstore_name_renew("foo.test", wallets[i].privkey)
        if "error" in resp:
            print json.dumps(resp, indent=4)

        testlib.next_block(**kw)
        testlib.next_block(**kw)
        testlib.next_block(**kw)

        if i == 10:
            break

        testlib.next_block(**kw)
def scenario(wallets, **kw):

    global debug

    resp = testlib.blockstore_namespace_preorder("test", wallets[1].addr,
                                                 wallets[0].privkey)
    if debug or 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_namespace_reveal(
        "test", wallets[1].addr, 52595, 250, 4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10,
        wallets[0].privkey)
    if debug or 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_namespace_ready("test", wallets[1].privkey)
    if debug or 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_name_preorder("foo.test", wallets[2].privkey,
                                            wallets[3].addr)
    if debug or 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_name_register("foo.test", wallets[2].privkey,
                                            wallets[3].addr)
    if debug or 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_name_transfer("foo.test", wallets[4].addr, True,
                                            wallets[3].privkey)
    if debug or 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    global snv_consensus, snv_block_id
    snv_block_id = testlib.get_current_block()
    snv_consensus = testlib.get_consensus_at(snv_block_id)
Esempio n. 35
0
def scenario( wallets, **kw ):

    global final_consensus

    testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    testlib.next_block( **kw )

    resp = testlib.blockstore_name_preorder_multi( ["foo.test", "bar.test", "baz.test"], wallets[2].privkey, [wallets[3].addr, wallets[4].addr, wallets[5].addr] )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )
        sys.exit(1)
       
    testlib.next_block( **kw )

    resp = testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[3].addr )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )
        sys.exit(1)
       
    testlib.next_block( **kw )

    resp = testlib.blockstore_name_preorder( "goo.test", wallets[2].privkey, wallets[3].addr )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )
        sys.exit(1)

    testlib.next_block( **kw )

    resp = testlib.blockstore_name_register( "bar.test", wallets[2].privkey, wallets[4].addr )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )
        sys.exit(1)

    resp = testlib.blockstore_name_register( "goo.test", wallets[2].privkey, wallets[3].addr )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )
        sys.exit(1)

    resp = testlib.blockstore_name_register( "baz.test", wallets[2].privkey, wallets[5].addr )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )
        sys.exit(1)

    testlib.next_block( **kw )
def scenario( wallets, **kw ):

    testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    testlib.next_block( **kw )

    resp = testlib.blockstore_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr )
    if 'error' in resp:
        print json.dumps(resp)

    testlib.next_block( **kw )

    # no name operations should work on this name, except register
    resp = testlib.blockstore_name_update( "foo.test", "11" * 20, wallets[3].privkey )
    if 'error' in resp:
        print json.dumps(resp)

    testlib.next_block( **kw )

    resp = testlib.blockstore_name_renew( "foo.test", wallets[3].privkey )
    if 'error' in resp:
        print json.dumps(resp)

    testlib.next_block( **kw )

    resp = testlib.blockstore_name_transfer( "foo.test", wallets[4].addr, True, wallets[3].privkey )
    if 'error' in resp:
        print json.dumps(resp)

    testlib.next_block( **kw )

    # try both addresses (should both fail)
    resp = testlib.blockstore_name_revoke( "foo.test", wallets[4].privkey )
    if 'error' in resp:
        print json.dumps(resp)

    testlib.next_block( **kw )

    resp = testlib.blockstore_name_revoke( "foo.test", wallets[3].privkey )
    if 'error' in resp:
        print json.dumps(resp)
Esempio n. 37
0
def scenario( wallets, **kw ):

    testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.blockstore_name_preorder( "foo.test", wallets[4].privkey, wallets[5].addr )
    testlib.blockstore_name_preorder( "foo.test", wallets[0].privkey, wallets[1].addr )
    testlib.blockstore_name_preorder( "foo.test", wallets[5].privkey, wallets[2].addr )
    testlib.next_block( **kw )

    # all of these should fail, since they're in the same block
    testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.blockstore_name_register( "foo.test", wallets[4].privkey, wallets[5].addr )
    testlib.blockstore_name_register( "foo.test", wallets[0].privkey, wallets[1].addr )
    testlib.blockstore_name_register( "foo.test", wallets[5].privkey, wallets[2].addr )
    testlib.next_block( **kw )
def scenario( wallets, **kw ):

    testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.blockstore_name_preorder( "foo.test", wallets[4].privkey, wallets[5].addr )
    testlib.blockstore_name_preorder( "foo.test", wallets[0].privkey, wallets[1].addr )
    testlib.blockstore_name_preorder( "foo.test", wallets[5].privkey, wallets[2].addr )
    testlib.next_block( **kw )

    # all of these should fail, since they're in the same block
    testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.blockstore_name_register( "foo.test", wallets[4].privkey, wallets[5].addr )
    testlib.blockstore_name_register( "foo.test", wallets[0].privkey, wallets[1].addr )
    testlib.blockstore_name_register( "foo.test", wallets[5].privkey, wallets[2].addr )
    testlib.next_block( **kw )
Esempio n. 39
0
def scenario( wallets, **kw ):

    subsidy_wallet = wallets[5]
    
    print json.dumps( testlib.getrawtransaction( "28f78fbae22d2273341af231a2ac049d74958e1e6ce6ae622cd48d8f0fef591e", 1 ), indent=4 )

    resp = testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    if debug or 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    resp = testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    if debug or 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    resp = testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    if debug or  'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # subsidized transactions...
    resp = testlib.blockstore_name_preorder( "foo.test", None, wallets[3].addr, subsidy_key=subsidy_wallet.privkey )
    if debug or  'error' in resp:
        print json.dumps( resp, indent=4 )
  
    # (already subsidized...)
    send_subsidized( None, resp, **kw )
    testlib.next_block( **kw )

    resp = testlib.blockstore_name_register( "foo.test", None, wallets[3].addr, subsidy_key=subsidy_wallet.privkey )
    if debug or  'error' in resp:
        print json.dumps( resp, indent=4 )

    # (already subsidized...)
    send_subsidized( None, resp, **kw )
    testlib.next_block( **kw )

    resp = testlib.blockstore_name_update( "foo.test", "11" * 20, None, user_public_key=wallets[3].pubkey_hex, subsidy_key=subsidy_wallet.privkey )
    if debug or  'error' in resp:
        print json.dumps( resp, indent=4 )

    send_subsidized( wallets[3].privkey, resp, **kw )
    testlib.next_block( **kw )

    resp = testlib.blockstore_name_transfer( "foo.test", wallets[4].addr, True, None, user_public_key=wallets[3].pubkey_hex, subsidy_key=subsidy_wallet.privkey ) 
    if debug or  'error' in resp:
        print json.dumps( resp, indent=4 )

    send_subsidized( wallets[3].privkey, resp, **kw )
    testlib.next_block( **kw )

    resp = testlib.blockstore_name_revoke( "foo.test", None, user_public_key=wallets[4].pubkey_hex, subsidy_key=subsidy_wallet.privkey )
    if debug or 'error' in resp:
        print json.dumps( resp, indent=4 )

    send_subsidized( wallets[4].privkey, resp, **kw )
    
    # advance a bit 
    for i in xrange(0, 5):
        testlib.next_block( **kw )
def scenario( wallets, **kw ):

    # make a test namespace
    resp = testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    if debug or 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    resp = testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    if debug or 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    resp = testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    if debug or  'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # 6 names, for all interleavings of (u)pdate, (t)ransfer, and (r)enew
    # NOTE: the name encodes the interleaving order
    names = {
        "utr.test": [wallets[0], wallets[1]],
        "urt.test": [wallets[2], wallets[3]],
        "tur.test": [wallets[4], wallets[5]],
        "tru.test": [wallets[6], wallets[7]],
        "rut.test": [wallets[8], wallets[9]],
        "rtu.test": [wallets[10], wallets[11]]
        }

    # preorder them all
    for name in names.keys():

        resp = testlib.blockstore_name_preorder( name, names[name][1].privkey, names[name][0].addr )
        if debug or  'error' in resp:
            print json.dumps( resp, indent=4 )
   
    testlib.next_block( **kw )

    # regster them all
    for name in names.keys():

        resp = testlib.blockstore_name_register( name, names[name][1].privkey, names[name][0].addr )
        if debug or  'error' in resp:
            print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # test intra-block interleavings:
    # update/transfer/renew
    # update/renew/transfer
    # transfer/update/renew
    # transfer/renew/update
    # renew/update/transfer
    # renew/transfer/update
    for name in names.keys():

        do_interleaving( name, names, name[:-5] )

    # iterate the blocks a few times 
    for i in xrange(0, 5):
        testlib.next_block( **kw )
Esempio n. 41
0
def scenario( wallets, **kw ):

    # make a test namespace
    resp = testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    if debug or 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    resp = testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    if debug or 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    resp = testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    if debug or  'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # preorder 3 names in the same block: foo.test, bar.test, baz.test
    names = ['foo.test', 'bar.test', 'baz.test']
    name_preorder_wallets = [wallets[2], wallets[3], wallets[4]]
    name_register_wallets = [wallets[5], wallets[6], wallets[7]]
    name_transfer_wallets = [wallets[6], wallets[7], wallets[5]]

    for i in xrange(0, len(names)):

        name = names[i]
        preorder_wallet = name_preorder_wallets[i]
        register_wallet = name_register_wallets[i]

        resp = testlib.blockstore_name_preorder( name, preorder_wallet.privkey, register_wallet.addr )
        if debug or  'error' in resp:
            print json.dumps( resp, indent=4 )
   
    testlib.next_block( **kw )

    # regster 3 names in the same block
    for i in xrange(0, len(names)):

        name = names[i]
        preorder_wallet = name_preorder_wallets[i]
        register_wallet = name_register_wallets[i]

        resp = testlib.blockstore_name_register( name, preorder_wallet.privkey, register_wallet.addr )
        if debug or  'error' in resp:
            print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # update 3 names in the same block
    for i in xrange(0, len(names)):

        name = names[i]
        register_wallet = name_register_wallets[i]

        resp = testlib.blockstore_name_update( name, str(i + 1) * 40, register_wallet.privkey )
        if debug or  'error' in resp:
            print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # transfer 3 names in the same block 
    for i in xrange(0, len(names)):

        name = names[i]
        register_wallet = name_register_wallets[i]
        transfer_wallet = name_transfer_wallets[i]

        resp = testlib.blockstore_name_transfer( name, transfer_wallet.addr, True, register_wallet.privkey ) 
        if debug or  'error' in resp:
            print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # exchange after transfer...
    tmp = name_register_wallets
    name_register_wallets = name_transfer_wallets
    name_transfer_wallets = tmp

    # renew 3 names in the same block 
    for i in xrange(0, len(names)):

        name = names[i]
        register_wallet = name_register_wallets[i]

        resp = testlib.blockstore_name_renew( name, register_wallet.privkey )
        if debug or 'error' in resp:
            print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # revoke 3 names in the same block 
    for i in xrange(0, len(names)):

        name = names[i]
        register_wallet = name_register_wallets[i]

        resp = testlib.blockstore_name_revoke( name, register_wallet.privkey )
        if debug or 'error' in resp:
            print json.dumps( resp, indent=4 )

    # iterate the blocks a few times 
    for i in xrange(0, 5):
        testlib.next_block( **kw )
Esempio n. 42
0
def scenario( wallets, **kw ):

    subsidy_wallet = wallets[5]
    
    print json.dumps( testlib.getrawtransaction( "28f78fbae22d2273341af231a2ac049d74958e1e6ce6ae622cd48d8f0fef591e", 1 ), indent=4 )

    resp = testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    if debug or 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    resp = testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    if debug or 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    resp = testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    if debug or  'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # subsidized transactions...
    resp = testlib.blockstore_name_preorder( "foo.test", None, wallets[3].addr, subsidy_key=subsidy_wallet.privkey )
    if debug or  'error' in resp:
        print json.dumps( resp, indent=4 )
  
    # (already subsidized...)
    send_subsidized( None, resp, **kw )
    testlib.next_block( **kw )

    resp = testlib.blockstore_name_register( "foo.test", None, wallets[3].addr, subsidy_key=subsidy_wallet.privkey )
    if debug or  'error' in resp:
        print json.dumps( resp, indent=4 )

    # (already subsidized...)
    send_subsidized( None, resp, **kw )
    testlib.next_block( **kw )

    resp = testlib.blockstore_name_update( "foo.test", "11" * 20, None, user_public_key=wallets[3].pubkey_hex, subsidy_key=subsidy_wallet.privkey )
    if debug or  'error' in resp:
        print json.dumps( resp, indent=4 )

    send_subsidized( wallets[3].privkey, resp, **kw )
    testlib.next_block( **kw )

    resp = testlib.blockstore_name_transfer( "foo.test", wallets[4].addr, True, None, user_public_key=wallets[3].pubkey_hex, subsidy_key=subsidy_wallet.privkey ) 
    if debug or  'error' in resp:
        print json.dumps( resp, indent=4 )

    send_subsidized( wallets[3].privkey, resp, **kw )
    testlib.next_block( **kw )

    resp = testlib.blockstore_name_revoke( "foo.test", None, user_public_key=wallets[4].pubkey_hex, subsidy_key=subsidy_wallet.privkey )
    if debug or 'error' in resp:
        print json.dumps( resp, indent=4 )

    send_subsidized( wallets[4].privkey, resp, **kw )
    
    # advance a bit 
    for i in xrange(0, 5):
        testlib.next_block( **kw )
def scenario( wallets, **kw ):

    testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 10, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.next_block( **kw )
    
    testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.next_block( **kw )
    
    testlib.blockstore_name_revoke( "foo.test", wallets[3].privkey )
    testlib.next_block( **kw )

    # can't do anything with the name for another 10 blocks
    resp = testlib.blockstore_name_update( "foo.test", "11" * 20, wallets[3].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # should fail
    resp = testlib.blockstore_name_transfer( "foo.test", wallets[4].addr, True, wallets[3].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # should fail
    resp = testlib.blockstore_name_renew( "foo.test", wallets[3].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # wait for it to expire...
    for i in xrange(0, 8):
        testlib.next_block( **kw )

    # verify that operations continue to fail
    resp = testlib.blockstore_name_update( "foo.test", "11" * 20, wallets[3].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # should fail
    resp = testlib.blockstore_name_transfer( "foo.test", wallets[4].addr, True, wallets[3].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # should fail
    resp = testlib.blockstore_name_renew( "foo.test", wallets[3].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # re-preorder...
    resp = testlib.blockstore_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # re-register 
    resp = testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[3].addr )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )
Esempio n. 44
0
def scenario( wallets, **kw ):

    resp = testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    if debug or 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # should get rejected
    resp = testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    if debug or 'error' in resp:
        print json.dumps( resp, indent=4 )

    # should get rejected (NOTE: the underlying mock utxo provider doesn't handle double-spends!)
    resp = testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    if debug or 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # should get accepted
    resp = testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    if debug or 'error' in resp:
        print json.dumps( resp, indent=4 )

    # should get rejected (but only because the namespace isn't revealed until the block goes through)
    resp = testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    if debug or  'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    resp = testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    if debug or  'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    resp = testlib.blockstore_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr )
    if debug or  'error' in resp:
        print json.dumps( resp, indent=4 )
   
    testlib.next_block( **kw )

    # should get rejected
    resp = testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[3].addr )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    # should get rejected (NOTE: the underlying mock utxo provider doesn't handle double-spends!)
    resp = testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[3].addr )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )
    
    # should succeed
    resp = testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[3].addr )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # (this should succeed)
    resp = testlib.blockstore_name_update( "foo.test", "11" * 20, wallets[3].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    # (this should also succeed)
    resp = testlib.blockstore_name_transfer( "foo.test", wallets[4].addr, True, wallets[3].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # (this should succeed)
    resp = testlib.blockstore_name_renew( "foo.test", wallets[4].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    # (this should also succeed)
    resp = testlib.blockstore_name_update( "foo.test", "22" * 20, wallets[4].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    # (this should succeed)
    resp = testlib.blockstore_name_transfer( "foo.test", wallets[3].addr, True, wallets[4].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )
   
    # lots of updates 
    for i in xrange(0, 9):
        resp = testlib.blockstore_name_update( "foo.test", ("%s%s" % (i,i)) * 20, wallets[3].privkey )
        if 'error' in resp:
            print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # transfer loop
    for i in xrange(0, 5):

        #resp = testlib.blockstore_name_transfer( "foo.test", wallets[3].addr, True, wallets[4].privkey )
        resp = testlib.blockstore_name_transfer( "foo.test", wallets[4].addr, True, wallets[3].privkey )
        if 'error' in resp:
            print json.dumps( resp, indent=4 )

        resp = testlib.blockstore_name_transfer( "foo.test", wallets[3].addr, True, wallets[4].privkey )
        if 'error' in resp:
            print json.dumps( resp, indent=4 )

    
    testlib.next_block( **kw )

    # update/transfer/update/transfer
    for i in xrange(0, 5):

        resp = testlib.blockstore_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey )
        if 'error' in resp:
            print json.dumps( resp, indent=4 )

        resp = testlib.blockstore_name_update("foo.test", "aa" * 20, wallets[4].privkey )
        if 'error' in resp:
            print json.dumps( resp, indent=4 )

        resp = testlib.blockstore_name_transfer("foo.test", wallets[3].addr, True, wallets[4].privkey )
        if 'error' in resp:
            print json.dumps( resp, indent=4 )

        resp = testlib.blockstore_name_update("foo.test", "bb" * 20, wallets[3].privkey )
        if 'error' in resp:
            print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )
def scenario( wallets, **kw ):

    testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 10, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.next_block( **kw )
    
    testlib.blockstore_name_register( "foo.test", wallets[2].privkey, wallets[3].addr )
    testlib.next_block( **kw )
    
    testlib.blockstore_name_revoke( "foo.test", wallets[3].privkey )
    testlib.next_block( **kw )

    # can't do anything with the name for another 10 blocks
    resp = testlib.blockstore_name_update( "foo.test", "11" * 20, wallets[3].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # should fail
    resp = testlib.blockstore_name_transfer( "foo.test", wallets[4].addr, True, wallets[3].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # should fail
    resp = testlib.blockstore_name_renew( "foo.test", wallets[3].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # wait for it to expire...
    for i in xrange(0, 8):
        testlib.next_block( **kw )

    # verify that operations continue to fail
    resp = testlib.blockstore_name_update( "foo.test", "11" * 20, wallets[3].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # should fail
    resp = testlib.blockstore_name_transfer( "foo.test", wallets[4].addr, True, wallets[3].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # should fail
    resp = testlib.blockstore_name_renew( "foo.test", wallets[3].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )
Esempio n. 46
0
def scenario(wallets, **kw):

    # make a test namespace
    resp = testlib.blockstore_namespace_preorder("test", wallets[1].addr,
                                                 wallets[0].privkey)
    if debug or 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_namespace_reveal(
        "test", wallets[1].addr, 52595, 250, 4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10,
        wallets[0].privkey)
    if debug or 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_namespace_ready("test", wallets[1].privkey)
    if debug or 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    # 6 names, for all interleavings of (u)pdate, (t)ransfer, and (r)enew
    # NOTE: the name encodes the interleaving order
    names = {
        "utr.test": [wallets[0], wallets[1]],
        "urt.test": [wallets[2], wallets[3]],
        "tur.test": [wallets[4], wallets[5]],
        "tru.test": [wallets[6], wallets[7]],
        "rut.test": [wallets[8], wallets[9]],
        "rtu.test": [wallets[10], wallets[11]]
    }

    # preorder them all
    for name in names.keys():

        resp = testlib.blockstore_name_preorder(name, names[name][1].privkey,
                                                names[name][0].addr)
        if debug or 'error' in resp:
            print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    # regster them all
    for name in names.keys():

        resp = testlib.blockstore_name_register(name, names[name][1].privkey,
                                                names[name][0].addr)
        if debug or 'error' in resp:
            print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    # test intra-block interleavings:
    # update/transfer/renew
    # update/renew/transfer
    # transfer/update/renew
    # transfer/renew/update
    # renew/update/transfer
    # renew/transfer/update
    for name in names.keys():

        do_interleaving(name, names, name[:-5])

    # iterate the blocks a few times
    for i in xrange(0, 5):
        testlib.next_block(**kw)
def scenario( wallets, **kw ):

    testlib.blockstore_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey )
    testlib.next_block( **kw )

    testlib.blockstore_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey )
    testlib.next_block( **kw )

    resp = testlib.blockstore_name_import( "foo.test", wallets[2].addr, "11" * 20, wallets[1].privkey )
    if 'error' in resp:
        print json.dumps(resp, indent=4 )

    testlib.next_block( **kw )

    # try to exceed quota (currently 25): order 25, and try to register a 26th
    for i in xrange(0, 25):
        resp = testlib.blockstore_name_import( "foo%s.test" % i, wallets[3].addr, "22" * 20, wallets[1].privkey )
        if 'error' in resp:
            print json.dumps(resp, indent=4 )

    testlib.next_block( **kw )

    # try to exceed quota (currently 25): order 26, and try to update one of them (and try to transfer one too).
    for i in xrange(0, 27):
        resp = testlib.blockstore_name_import( "bar%s.test" % i, wallets[4].addr, "33" * 20, wallets[1].privkey )
        if 'error' in resp:
            print json.dumps(resp, indent=4 )

    testlib.next_block( **kw )
    
    testlib.blockstore_namespace_ready( "test", wallets[1].privkey )
    testlib.next_block( **kw )

    print wallets[3].privkey
    resp = testlib.blockstore_name_preorder( "foofail.test", wallets[3].privkey, wallets[1].addr )
    if 'error' in resp:
       print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # should fail 
    resp = testlib.blockstore_name_register( "foofail.test",wallets[3].privkey,  wallets[1].addr )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # should succeed
    resp = testlib.blockstore_name_update( "foo0.test", '55' * 20, wallets[3].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    resp = testlib.blockstore_name_preorder( "barfail.test", wallets[4].privkey, wallets[2].addr )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # should fail (exceeded quota)
    resp = testlib.blockstore_name_register( "barfail.test", wallets[4].privkey, wallets[2].addr )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # should fail (exceeded quota--have to revoke or give names away)
    resp = testlib.blockstore_name_update( "bar0.test", '44' * 20, wallets[4].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # should succeed (give a name away)
    resp = testlib.blockstore_name_transfer( "bar0.test", wallets[1].addr, True, wallets[4].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # should fail (exceeded quota--have to revoke or give names away)
    resp = testlib.blockstore_name_update( "bar0.test", '44' * 20, wallets[4].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # should succeed (revoke a name)
    resp = testlib.blockstore_name_revoke( "bar2.test", wallets[4].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )

    # should succeed (now under quota)
    resp = testlib.blockstore_name_update( "bar1.test", '66' * 20, wallets[4].privkey )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

    testlib.next_block( **kw )
def scenario(wallets, **kw):

    global snv_block_id_foo, snv_serial_number_bar, snv_serial_number_baz, last_consensus, snv_txid_bar, snv_txid_baz

    testlib.blockstore_namespace_preorder("test", wallets[1].addr,
                                          wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_reveal(
        "test", wallets[1].addr, 52595, 250, 4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10,
        wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_ready("test", wallets[1].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_name_preorder("foo.test", wallets[2].privkey,
                                     wallets[3].addr)
    testlib.next_block(**kw)

    testlib.blockstore_name_register("foo.test", wallets[2].privkey,
                                     wallets[3].addr)
    testlib.next_block(**kw)

    snv_block_id_foo = testlib.get_current_block()

    testlib.next_block(**kw)
    testlib.next_block(**kw)
    testlib.next_block(**kw)
    testlib.next_block(**kw)
    testlib.next_block(**kw)

    bar_preorder = testlib.blockstore_name_preorder("bar.test",
                                                    wallets[4].privkey,
                                                    wallets[5].addr)
    testlib.next_block(**kw)

    snv_serial_number_bar = "%s-%s" % (testlib.get_current_block(), 0)
    snv_txid_bar = bar_preorder['transaction_hash']

    testlib.blockstore_name_register("bar.test", wallets[4].privkey,
                                     wallets[5].addr)
    testlib.next_block(**kw)

    testlib.next_block(**kw)
    testlib.next_block(**kw)
    testlib.next_block(**kw)
    testlib.next_block(**kw)
    testlib.next_block(**kw)

    baz_preorder = testlib.blockstore_name_preorder("baz.test",
                                                    wallets[6].privkey,
                                                    wallets[7].addr)
    testlib.next_block(**kw)

    snv_serial_number_baz = "%s-%s" % (testlib.get_current_block(), 0)
    snv_txid_baz = baz_preorder['transaction_hash']

    testlib.blockstore_name_register("baz.test", wallets[6].privkey,
                                     wallets[7].addr)
    testlib.next_block(**kw)

    last_consensus = testlib.get_consensus_at(testlib.get_current_block())
def scenario(wallets, **kw):

    testlib.blockstore_namespace_preorder("test", wallets[1].addr,
                                          wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.blockstore_namespace_reveal(
        "test", wallets[1].addr, 52595, 250, 4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10,
        wallets[0].privkey)
    testlib.next_block(**kw)

    resp = testlib.blockstore_name_import("foo.test", wallets[2].addr,
                                          "11" * 20, wallets[1].privkey)
    if 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    # try to exceed quota (currently 25): order 25, and try to register a 26th
    for i in xrange(0, 25):
        resp = testlib.blockstore_name_import("foo%s.test" % i,
                                              wallets[3].addr, "22" * 20,
                                              wallets[1].privkey)
        if 'error' in resp:
            print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    # try to exceed quota (currently 25): order 26, and try to update one of them (and try to transfer one too).
    for i in xrange(0, 27):
        resp = testlib.blockstore_name_import("bar%s.test" % i,
                                              wallets[4].addr, "33" * 20,
                                              wallets[1].privkey)
        if 'error' in resp:
            print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    testlib.blockstore_namespace_ready("test", wallets[1].privkey)
    testlib.next_block(**kw)

    print wallets[3].privkey
    resp = testlib.blockstore_name_preorder("foofail.test", wallets[3].privkey,
                                            wallets[1].addr)
    if 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    # should fail
    resp = testlib.blockstore_name_register("foofail.test", wallets[3].privkey,
                                            wallets[1].addr)
    if 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    # should succeed
    resp = testlib.blockstore_name_update("foo0.test", '55' * 20,
                                          wallets[3].privkey)
    if 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    resp = testlib.blockstore_name_preorder("barfail.test", wallets[4].privkey,
                                            wallets[2].addr)
    if 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    # should fail (exceeded quota)
    resp = testlib.blockstore_name_register("barfail.test", wallets[4].privkey,
                                            wallets[2].addr)
    if 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    # should fail (exceeded quota--have to revoke or give names away)
    resp = testlib.blockstore_name_update("bar0.test", '44' * 20,
                                          wallets[4].privkey)
    if 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    # should succeed (give a name away)
    resp = testlib.blockstore_name_transfer("bar0.test", wallets[1].addr, True,
                                            wallets[4].privkey)
    if 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    # should fail (exceeded quota--have to revoke or give names away)
    resp = testlib.blockstore_name_update("bar0.test", '44' * 20,
                                          wallets[4].privkey)
    if 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    # should succeed (revoke a name)
    resp = testlib.blockstore_name_revoke("bar2.test", wallets[4].privkey)
    if 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

    # should succeed (now under quota)
    resp = testlib.blockstore_name_update("bar1.test", '66' * 20,
                                          wallets[4].privkey)
    if 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)