• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python testlib.blockstack_client_initialize_wallet函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中testlib.blockstack_client_initialize_wallet函数的典型用法代码示例。如果您正苦于以下问题:Python blockstack_client_initialize_wallet函数的具体用法?Python blockstack_client_initialize_wallet怎么用?Python blockstack_client_initialize_wallet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了blockstack_client_initialize_wallet函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: scenario

def scenario( wallets, **kw ):

    global zonefile_hash

    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 )

    wallet = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, None )
    resp = testlib.blockstack_rpc_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)

    # transfer to a new address 
    resp = testlib.blockstack_rpc_transfer( "foo.test", wallets[4].addr, "0123456789abcdef" )

    if 'error' in resp:
        print >> sys.stderr, "transfer error: %s" % resp['error']
        return False

    # wait for it to go through 
    for i in xrange(0, 12):
        testlib.next_block( **kw )

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

    testlib.next_block(**kw)
开发者ID:odinho,项目名称:blockstack-integration-tests,代码行数:56,代码来源:rpc_register_transfer.py


示例2: scenario

def scenario( wallets, **kw ):

    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 )

    wallet = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, wallets[4].privkey )
    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)

    # let's make sure the zonefile propagates...

    res = testlib.blockstack_REST_call("GET", "/v1/names/foo.test", None)
    if 'error' in res or res['http_status'] != 200:
        res['test'] = 'Failed to get name bar.test'
        print json.dumps(res)
        return False

    response_json = json.loads(res['raw'])

    # assert that we're getting a mainnet address
    if response_json['address'] != "1K4SCfqffVHTnHvqsW2whH1Jn57dDjDdQA":
        print "Address returned to REST call isn't converted to mainnet!"
        print "Returned: {}, Expected: {}".format(response_json['address'], "1K4SCfqffVHTnHvqsW2whH1Jn57dDjDdQA")
        return False
开发者ID:destenson,项目名称:blockstack--blockstack-server,代码行数:54,代码来源:convert_regtest_to_mainnet_name.py


示例3: scenario

def scenario( wallets, **kw ):

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

    testlib.blockstack_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.blockstack_namespace_ready( "id", wallets[1].privkey )
    testlib.next_block( **kw )
    
    wallet = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, wallets[4].privkey )
    resp = testlib.blockstack_cli_register( "foo.id", "0123456789abcdef", 
                                            recipient_address = 'mi8mUNSFC9EoGXmjPF8vKqCUSfGE2fbD4V')
    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)

    r = blockstack_client.actions.cli_get_registrar_info(None)
    assert 'errors' not in r['register'][0]

    # 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 the update to go off
    for i in xrange(0, 8):
        testlib.next_block( **kw )
    
    # drain the wallet
    print >> sys.stderr, "Lets drain the wallet."
    testlib.blockstack_cli_withdraw( "0123456789abcdef", 'mi8mUNSFC9EoGXmjPF8vKqCUSfGE2fbD4V' )
    print >> sys.stderr, "Drained!"

    for i in xrange(0, 11):
        testlib.next_block( **kw )

    print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge update"
    time.sleep(10)
开发者ID:destenson,项目名称:blockstack--blockstack-server,代码行数:50,代码来源:name_transfer_not_enough_coin.py


示例4: scenario

def scenario( wallets, **kw ):

    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 )

    wallet = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, wallets[4].privkey )
    for j in xrange(0, 3):
        resp = testlib.blockstack_cli_register( "foo_%s.test" % j, "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 them up
        print >> sys.stderr, "Waiting 10 seconds for the backend to submit the registers on foo_%s.test" % j
        time.sleep(10)

        # wait for the registers to get confirmed 
        for i in xrange(0, 15):
            # tell serialization-checker that value_hash can be ignored here
            print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash"
            sys.stdout.flush()
            
            testlib.next_block( **kw )

        print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge registrations on foo_%s.test" % j
        time.sleep(10)

        # wait for update to get confirmed 
        for i in xrange(0, 15):
            # warn the serialization checker that this changes behavior from 0.13
            print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash"
            sys.stdout.flush()
            
            testlib.next_block( **kw )

        print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge update on foo_%s.test" % j
        time.sleep(10)
开发者ID:destenson,项目名称:blockstack--blockstack-server,代码行数:47,代码来源:rpc_register_multi_sequential.py


示例5: scenario

def scenario( wallets, **kw ):

    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 )

    wallet = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, None )
    for i in xrange(0, 5):
        resp = testlib.blockstack_cli_register( "foo_%s.test" % i, "0123456789abcdef" )
        if 'error' in resp:
            print >> sys.stderr, json.dumps(resp, indent=4, sort_keys=True)
            return False
       
        
        # wait for tx confirmation
        # (takes a few secs)
        for i in xrange(0, 6):
            testlib.next_block( **kw )

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

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


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

    print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge registrations"
    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)
