コード例 #1
0
def scenario( wallets, **kw ):

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

    testlib.ysi_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.ysi_namespace_ready( "id", wallets[1].privkey )
    testlib.next_block( **kw )
    
    wallet = testlib.ysi_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, wallets[4].privkey )
    resp = testlib.ysi_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, 10):
        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 = ysi_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, 10):
        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.ysi_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)
コード例 #2
0
def scenario( wallets, **kw ):

    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 )

    wallet = testlib.ysi_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, wallets[4].privkey )
    for j in xrange(0, 3):
        resp = testlib.ysi_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)
コード例 #3
0
def scenario( wallets, **kw ):

    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 )

    wallet = testlib.ysi_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, None )
    for i in xrange(0, 5):
        resp = testlib.ysi_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)
コード例 #4
0
def scenario(wallets, **kw):

    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)

    # NOTE: the wallets used here used to be wallets[2] and wallets[3]; these were changed in rc-0.14.2
    wallet = testlib.ysi_client_initialize_wallet("0123456789abcdef",
                                                  wallets[3].privkey,
                                                  wallets[4].privkey,
                                                  wallets[2].privkey)
    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(15)

    # 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(15)
コード例 #5
0
ファイル: issue469_1.py プロジェクト: Deutsch4534/ysi_main
def scenario(wallets, **kw):

    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)

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

    wallet = testlib.ysi_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.ysi_cli_register("foo.test", "0123456789abcdef")
    if 'error' in resp:
        import sys
        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)
コード例 #6
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)

    # pre-0.13 wallet
    legacy_wallet = testlib.make_legacy_014_wallet(wallets[2].privkey,
                                                   wallets[4].privkey,
                                                   wallets[0].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)
コード例 #7
0
def scenario(wallets, **kw):

    global zonefile_hash

    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)

    wallet = testlib.ysi_client_initialize_wallet("0123456789abcdef",
                                                  wallets[2].privkey,
                                                  wallets[3].privkey,
                                                  wallets[4].privkey)
    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):
        # 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 = ysi_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 = ysi_client.zonefile.make_empty_zonefile("foo.test", data_pubkey)
    ysi_client.user.put_immutable_data_zonefile(
        zonefile,
        "testdata",
        ysi_client.get_data_hash("testdata"),
        data_url="file:///testdata")
    zonefile_json = json.dumps(zonefile)

    resp = testlib.ysi_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)

    # revoke it
    resp = testlib.ysi_cli_revoke("foo.test", "0123456789abcdef")
    if 'error' in resp:
        print >> sys.stderr, "Revoke 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 revoke"
    time.sleep(10)

    # wait for it to go through
    for i in xrange(0, 12):
        testlib.next_block(**kw)
コード例 #8
0
def scenario(wallets, **kw):

    global zonefile_hash

    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)

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

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

    resp = testlib.ysi_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)

    # transfer to a new address
    resp = testlib.ysi_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(10)

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

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

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

    resp = testlib.ysi_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)
コード例 #9
0
def scenario(wallets, **kw):

    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)

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

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

    res = testlib.ysi_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
