Beispiel #1
0
def scenario(wallets, **kw):

    global owner_address

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

    testlib.ysi_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.ysi_namespace_ready("test", wallets[1].privkey)
    testlib.next_block(**kw)

    legacy_wallet = testlib.make_legacy_wallet(wallets[2].privkey,
                                               "0123456789abcdef")
    testlib.store_wallet(legacy_wallet)

    res = testlib.ysi_cli_setup_wallet("0123456789abcdef")
    if 'error' in res:
        print json.dumps(res, indent=4, sort_keys=True)
        return False

    if not res.has_key('backup_wallet'):
        print "no backup_wallet"
        print json.dumps(res, indent=4, sort_keys=True)
        return False

    if not os.path.exists(res['backup_wallet']):
        print "backup wallet doesn't exist"
        print json.dumps(res, indent=4, sort_keys=True)
        return False

    res = testlib.instantiate_wallet()
    if 'error' in res:
        print json.dumps(res, indent=4, sort_keys=True)
        return False

    payment_address = str(res['payment_address'])
    owner_address = str(res['owner_address'])

    # fill wallet with 5 BTC
    res = testlib.send_funds(wallets[3].privkey, 5 * 10**8, payment_address)
    if 'error' in res:
        print "failed to fill wallet"
        print json.dumps(res)
        return False

    testlib.next_block(**kw)

    # register
    resp = testlib.ysi_cli_register("foo.test", "0123456789abcdef")
    if 'error' in resp:
        print >> sys.stderr, json.dumps(resp, indent=4, sort_keys=True)
        return False

    # wait for the preorder to get confirmed
    for i in xrange(0, 12):
        testlib.next_block(**kw)

    # wait for the poller to pick it up
    print >> sys.stderr, "Waiting 10 seconds for the backend to submit the register"
    time.sleep(10)

    # wait for the register to get confirmed
    for i in xrange(0, 12):
        testlib.next_block(**kw)

    print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge registration"
    time.sleep(10)

    # wait for update to get confirmed
    for i in xrange(0, 12):
        testlib.next_block(**kw)

    print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge update"
    time.sleep(10)
def scenario( wallets, **kw ):

    global owner_address

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

    testlib.blockstack_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.blockstack_namespace_ready( "test", wallets[1].privkey )
    testlib.next_block( **kw )

    # pre-0.13 wallet
    legacy_wallet = testlib.make_legacy_wallet( wallets[2].privkey, "0123456789abcdef" )
    testlib.store_wallet( legacy_wallet )

    res = testlib.blockstack_cli_setup_wallet("0123456789abcdef")
    if 'error' in res:
        print json.dumps(res, indent=4, sort_keys=True)
        return False

    if not res.has_key('backup_wallet'):
        print "no backup_wallet"
        print json.dumps(res, indent=4, sort_keys=True)
        return False

    if not os.path.exists(res['backup_wallet']):
        print "backup wallet doesn't exist"
        print json.dumps(res, indent=4, sort_keys=True)
        return False

    res = testlib.instantiate_wallet()
    if 'error' in res:
        print json.dumps(res, indent=4, sort_keys=True)
        return False

    payment_address = str(res['payment_address'])
    owner_address = str(res['owner_address'])

    print "fund {}".format(payment_address)
    
    # fill wallet with 5 BTC
    res = testlib.send_funds( wallets[3].privkey, 5 * 10**8, payment_address )
    if 'error' in res:
        print "failed to fill wallet"
        print json.dumps(res)
        return False
   
    testlib.next_block( **kw )

    # register
    resp = testlib.blockstack_cli_register( "foo.test", "0123456789abcdef" )
    if 'error' in resp:
        print >> sys.stderr, json.dumps(resp, indent=4, sort_keys=True)
        return False
   
    # wait for the preorder to get confirmed
    for i in xrange(0, 12):
        testlib.next_block( **kw )

    # wait for the poller to pick it up
    print >> sys.stderr, "Waiting 10 seconds for the backend to submit the register"
    time.sleep(10)

    # wait for the register to get confirmed 
    for i in xrange(0, 12):
        testlib.next_block( **kw )

    print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge registration"
    time.sleep(10)

    # wait for update to get confirmed 
    for i in xrange(0, 12):
        testlib.next_block( **kw )

    print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge update"
    time.sleep(10)