开发者ID:blockstack,项目名称:blockstack-integration-tests,代码行数:47,代码来源:rpc_register_multi_parallel.py


示例6: scenario

def scenario( wallets, **kw ):

    # save the wallet 
    wallet = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, wallets[4].privkey )
    if 'error' in wallet:
        print 'failed to set wallet: {}'.format(wallet)
        return False

    config_path = os.environ.get("BLOCKSTACK_CLIENT_CONFIG", None)
    config_dir = os.path.dirname(config_path)
     
    conf = blockstack_client.get_config(config_path)
    assert conf

    api_pass = conf['api_password']

    if not check_wallet(wallets[2].privkey, wallets[3].privkey, wallets[4].privkey):
        return False

    res = testlib.blockstack_REST_call('PUT', '/v1/wallet/keys/owner', None, api_pass=api_pass, data=wallets[0].privkey)
    if 'error' in res:
        print 'failed to set owner key'
        print res
        return False
       
    if not check_wallet(wallets[2].privkey, wallets[0].privkey, wallets[4].privkey):
        return False

    res = testlib.blockstack_REST_call('PUT', '/v1/wallet/keys/payment', None, api_pass=api_pass, data=wallets[1].privkey)
    if 'error' in res:
        print 'failed to set payment key'
        print res
        return False

    if not check_wallet(wallets[1].privkey, wallets[0].privkey, wallets[4].privkey):
        return False

    res = testlib.blockstack_REST_call('PUT', '/v1/wallet/keys/data', None, api_pass=api_pass, data=wallets[2].privkey)
    if 'error' in res:
        print 'failed to set payment key'
        print res
        return False

    if not check_wallet(wallets[1].privkey, wallets[0].privkey, wallets[2].privkey):
        return False
开发者ID:destenson,项目名称:blockstack--blockstack-server,代码行数:45,代码来源:wallet_set_keys.py


示例7: scenario

def scenario( wallets, **kw ):

    # save the wallet 
    wallet = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, wallets[4].privkey, start_rpc=False )
    if 'error' in wallet:
        print 'failed to set wallet: {}'.format(wallet)
        return False

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

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

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

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

    # start api server 
    res = testlib.start_api("0123456789abcdef")
    if 'error' in res:
        print 'failed to start API server: {}'.format(res)
        return False

    # set up node environment 
    nodedir = testlib.nodejs_setup()

    # run 'core-test' test on blockstack (tests authentication from blockstack.js to Core API)
    testlib.nodejs_copy_package(nodedir, "blockstack")
    testlib.nodejs_copy_package(nodedir, "blockstack-storage")
    testlib.nodejs_run_test(nodedir, "integration-test-storage")
    testlib.nodejs_cleanup(nodedir)
开发者ID:destenson,项目名称:blockstack--blockstack-server,代码行数:37,代码来源:name_preorder_register_portal_datastore.py


示例8: scenario

def scenario( wallets, **kw ):

    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 )

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

    wallet = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, wallets[4].privkey )

    args = ARGS()

    ret = actions.cli_withdraw(args, "0123456789abcdef", False)

    print ret

    tx = ret['tx']

    # these should end up having the SAME utxo.

    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


    testlib.next_block( **kw )
    testlib.broadcast_tx(tx)

    for i in xrange(0, 12):
        testlib.next_block( **kw )
开发者ID:destenson,项目名称:blockstack--blockstack-server,代码行数:37,代码来源:issue469_1.py


示例9: scenario