コード例 #10
0
def scenario(wallets, **kw):

    global put_result, wallet_keys, wallet_keys_2, datasets, zonefile_hash, dataset_change

    # make a storage gateway (will be port 16300)
    res = testlib.peer_setup(0)
    if 'error' in res:
        return res

    storage_gateway_working_dir = res['working_dir']
    storage_gateway_config_path = res['config_path']

    # make sure the storage gateway saves to disk
    # ysi_client.config.
    res = peer_start(storage_gateway_wd, args=['--foreground', '--no-indexer'])

    # start storage gateway
    # res = testlib.peer_start(

    # set up client
    wallet_keys = testlib.ysi_client_initialize_wallet("0123456789abcdef",
                                                       wallets[2].privkey,
                                                       wallets[3].privkey,
                                                       wallets[4].privkey)

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

    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)

    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 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 for the backend to acknowledge registration"
    time.sleep(10)

    # wait for initial update to get confirmed
    for i in xrange(0, 12):
        # 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 for the backend to acknowledge update"
    time.sleep(10)

    # wait for zonefile/profile replication
    for i in xrange(0, 12):
        testlib.next_block(**kw)

    print >> sys.stderr, "Waiting for the backend to replicate zonefile and profile"
    time.sleep(10)

    # make a few accounts
    res = testlib.ysi_cli_put_account("foo.test",
                                      "serviceFoo",
                                      "serviceFooID",
                                      "foo://bar.com",
                                      "0123456789abcdef",
                                      extra_data='foofield=foo!',
                                      wallet_keys=wallet_keys)
    if 'error' in res:
        res['test'] = 'Failed to create foo.test serviceFoo account'
        print json.dumps(res, indent=4, sort_keys=True)
        error = True
        return

    time.sleep(2)

    res = testlib.ysi_cli_put_account("foo.test",
                                      "serviceBar",
                                      "serviceBarID",
                                      "bar://baz.com",
                                      "0123456789abcdef",
                                      extra_data='barfield=bar!',
                                      wallet_keys=wallet_keys)
    if 'error' in res:
        res['test'] = 'Failed to create foo.test serviceBar account'
        print json.dumps(res, indent=4, sort_keys=True)
        error = True
        return

    time.sleep(2)

    # put some data
    put_result = testlib.ysi_cli_put_mutable("foo.test",
                                             "hello_world_1",
                                             json.dumps(datasets[0]),
                                             password="******")
    if 'error' in put_result:
        print json.dumps(put_result, indent=4, sort_keys=True)
        return False

    time.sleep(2)

    put_result = testlib.ysi_cli_put_mutable("foo.test",
                                             "hello_world_2",
                                             json.dumps(datasets[1]),
                                             password="******")
    if 'error' in put_result:
        print json.dumps(put_result, indent=4, sort_keys=True)
        return False

    time.sleep(2)

    put_result = testlib.ysi_cli_put_mutable("foo.test",
                                             "hello_world_3",
                                             json.dumps(datasets[2]),
                                             password="******")
    if 'error' in put_result:
        print json.dumps(put_result, indent=4, sort_keys=True)
        return False

    time.sleep(2)

    # increment data 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.ysi_cli_put_mutable("foo.test",
                                                 "hello_world_1",
                                                 json.dumps(datasets[0]),
                                                 password="******")
        if 'error' in put_result:
            print json.dumps(put_result, indent=4, sort_keys=True)
            return False

        time.sleep(2)

    testlib.next_block(**kw)
コード例 #11
0
def scenario(wallets, **kw):

    global zonefile_hash, final_balance, new_expire_block

    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)

    wallet = testlib.ysi_client_initialize_wallet("0123456789abcdef",
                                                  wallets[2].privkey,
                                                  wallets[3].privkey,
                                                  wallets[4].privkey)
    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):
        # 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 = ysi_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 = ysi_client.zonefile.make_empty_zonefile("foo.test", data_pubkey)
    ysi_client.user.put_immutable_data_zonefile(
        zonefile,
        "testdata",
        ysi_client.get_data_hash("testdata"),
        data_url="file:///testdata")
    zonefile_json = json.dumps(zonefile)

    resp = testlib.ysi_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.ysi_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)

    # wait for it to go through
    for i in xrange(0, 6):
        # 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)

    # verify that it's in the queue
    queue_state = testlib.ysi_cli_info()
    if 'error' in queue_state:
        print json.dumps(queue_state)
        return False

    if not queue_state.has_key('queues'):
        print 'no queues'
        print json.dumps(queue_state)
        return False

    if not queue_state['queues'].has_key('renew'):
        print 'no renew queue'
        print json.dumps(queue_state)
        return False

    if len(queue_state['queues']['renew']) != 1:
        print 'wrong renew state'
        print json.dumps(queue_state)
        return False

    if queue_state['queues']['renew'][0]['name'] != 'foo.test':
        print 'wrong name'
        print json.dumps(queue_state)
        return False

    # wait for it to go through
    for i in xrange(0, 6):
        # 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)

    proxy = testlib.make_proxy()
    res = ysi_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

    new_expire_block = res['expire_block']
    if old_expire_block >= new_expire_block + 12:
        # didn't go through
        print >> sys.stderr, "Renewal didn't go through: %s --> %s" % (
            old_expire_block, new_expire_block)
        return False

    if res['op'] != ysi_client.config.NAME_REGISTRATION + ":":
        print >> sys.stderr, "Renewal didn't go through (last op is %s)" % res[
            'op']
        error = True
        return False

    final_balance = testlib.getbalance(wallets[2].addr)