def scenario( wallets, **kw ):

    global zonefile_hash

    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 )

    wallet = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, wallets[0].privkey )
    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(15)

    # wait for the register to get confirmed 
    for i in xrange(0, 12):
        # warn the serialization checker that this changes behavior from 0.13
        print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash"
        sys.stdout.flush()
        
        testlib.next_block( **kw )

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

    # wait for update to get confirmed 
    for i in xrange(0, 12):
        # warn the serialization checker that this changes behavior from 0.13
        print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash"
        sys.stdout.flush()
        
        testlib.next_block( **kw )

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

    # transfer to a new address 
    resp = testlib.blockstack_cli_transfer( "foo.test", wallets[4].addr, "0123456789abcdef" )

    if 'error' in resp:
        print >> sys.stderr, "transfer error: %s" % resp['error']
        return False

    # wait for it to go through 
    for i in xrange(0, 12):
        # warn the serialization checker that this changes behavior from 0.13
        print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash"
        sys.stdout.flush()

        testlib.next_block( **kw )

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

    testlib.next_block(**kw)
开发者ID:destenson,项目名称:blockstack--blockstack-server,代码行数:68,代码来源:rpc_register_transfer_multisig.py


示例10: scenario

def scenario( wallets, **kw ):

    global zonefile_hash, final_balance, new_expire_block

    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 )

    wallet = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, wallets[4].privkey )
    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):
        # warn the serialization checker that this changes behavior from 0.13
        print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash"
        sys.stdout.flush()
        
        testlib.next_block( **kw )

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

    # wait for initial update to get confirmed 
    for i in xrange(0, 12):
        # warn the serialization checker that this changes behavior from 0.13
        print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash"
        sys.stdout.flush()
        
        testlib.next_block( **kw )

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

    # what's the name's renewal block?
    proxy = testlib.make_proxy()
    res = blockstack_client.get_name_blockchain_record( "foo.test", proxy=proxy )
    if 'error' in res:
        print >> sys.stderr, json.dumps(res, indent=4, sort_keys=True)
        return False
    
    old_expire_block = res['expire_block']

    # send an update, changing the zonefile
    data_pubkey = wallet['data_pubkey']
    zonefile = blockstack_client.zonefile.make_empty_zonefile( "foo.test", data_pubkey )
    blockstack_client.user.put_immutable_data_zonefile( zonefile, "testdata", blockstack_client.get_data_hash("testdata"), data_url="file:///testdata")
    zonefile_json = json.dumps(zonefile)

    resp = testlib.blockstack_cli_update( "foo.test", zonefile_json, "0123456789abcdef" )
    
    if 'error' in resp:
        print >> sys.stderr, "update error: %s" % resp['error']
        return False

    zonefile_hash = resp['zonefile_hash']
    
    # wait for it to go through 
    for i in xrange(0, 12):
        # warn the serialization checker that this changes behavior from 0.13
        print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash"
        sys.stdout.flush()
        
        testlib.next_block( **kw )

    print >> sys.stderr, "Waiting 10 seconds for the backend to acknowedge the update"
    time.sleep(10)
    # wait for it to go through 
    for i in xrange(0, 12):
        # warn the serialization checker that this changes behavior from 0.13
        print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash"
        sys.stdout.flush()
        
        testlib.next_block( **kw )

    # renew it 
    resp = testlib.blockstack_cli_renew( "foo.test", "0123456789abcdef" )
    if 'error' in resp:
        print >> sys.stderr, "Renewal request failed:\n%s" % json.dumps(resp, indent=4, sort_keys=True)
        return False

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

#.........这里部分代码省略.........
开发者ID:destenson,项目名称:blockstack--blockstack-server,代码行数:101,代码来源:rpc_register_renew.py


示例11: scenario

def scenario( wallets, **kw ):

    global wallet_keys, wallet_keys_2, error, index_file_data, resource_data

    wallet_keys = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[5].privkey, wallets[3].privkey, wallets[4].privkey )
    test_proxy = testlib.TestAPIProxy()
    blockstack_client.set_default_proxy( test_proxy )

    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 )

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

    test_proxy = testlib.TestAPIProxy()
    blockstack_client.set_default_proxy( test_proxy )

    testlib.blockstack_client_set_wallet( "0123456789abcdef", wallets[5].privkey, wallets[3].privkey, wallets[4].privkey )
    
    # migrate profiles 
    res = testlib.migrate_profile( "foo.test", proxy=test_proxy, wallet_keys=wallet_keys )
    if 'error' in res:
        res['test'] = 'Failed to initialize foo.test profile'
        print json.dumps(res, indent=4, sort_keys=True)
        error = True
        return 

    # tell serialization-checker that value_hash can be ignored here
    print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash"
    sys.stdout.flush()
    
    testlib.next_block( **kw )

    config_path = os.environ.get("BLOCKSTACK_CLIENT_CONFIG", None)

    # make a session 
    datastore_pk = keylib.ECPrivateKey(wallets[-1].privkey).to_hex()
    res = testlib.blockstack_cli_app_signin(datastore_pk, 'register.app', ['names', 'register', 'prices', 'zonefiles', 'blockchain', 'node_read', 'store_admin', 'store_read', 'store_write'])
    if 'error' in res:
        print json.dumps(res, indent=4, sort_keys=True)
        error = True
        return 

    ses = res['token']

    # make a datastore 
    res = testlib.blockstack_REST_call('POST', '/v1/stores', ses )
    if 'error' in res or res['http_status'] != 200:
        print 'failed to create datastore'
        print json.dumps(res, indent=4, sort_keys=True)
        return False

    # get the data store id
    res = testlib.blockstack_REST_call('GET', '/v1/stores/register.app', ses)
    if 'error' in res or res['http_status'] != 200:
        print 'failed to get store'
        print json.dumps(res, indent=4, sort_keys=True)
        return False

    if 'error' in res['response']:
        print 'failed to get datastore'
        print json.dumps(res, indent=4, sort_keys=True)
        return False

    datastore_info = res['response']
    datastore_name = datastore_info['datastore_id']

    # get the data store name
    res = testlib.blockstack_REST_call('GET', '/v1/stores/register.app', ses)
    if 'error' in res or res['http_status'] != 200:
        print 'failed to get datastore'
        print json.dumps(res, indent=4, sort_keys=True)
        return False

    if 'error' in res['response']:
        print 'failed to get datastore'
        print json.dumps(res, indent=4, sort_keys=True)
        return False

    datastore_info = res['response']
    datastore_name = datastore_info['datastore_id']

    # make directories
    for dpath in ['/dir1', '/dir2', '/dir1/dir3', '/dir1/dir3/dir4']:
        print 'mkdir {}'.format(dpath)
        res = testlib.blockstack_REST_call('POST', '/v1/stores/{}/directories'.format(datastore_name), ses, path=dpath)
        if 'error' in res or res['http_status'] != 200:
            print 'failed to mkdir {}: {}'.format(dpath, res['http_status'])
            return False

    # stat directories 
#.........这里部分代码省略.........
开发者ID:destenson,项目名称:blockstack--blockstack-server,代码行数:101,代码来源:rest_stores_rmtree.py


示例12: scenario