コード例 #12
0
def scenario(wallets, **kw):

    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)

    driver_urls = ysi_client.storage.make_mutable_data_urls(
        'foo.test', use_only=['dht', 'disk'])
    zonefile = ysi_client.zonefile.make_empty_zonefile('foo.test',
                                                       wallets[4].pubkey_hex,
                                                       urls=driver_urls)
    zonefile_txt = ysi_zones.make_zone_file(zonefile,
                                            origin='foo.test',
                                            ttl=3600)

    wallet = testlib.ysi_client_initialize_wallet("0123456789abcdef",
                                                  wallets[2].privkey,
                                                  wallets[3].privkey,
                                                  wallets[4].privkey)
    resp = testlib.ysi_cli_register("foo.test",
                                    "0123456789abcdef",
                                    zonefile=zonefile_txt,
                                    recipient_address=wallets[4].addr)
    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)

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

    print >> sys.stderr, "Waiting 10 seconds for the backend to acknowledge transfer"
    time.sleep(10)
コード例 #13
0
def scenario(wallets, **kw):

    global zonefile_hash

    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)

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

    # store a new zonefile
    data_pubkey = wallet['data_pubkey']
    zonefile = ysi_client.zonefile.make_empty_zonefile("foo.test", data_pubkey)
    assert ysi_client.user.put_immutable_data_zonefile(
        zonefile, "testdata", ysi_client.get_data_hash("testdata"))

    zonefile_txt = ysi_zones.make_zone_file(zonefile)
    zonefile_hash = ysi_client.storage.get_zonefile_data_hash(zonefile_txt)

    print >> sys.stderr, "\n\nzonefile hash: %s\nzonefile:\n%s\n\n" % (
        zonefile_hash, zonefile_txt)

    # will store to queue
    test_proxy = testlib.make_proxy()
    config_path = test_proxy.config_path
    conf = ysi_client.config.get_config(config_path)
    queuedb_path = conf['queue_path']

    # update the zonefile hash, but not the zonefile.
    resp = testlib.ysi_cli_set_zonefile_hash("foo.test", zonefile_hash)
    if 'error' in resp:
        print >> sys.stderr, "\nFailed to set zonefile hash: %s\n" % resp
        return False

    txhash = resp['transaction_hash']
    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)

    # stop endpoint
    print >> sys.stderr, "\nstopping RPC daemon\n"
    testlib.stop_api()
    time.sleep(3)

    # store to queue
    res = ysi_client.backend.queue.queue_append(
        "update",
        "foo.test",
        txhash,
        payment_address=wallets[2].addr,
        owner_address=wallets[3].addr,
        config_path=test_proxy.config_path,
        zonefile_data=zonefile_txt,
        zonefile_hash=zonefile_hash,
        path=queuedb_path)

    # verify that we can sync the zonefile, using the in-queue zonefile
    resp = testlib.ysi_cli_sync_zonefile("foo.test")
    if 'error' in resp:
        print >> sys.stderr, "\nfailed to sync zonefile: %s\n" % resp
        return False

    ysi_client.backend.queue.queuedb_remove("update",
                                            "foo.test",
                                            txhash,
                                            path=queuedb_path)

    print >> sys.stderr, "\nstarting RPC daemon\n"
    testlib.start_api("0123456789abcdef")

    # store a new zonefile
    zonefile = ysi_client.zonefile.make_empty_zonefile("foo.test", data_pubkey)
    ysi_client.user.put_immutable_data_zonefile(
        zonefile, "testdata2", ysi_client.get_data_hash("testdata"))

    zonefile_txt = ysi_zones.make_zone_file(zonefile)
    zonefile_hash = ysi_client.storage.get_zonefile_data_hash(zonefile_txt)

    # store locally
    res = ysi_client.zonefile.store_name_zonefile("foo.test",
                                                  zonefile,
                                                  None,
                                                  storage_drivers=['disk'])
    if 'error' in res:
        print >> sys.stderr, "\nFailed to store zonefile: %s\n" % res
        return False

    # update the zonefile hash, but not the zonefile.
    resp = testlib.ysi_cli_set_zonefile_hash("foo.test", zonefile_hash)
    if 'error' in resp:
        print >> sys.stderr, "\nFailed to set zonefile hash: %s\n" % resp
        return False

    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)

    # verify that we can sync the zonefile, using the on-disk zonefile
    resp = testlib.ysi_cli_sync_zonefile("foo.test")

    if 'error' in resp:
        print >> sys.stderr, "update 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 acknowedge the update"
    time.sleep(10)