def scenario( wallets, **kw ):

    global wallet_keys, wallet_keys_2, error, index_file_data, resource_data, wallet_balance

    wallet_keys = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[5].privkey, wallets[3].privkey, wallets[4].privkey )
    test_proxy = testlib.TestAPIProxy()
    blockstack_client.set_default_proxy( test_proxy )

    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 )

    testlib.blockstack_name_preorder( "foo.test", wallets[3].privkey, wallets[5].addr )
    testlib.next_block( **kw )
    
    register_resp = testlib.blockstack_name_register( "foo.test", wallets[3].privkey, wallets[5].addr )
    testlib.next_block( **kw )
    
    config_path = os.environ.get("BLOCKSTACK_CLIENT_CONFIG", None)
    config_dir = os.path.dirname(config_path)
 
    conf = blockstack_client.get_config(config_path)
    assert conf

    api_pass = conf['api_password']

    # get utxos for the payer
    payer_utxos = testlib.blockstack_REST_call('GET', '/v1/blockchains/bitcoin/{}/unspent?min_confirmations=1'.format(wallets[3].addr), None, api_pass=api_pass)
    if 'error' in payer_utxos:
        payer_utxos['test'] = 'failed to get utxos'
        print json.dumps(payer_utxos)
        return False

    # have both the test wallet output and the one the NAME_REGISTRATION sent
    if len(payer_utxos['response']) != 1:
        payer_utxos['test'] = 'wrong utxos'
        print json.dumps(payer_utxos)
        return False

    # last transaction should be the register, and it should have been paid with the owner address (since that's how we sent it above)
    if payer_utxos['response'][0]['transaction_hash'] != register_resp['transaction_hash'] or payer_utxos['response'][0]['confirmations'] != 1:
        payer_utxos['test'] = 'invalid utxos (tx_hash, confirmations)'
        print json.dumps(payer_utxos)
        return False

    # get utxos for the owner wallet
    owner_utxos = testlib.blockstack_REST_call('GET', '/v1/blockchains/bitcoin/{}/unspent?min_confirmations=1'.format(wallets[5].addr), None, api_pass=api_pass)
    if 'error' in owner_utxos:
        owner_utxos['test'] = 'failed to get utxos'
        print json.dumps(owner_utxos)
        return False

    # two utxos: one for the initial wallet fill-up from the test framework, and one from the registration 
    if len(owner_utxos['response']) != 2:
        owner_utxos['test'] = 'wrong utxos'
        print json.dumps(owner_utxos)
        return False

    # last transaction should be the register
    found = False
    for utxo in owner_utxos['response']:
        if utxo['transaction_hash'] == register_resp['transaction_hash'] and utxo['confirmations'] == 1:
            found = True

    if not found:
        owner_utxos['test'] = 'invalid utxos (tx_hash, confirmations)'
        print json.dumps(owner_utxos)
        return False

    # verify that min_confirmations=2 hides these transactions
    res = testlib.blockstack_REST_call('GET', '/v1/blockchains/bitcoin/{}/unspent?min_confirmations=2'.format(wallets[5].addr), None, api_pass=api_pass)
    if 'error' in res:
        res['test'] = 'failed to get utxos'
        print json.dumps(res)
        return False

    if len(res['response']) > 1:
        res['test'] = 'got more UTXOs than we expected'
        print json.dumps(res)
        return False

    # count UTXOs in wallets[1]
    res = testlib.blockstack_REST_call('GET', '/v1/blockchains/bitcoin/{}/unspent?min_confirmations=0'.format(wallets[1].addr), None, api_pass=api_pass)
    if 'error' in res:
        res['test'] = 'failed to get utxos'
        print json.dumps(res)
        return False

    initial_utxos = res['response']
    if len(initial_utxos) == 0:
        res['test'] = 'test bug: no UTXOs for wallet'
        print json.dumps(res)
        return False

    # send money from one wallet to another
#.........这里部分代码省略.........
开发者ID:destenson,项目名称:blockstack--blockstack-server,代码行数:101,代码来源:rest_noauth_blockchain.py


示例13: scenario

def scenario( wallets, **kw ):

    # has the side-effect of starting the API server
    resp = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, wallets[4].privkey )
    if 'error' in resp:
        print json.dumps(resp, indent=4, sort_keys=True)
        return False

    resp = testlib.blockstack_cli_namespace_preorder("test", wallets[0].privkey, wallets[1].privkey)
    if 'error' in resp:
        print json.dumps(resp, indent=4, sort_keys=True)
        return False

    testlib.next_block(**kw)

    resp = testlib.blockstack_cli_namespace_reveal('test', wallets[0].privkey, wallets[1].privkey, 52560, 4, 4, '6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0', 10, 10)
    if 'error' in resp:
        print json.dumps(resp, indent=4, sort_keys=True)
        return False

    testlib.next_block(**kw)

    private_keychain = keychain.PrivateKeychain.from_private_key( wallets[1].privkey )
    private_keys = [wallets[1].privkey]     # NOTE: always start with the reveal key, then use children
    for i in xrange(0, 4):
        import_key = private_keychain.child(i).private_key()

        print "fund {} (child {})".format(import_key, i)
        res = testlib.send_funds( wallets[1].privkey, 100000000, virtualchain.BitcoinPrivateKey(import_key).public_key().address() )
        if 'error' in res:
            print json.dumps(res, indent=4, sort_keys=True)
            return False

        testlib.next_block(**kw)
        private_keys.append(import_key)

    # should fail (first key must be revealer)
    resp = testlib.blockstack_cli_name_import("fail.test", wallets[2].addr, "Hello fail.test!", private_keys[1])
    if 'error' not in resp:
        print json.dumps(resp, indent=4, sort_keys=True)
        return False

    # should succeed
    resp = testlib.blockstack_cli_name_import("foo.test", wallets[2].addr, "Hello foo.test!", private_keys[0])
    if 'error' in resp:
        print json.dumps(resp, indent=4, sort_keys=True)
        return False

    testlib.next_block(**kw)
   
    # 3 in one block (zero-conf)
    resp = testlib.blockstack_cli_name_import("bar.test", wallets[3].addr, "Hello bar.test!", private_keys[1])
    if 'error' in resp:
        print json.dumps(resp, indent=4, sort_keys=True)
        return False

    resp = testlib.blockstack_cli_name_import("baz.test", wallets[4].addr, "Hello baz.test!", private_keys[2])
    if 'error' in resp:
        print json.dumps(resp, indent=4, sort_keys=True)
        return False

    resp = testlib.blockstack_cli_name_import("goo.test", wallets[5].addr, "Hello goo.test!", private_keys[3])
    if 'error' in resp:
        print json.dumps(resp, indent=4, sort_keys=True)
        return False

    testlib.next_block(**kw)

    # should fail (wrong key)
    resp = testlib.blockstack_cli_name_import("fail.test", wallets[5].addr, "Hello fail.test!", wallets[2].privkey)
    if 'error' not in resp:
        print json.dumps(resp, indent=4, sort_keys=True)
        return False

    resp = testlib.blockstack_cli_namespace_ready('test', wallets[1].privkey)
    if 'error' in resp:
        print json.dumps(resp, indent=4, sort_keys=True)
        return False

    for i in xrange(0, 10):
        testlib.next_block(**kw)

    print "Waiting 10 seconds for registrar to replicate zone files"
    time.sleep(10)
开发者ID:destenson,项目名称:blockstack--blockstack-server,代码行数:84,代码来源:rpc_namespace_preorder_reveal_import_ready.py


示例14: scenario

def scenario( wallets, **kw ):

    global zonefile_hash

    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 )

    wallet = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, wallets[4].privkey )
    resp = testlib.blockstack_rpc_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)

    # send an update, changing the zonefile
    data_pubkey = wallet['data_pubkey']
    zonefile = blockstack_client.user.make_empty_user_zonefile( "foo.test", data_pubkey )
    blockstack_client.user.put_immutable_data_zonefile( zonefile, "testdata", blockstack_client.get_data_hash("testdata"), data_url="file:///testdata")
    zonefile_json = json.dumps(zonefile)

    resp = testlib.blockstack_rpc_update( "foo.test", zonefile_json, "0123456789abcdef" )
    
    if 'error' in resp:
        print >> sys.stderr, "update error: %s" % resp['error']
        return False

    zonefile_hash = resp['zonefile_hash']
    
    # wait for it to go through 
    for i in xrange(0, 12):
        testlib.next_block( **kw )

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

    # transfer to a new address 
    resp = testlib.blockstack_rpc_transfer( "foo.test", wallets[4].addr, "0123456789abcdef" )

    if 'error' in resp:
        print >> sys.stderr, "transfer error: %s" % resp['error']
        return False

    # wait for it to go through 
    for i in xrange(0, 12):
        testlib.next_block( **kw )

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

    # regenerate the wallet, with the new owner address
    wallet = testlib.blockstack_client_set_wallet( "0123456789abcdef", wallets[2].privkey, wallets[4].privkey, wallets[4].privkey )

    # send another update, changing the zonefile again
    # pay for it using the same payment address
    zonefile = blockstack_client.user.make_empty_user_zonefile( "foo.test", new_data_pubkey )
    blockstack_client.user.put_immutable_data_zonefile( zonefile, "testdata", blockstack_client.get_data_hash("testdata"), data_url="file:///testdata")
    zonefile_json = json.dumps(zonefile)

    resp = testlib.blockstack_rpc_update( "foo.test", zonefile_json, "0123456789abcdef" )
    
    if 'error' in resp:
        print >> sys.stderr, "update error: %s" % resp['error']
        return False

    zonefile_hash = resp['zonefile_hash']
    
    # wait for it to go through 
    for i in xrange(0, 12):
        testlib.next_block( **kw )

    print >> sys.stderr, "Waiting 10 seconds for the backend to acknowedge the update"
    time.sleep(10)