コード例 #14
0
def scenario(wallets, **kw):

    global zonefile_hash

    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)

    wallet = testlib.ysi_client_initialize_wallet("0123456789abcdef",
                                                  wallets[2].privkey,
                                                  wallets[3].privkey,
                                                  wallets[0].privkey)
    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(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.ysi_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)
コード例 #15
0
def scenario( wallets, **kw ):

    global owner_address, payment_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 )

    payment_address = wallets[5].addr
    owner_address = wallets[6].addr

    testlib.delete_wallet()
    wallet_files = testlib.list_wallet_backups()
    if len(wallet_files) > 0:
        print "still have {}".format(wallet_files)
        return False

    # import a single-sig wallet, with a data key
    payment_str = "{},{},{},{},{}".format(2,3,wallets[5].pks[0],wallets[5].pks[1],wallets[5].pks[2])
    owner_str = "{},{},{},{},{}".format(2,3,wallets[6].pks[0],wallets[6].pks[1],wallets[6].pks[2])

    res = testlib.ysi_cli_import_wallet( "0123456789abcdef", payment_str, owner_str, wallets[4].privkey )
    if 'error' in res:
        print json.dumps(res, indent=4, sort_keys=True)
        return False

    # should still be none
    wallet_files = testlib.list_wallet_backups()
    if len(wallet_files) > 0:
        print "still have {} after import".format(wallet_files)
        return False

    testlib.start_api("0123456789abcdef")

    # 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)
コード例 #16
0
def scenario(wallets, **kw):

    global put_result, wallet_keys, wallet_keys_2, datasets, zonefile_hash, dataset_change

    # set up a second client
    config_path = os.environ.get("BLOCKSTACK_CLIENT_CONFIG", None)
    assert config_path

    config_dir_2 = os.path.dirname(config_path) + '.2'
    os.makedirs(config_dir_2)

    config_path_2 = os.path.join(config_dir_2, 'client.ini')

    res = testlib.peer_make_config(16300, config_dir_2)
    if 'error' in res:
        print "failed to set up {}".format(config_dir_2)
        return False

    wallet_keys_2 = testlib.ysi_client_initialize_wallet(
        "0123456789abcdef", wallets[5].privkey, wallets[6].privkey,
        wallets[7].privkey)
    wallet_keys = testlib.ysi_client_initialize_wallet("0123456789abcdef",
                                                       wallets[2].privkey,
                                                       wallets[3].privkey,
                                                       wallets[4].privkey)

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

    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)

    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 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 for the backend to acknowledge registration"
    time.sleep(10)

    # wait for initial update to get confirmed
    for i in xrange(0, 12):
        # 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 for the backend to acknowledge update"
    time.sleep(10)

    # wait for zonefile/profile replication
    for i in xrange(0, 12):
        testlib.next_block(**kw)

    print >> sys.stderr, "Waiting for the backend to replicate zonefile and profile"
    time.sleep(10)

    # make a few accounts
    res = testlib.ysi_cli_put_account("foo.test",
                                      "serviceFoo",
                                      "serviceFooID",
                                      "foo://bar.com",
                                      "0123456789abcdef",
                                      extra_data='foofield=foo!',
                                      wallet_keys=wallet_keys)
    if 'error' in res:
        res['test'] = 'Failed to create foo.test serviceFoo account'
        print json.dumps(res, indent=4, sort_keys=True)
        error = True
        return

    time.sleep(2)

    res = testlib.ysi_cli_put_account("foo.test",
                                      "serviceBar",
                                      "serviceBarID",
                                      "bar://baz.com",
                                      "0123456789abcdef",
                                      extra_data='barfield=bar!',
                                      wallet_keys=wallet_keys)
    if 'error' in res:
        res['test'] = 'Failed to create foo.test serviceBar account'
        print json.dumps(res, indent=4, sort_keys=True)
        error = True
        return

    time.sleep(2)

    # put some data
    put_result = testlib.ysi_cli_put_mutable("foo.test",
                                             "hello_world_1",
                                             json.dumps(datasets[0]),
                                             password="******")
    if 'error' in put_result:
        print json.dumps(put_result, indent=4, sort_keys=True)
        return False

    time.sleep(2)

    put_result = testlib.ysi_cli_put_mutable("foo.test",
                                             "hello_world_2",
                                             json.dumps(datasets[1]),
                                             password="******")
    if 'error' in put_result:
        print json.dumps(put_result, indent=4, sort_keys=True)
        return False

    time.sleep(2)

    put_result = testlib.ysi_cli_put_mutable("foo.test",
                                             "hello_world_3",
                                             json.dumps(datasets[2]),
                                             password="******")
    if 'error' in put_result:
        print json.dumps(put_result, indent=4, sort_keys=True)
        return False

    time.sleep(2)

    # increment data 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.ysi_cli_put_mutable("foo.test",
                                                 "hello_world_1",
                                                 json.dumps(datasets[0]),
                                                 password="******")
        if 'error' in put_result:
            print json.dumps(put_result, indent=4, sort_keys=True)
            return False

        time.sleep(2)

    testlib.next_block(**kw)
コード例 #17
0
def scenario( wallets, **kw ):

    global preorder_info, register_info, update_info, balance_before, balance_after, names_owned_before, names_owned_after, whois, blockchain_record, deposit_info, price_info
    global blockchain_history, zonefile_info, all_names_info, namespace_names_info, wallet_info, lookup_info, update_history, zonefile_history, names_info

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

    balance_before = testlib.ysi_cli_balance()
    deposit_info = testlib.ysi_cli_deposit()
    price_info = testlib.ysi_cli_price( "foo.test", password="******" )
    wallet_info = testlib.ysi_cli_wallet( "0123456789abcdef" ) 

    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, 5):
        testlib.next_block( **kw )

    # queued?
    preorder_info = testlib.ysi_cli_info()
    names_owned_before = testlib.ysi_cli_get_names_owned_by_address( wallets[3].addr )

    for i in xrange(0, 7):
        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, 5):
        testlib.next_block( **kw )

    # registered?
    register_info = testlib.ysi_cli_info()
    names_info = testlib.ysi_cli_names()

    for i in xrange(0, 7):
        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, 5):
        testlib.next_block( **kw )

    update_info = testlib.ysi_cli_info()
    names_owned_after = testlib.ysi_cli_get_names_owned_by_address( wallets[3].addr )
    whois = testlib.ysi_cli_whois( "foo.test" )

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

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

    # put some immutable data 
    put_immutable_info = testlib.ysi_cli_put_immutable( "foo.test", "hello_world", '{"hello": "world"}' )    
    if 'error' in put_immutable_info:
        print "put_immutable failed"
        print json.dumps(put_immutable_info, indent=4, sort_keys=True)
        return False

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

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

    balance_after = testlib.ysi_cli_balance()
    blockchain_history = testlib.ysi_cli_get_name_blockchain_history( "foo.test" )
    zonefile_info = testlib.ysi_cli_get_name_zonefile( "foo.test", json=False )
    all_names_info = testlib.ysi_cli_get_all_names(0)
    namespace_names_info = testlib.ysi_cli_get_names_in_namespace("test", 0)
    lookup_info = testlib.ysi_cli_lookup( "foo.test" )
    update_history = testlib.ysi_cli_list_update_history( "foo.test" )
    zonefile_history = testlib.ysi_cli_list_zonefile_history( "foo.test" )
    blockchain_record = testlib.ysi_cli_get_name_blockchain_record( "foo.test" )