开发者ID:odinho,项目名称:blockstack-integration-tests,代码行数:100,代码来源:rpc_register_update_transfer_update.py


示例15: scenario

def scenario( wallets, **kw ):

    global put_result, wallet_keys, datasets, zonefile_hash, dataset_change

    wallet = testlib.blockstack_client_initialize_wallet( "0123456789abcdef", wallets[5].privkey, wallets[3].privkey, None )
    test_proxy = testlib.TestAPIProxy()
    blockstack_client.set_default_proxy( test_proxy )
    wallet_keys = wallet

    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 )

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

    # migrate profile
    res = testlib.migrate_profile( "foo.test", proxy=test_proxy, wallet_keys=wallet_keys, zonefile_has_data_key=False )
    if 'error' in res:
        res['test'] = 'Failed to initialize foo.test profile'
        print json.dumps(res, indent=4, sort_keys=True)
        error = True
        return 
    else:
        zonefile_hash = res['zonefile_hash']

    # tell serialization-checker that value_hash can be ignored here
    print "BLOCKSTACK_SERIALIZATION_CHECK_IGNORE value_hash"
    sys.stdout.flush()
    
    testlib.next_block( **kw )

    # should fail, since no zone file key
    put_result = testlib.blockstack_cli_put_mutable( "foo.test", "hello_world_1", json.dumps(datasets[0]), password='0123456789abcdef')
    if 'error' not in put_result:
        print 'accidentally put data without a zonefile key'
        print json.dumps(put_result, indent=4, sort_keys=True)
        return False
    
    # should succeed, since we have a given private key
    put_result = testlib.blockstack_cli_put_mutable( "foo.test", "hello_world_1", json.dumps(datasets[0]), password='0123456789abcdef', private_key=wallets[4].privkey )
    if 'error' in put_result:
        print json.dumps(put_result, indent=4, sort_keys=True)
        return False

    testlib.next_block( **kw )

    put_result = testlib.blockstack_cli_put_mutable( "foo.test", "hello_world_2", json.dumps(datasets[1]), password='0123456789abcdef', private_key=wallets[4].privkey )
    if 'error' in put_result:
        print json.dumps(put_result, indent=4, sort_keys=True)
        return False

    put_result = testlib.blockstack_cli_put_mutable( "foo.test", "hello_world_3", json.dumps(datasets[2]), password='0123456789abcdef', private_key=wallets[4].privkey )
    if 'error' in put_result:
        print json.dumps(put_result, indent=4, sort_keys=True)
        return False

    # increment version too
    datasets[0]['buf'] = []
    for i in xrange(0, 5):
        datasets[0]["dataset_change"] = dataset_change
        datasets[0]['buf'].append(i)

        put_result = testlib.blockstack_cli_put_mutable( "foo.test", "hello_world_1", json.dumps(datasets[0]), password='0123456789abcdef', private_key=wallets[4].privkey )
        if 'error' in put_result:
            print json.dumps(put_result, indent=4, sort_keys=True )

    testlib.next_block( **kw )
开发者ID:destenson,项目名称:blockstack--blockstack-server,代码行数:76,代码来源:name_preorder_register_update_putmutable_nozonefilekey.py


示例16: scenario

def scenario( wallets, **kw ):

    global wallet_keys, wallet_keys_2, error, index_file_data, resource_data

    wallet_keys = testlib.blockstack_client_initialize_wallet( "0123456789abcdef&qu 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python testlib.blockstack_name_preorder函数代码示例发布时间:2022-05-27
下一篇:
Python log.LOGGER类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap