def scenario(wallets, **kw):

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

    testlib.next_block(**kw)

    resp = testlib.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)
    if debug or 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)

    # revoke it
    resp = testlib.ysi_name_revoke("foo.test", wallets[3].privkey)
    testlib.next_block(**kw)
Exemple #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)

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

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

    # should fail; not the owner
    resp = testlib.ysi_name_revoke("foo.test",
                                   wallets[4].privkey,
                                   safety_checks=False)
    testlib.next_block(**kw)
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))
Exemple #3
0
def scenario(wallets, **kw):

    global snv_block_id, last_consensus

    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)

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

    snv_block_id = testlib.get_current_block()

    resp = testlib.ysi_name_revoke("foo.test", wallets[3].privkey)
    testlib.next_block(**kw)

    last_consensus = testlib.get_consensus_at(testlib.get_current_block())
Exemple #4
0
def scenario(wallets, **kw):

    global debug

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

    testlib.next_block(**kw)

    resp = testlib.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)
    if debug or 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)

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

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

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

    resp = testlib.ysi_name_revoke("foo.test", wallets[3].privkey)
    print json.dumps(resp, indent=4)
    testlib.next_block(**kw)
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, 10, 250, 4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10,
        wallets[0].privkey)
    testlib.next_block(**kw)

    testlib.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)

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

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

    testlib.next_block(**kw)

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

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

    testlib.next_block(**kw)
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))

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

    testlib.next_block(**kw)
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))

    # should fail
    resp = testlib.ysi_name_renew("foo.test",
                                  wallets[3].privkey,
                                  safety_checks=False,
                                  tx_fee=10000 * 5)
    if 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))

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

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

    testlib.next_block(**kw)
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))

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

    testlib.next_block(**kw)
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))

    # should fail
    resp = testlib.ysi_name_renew("foo.test",
                                  wallets[3].privkey,
                                  safety_checks=False,
                                  tx_fee=10000 * 5)
    if 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))

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

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)

    # re-update
    resp = testlib.ysi_name_update("foo.test",
                                   "11" * 20,
                                   wallets[0].privkey,
                                   safety_checks=False)
    if 'error' in resp:
        print json.dumps(resp, indent=4)

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

    global fail_blocks

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

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

    testlib.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)

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

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

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

    testlib.next_block(**kw)
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))

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

    testlib.next_block(**kw)
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))

    # should fail
    resp = testlib.ysi_name_renew("foo.test",
                                  wallets[3].privkey,
                                  safety_checks=False,
                                  tx_fee=10000 * 5)
    if 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))

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

    # verify that operations continue to fail (BUG in 0.13: THIS SUCCEEDS WHEN IT SHOULD FAIL)
    resp = testlib.ysi_name_update("foo.test",
                                   "11" * 20,
                                   wallets[3].privkey,
                                   safety_checks=False)
    if 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)
    fail_blocks.append(testlib.get_current_block(**kw))
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))

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

    testlib.next_block(**kw)
    fail_blocks.append(testlib.get_current_block(**kw))
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))

    # should fail
    resp = testlib.ysi_name_renew("foo.test",
                                  wallets[3].privkey,
                                  safety_checks=False,
                                  tx_fee=10000 * 5)
    if 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)
    fail_blocks.append(testlib.get_current_block(**kw))
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))

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

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)

    # warn the serialization checker that this changes behavior from 0.13
    print "BLOCKSTACK_SERIALIZATION_CHANGE_BEHAVIOR"
    sys.stdout.flush()
def scenario(wallets, **kw):

    global register_block, revoke_block

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

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)

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

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

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)

    revoke_block = testlib.get_current_block(**kw)

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

    # re-register
    testlib.ysi_name_preorder("foo.test", wallets[7].privkey, wallets[8].addr)
    testlib.next_block(**kw)

    testlib.ysi_name_register("foo.test", wallets[7].privkey, wallets[8].addr)
    testlib.next_block(**kw)

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

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

    testlib.next_block(**kw)

    resp = testlib.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)
    if debug or 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)

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

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

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

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

    testlib.next_block(**kw)

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

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

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

    testlib.next_block(**kw)

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

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

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

    testlib.next_block(**kw)

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

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

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

    testlib.next_block(**kw)

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

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

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

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

    testlib.next_block(**kw)

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

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

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

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

    global fail_blocks

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

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

    testlib.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)

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

    # wait for it to expire...
    for i in xrange(0, 2 * NAMESPACE_LIFETIME_MULTIPLIER + 1):
        testlib.next_block(**kw)

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

    testlib.next_block(**kw)
    fail_blocks.append(testlib.get_current_block(**kw))
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))

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

    testlib.next_block(**kw)
    fail_blocks.append(testlib.get_current_block(**kw))
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))

    # should fail
    resp = testlib.ysi_name_renew("foo.test",
                                  wallets[3].privkey,
                                  safety_checks=False,
                                  tx_fee=10000 * 5)
    if 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)
    fail_blocks.append(testlib.get_current_block(**kw))
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))

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

    testlib.next_block(**kw)
    fail_blocks.append(testlib.get_current_block(**kw))
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))
def scenario(wallets, **kw):

    global debug, consensus, small_unspents

    res = check_utxo_consumption(
        "test", wallets[0], wallets[1], wallets[2],
        ['namespace_preorder', 'namespace_reveal', 'namespace_ready'],
        wallets[1].addr, **kw)
    if 'error' in res:
        return False

    expected_utxo_count = res['expected_utxo_count']

    # do the preorder
    resp = testlib.ysi_namespace_preorder("test", wallets[1].addr,
                                          wallets[0].privkey)
    if debug or 'error' in resp:
        print simplejson.dumps(resp, indent=4)

    testlib.next_block(**kw)

    # verify that all the small UTXOs are NOT consumed
    bitcoind = testlib.connect_bitcoind()
    bitcoind.ping()

    txdata = bitcoind.getrawtransaction(resp['transaction_hash'], 1)
    if len(txdata['vin']) != 1:
        print simplejson.dumps(txdata, indent=4)
        print "wrong number of inputs: {} != 1".format(len(txdata['vin']))
        return False

    if spent_small_transaction(resp['transaction_hash']):
        return False

    # finish ordering the namespace
    resp = 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)
    if debug or 'error' in resp:
        print simplejson.dumps(resp, indent=4)

    if spent_small_transaction(resp['transaction_hash']):
        return False

    testlib.next_block(**kw)

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

    if spent_small_transaction(resp['transaction_hash']):
        return False

    testlib.next_block(**kw)

    res = check_utxo_consumption(
        "foo.test", wallets[2], wallets[3], wallets[4],
        ['preorder', 'register', 'update', 'transfer'], wallets[4].addr, **kw)
    if 'error' in res:
        return False

    expected_utxo_count = res['expected_utxo_count']

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

    if spent_small_transaction(resp['transaction_hash']):
        return False

    testlib.next_block(**kw)

    # verify that all the small UTXOs are NOT consumed
    bitcoind = testlib.connect_bitcoind()
    bitcoind.ping()

    txdata = bitcoind.getrawtransaction(resp['transaction_hash'], 1)
    if len(txdata['vin']) != 1:
        print simplejson.dumps(txdata, indent=4)
        print "wrong number of inputs: {} != {}".format(
            len(txdata['vin']), expected_utxo_count)
        return False

    # proceed to register
    resp = testlib.ysi_name_register("foo.test", wallets[2].privkey,
                                     wallets[3].addr)
    if debug or 'error' in resp:
        print simplejson.dumps(resp, indent=4)

    if spent_small_transaction(resp['transaction_hash']):
        return False

    testlib.next_block(**kw)

    # verify that all the UTXOs are consumed
    bitcoind = testlib.connect_bitcoind()
    bitcoind.ping()

    txdata = bitcoind.getrawtransaction(resp['transaction_hash'], 1)
    if len(txdata['vin']) != 1:
        print simplejson.dumps(txdata, indent=4)
        print "wrong number of inputs: {} != {}".format(
            len(txdata['vin']), expected_utxo_count)
        return False

    # make a few small UTXOs for the preorder payment addr
    for i in xrange(0, 3):
        res = testlib.send_funds(wallets[1].privkey, 10000,
                                 testlib.get_default_payment_wallet().addr)
        if 'error' in res:
            print simplejson.dumps(res, indent=4, sort_keys=True)
            return False

        testlib.next_block(**kw)
        small_unspents.append(res['transaction_hash'])

    utxos = testlib.get_utxos(testlib.get_default_payment_wallet().addr)
    assert len(utxos) > 3

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

    if spent_small_transaction(resp['transaction_hash']):
        return False

    consensus = testlib.get_consensus_at(testlib.get_current_block(**kw), **kw)
    testlib.next_block(**kw)

    # inspect the transaction: only 3 UTXOs should have been consumed (2 owner UTXOs and 1 payment UTXO)
    txdata = testlib.connect_bitcoind().getrawtransaction(
        resp['transaction_hash'], 1)
    if len(txdata['vin']) != 3:
        print simplejson.dumps(txdata, indent=4)
        print "too many inputs"
        return False

    # make a few more small UTXOs for the preorder payment addr
    for i in xrange(0, 3):
        res = testlib.send_funds(wallets[1].privkey, 10000,
                                 testlib.get_default_payment_wallet().addr)
        if 'error' in res:
            print simplejson.dumps(res, indent=4, sort_keys=True)
            return False

        testlib.next_block(**kw)
        small_unspents.append(res['transaction_hash'])

    utxos = testlib.get_utxos(testlib.get_default_payment_wallet().addr)
    assert len(utxos) > 3

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

    # inspect the transaction: only 2 UTXOs should have been consumed (1 owner UTXO and 1 payment UTXO)
    txdata = testlib.connect_bitcoind().getrawtransaction(
        resp['transaction_hash'], 1)
    if len(txdata['vin']) != 2:
        print simplejson.dumps(txdata, indent=4)
        print "too many inputs"
        return False

    if spent_small_transaction(resp['transaction_hash']):
        return False

    testlib.next_block(**kw)

    # make a few more small UTXOs for the preorder payment addr
    for i in xrange(0, 3):
        res = testlib.send_funds(wallets[1].privkey, 10000,
                                 testlib.get_default_payment_wallet().addr)
        if 'error' in res:
            print simplejson.dumps(res, indent=4, sort_keys=True)
            return False

        testlib.next_block(**kw)
        small_unspents.append(res['transaction_hash'])

    utxos = testlib.get_utxos(testlib.get_default_payment_wallet().addr)
    assert len(utxos) > 3

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

    # inspect the transaction: only 3 UTXOs should have been consumed (2 owner UTXO and 1 payment UTXO)
    # NOTE: produces two UTXOs: an "owner" utxo and the change for the owner address
    txdata = testlib.connect_bitcoind().getrawtransaction(
        resp['transaction_hash'], 1)
    if len(txdata['vin']) != 3:
        print simplejson.dumps(txdata, indent=4)
        print "too many inputs"
        return False

    if spent_small_transaction(resp['transaction_hash']):
        return False

    testlib.next_block(**kw)

    # make a few more small UTXOs for the preorder payment addr
    for i in xrange(0, 3):
        res = testlib.send_funds(wallets[1].privkey, 10000,
                                 testlib.get_default_payment_wallet().addr)
        if 'error' in res:
            print simplejson.dumps(res, indent=4, sort_keys=True)
            return False

        testlib.next_block(**kw)
        small_unspents.append(res['transaction_hash'])

    utxos = testlib.get_utxos(testlib.get_default_payment_wallet().addr)
    assert len(utxos) > 3

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

    # inspect the transaction: only 3 UTXOs should have been consumed (2 owner UTXO and 1 payment UTXO)
    txdata = testlib.connect_bitcoind().getrawtransaction(
        resp['transaction_hash'], 1)
    if len(txdata['vin']) != 3:
        print simplejson.dumps(txdata, indent=4)
        print "too many inputs"
        return False

    if spent_small_transaction(resp['transaction_hash']):
        return False

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

    global renew_block

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

    testlib.ysi_namespace_reveal(
        "test", wallets[1].addr, 4, 4, 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)

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

    whois = testlib.ysi_cli_whois('foo.test')
    if 'error' in whois:
        print whois
        return False

    print json.dumps(whois, indent=4, sort_keys=True)

    # push to grace period
    testlib.next_block(**kw)
    testlib.next_block(**kw)
    testlib.next_block(**kw)

    # can't update
    res = testlib.ysi_name_update("foo.test", '22' * 20, wallets[3].privkey)
    if 'error' not in res:
        print res
        return False

    res = testlib.ysi_name_update("foo.test",
                                  '22' * 20,
                                  wallets[3].privkey,
                                  safety_checks=False,
                                  tx_fee=300 * 5)
    if 'error' in res:
        print res
        return False

    testlib.next_block(**kw)
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))

    # should not have gone through
    res = testlib.ysi_cli_whois('foo.test')
    if 'error' in res:
        print res
        return False

    if res.has_key('zonefile_hash'):
        print res
        return False

    # can't transfer
    res = testlib.ysi_name_transfer('foo.test', wallets[4].addr, True,
                                    wallets[3].privkey)
    if 'error' not in res:
        print res
        return False

    res = testlib.ysi_name_transfer('foo.test',
                                    wallets[4].addr,
                                    True,
                                    wallets[3].privkey,
                                    safety_checks=False,
                                    tx_fee=300 * 5)
    if 'error' in res:
        print res
        return False

    testlib.next_block(**kw)
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))

    # should not have gone through
    res = testlib.ysi_cli_whois('foo.test')
    if 'error' in res:
        print res
        return False

    if res['owner_address'] != wallets[3].addr:
        print res
        return False

    # can't revoke
    res = testlib.ysi_name_revoke('foo.test', wallets[3].privkey)
    if 'error' not in res:
        print res
        return False

    res = testlib.ysi_name_revoke('foo.test',
                                  wallets[3].privkey,
                                  safety_checks=False,
                                  tx_fee=300 * 5)
    if 'error' in res:
        print res
        return False

    testlib.next_block(**kw)
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))

    # should not have gone through
    res = testlib.ysi_cli_whois('foo.test')
    if 'error' in res:
        print res
        return False

    # can renew
    res = testlib.ysi_name_renew('foo.test', wallets[3].privkey)
    if 'error' in res:
        print res
        return False

    testlib.next_block(**kw)
    renew_block = testlib.get_current_block(**kw)
Exemple #13
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)

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

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))

    resp = testlib.ysi_name_renew("foo.test",
                                  wallets[3].privkey,
                                  safety_checks=False,
                                  tx_fee=10000 * 5)
    if 'error' in resp:
        print json.dumps(resp)

    testlib.next_block(**kw)
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))

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

    testlib.next_block(**kw)
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))

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

    testlib.next_block(**kw)
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))

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

    testlib.next_block(**kw)
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))
def scenario(wallets, **kw):

    global fail_blocks

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

    testlib.ysi_namespace_reveal(
        "test", wallets[1].addr, 3, 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.ysi_name_preorder("bar.test", wallets[2].privkey, wallets[3].addr)
    testlib.ysi_name_preorder("baz.test", wallets[2].privkey, wallets[3].addr)
    testlib.next_block(**kw)

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

    # dids for each of these names
    foo_did = 'did:stack:v0:{}-0'.format(wallets[3].addr)
    bar_did = 'did:stack:v0:{}-1'.format(wallets[3].addr)
    baz_did = 'did:stack:v0:{}-2'.format(wallets[3].addr)

    for did in [foo_did, bar_did, baz_did]:
        res = ysi_client.proxy.get_DID_blockchain_record(did)
        if 'error' in res:
            print res
            return False

        if res['address'] != wallets[3].addr:
            print 'wrong address; expected {}'.format(wallets[3].addr)
            print json.dumps(res, indent=4, sort_keys=True)
            return False

    # revoke foo.test
    testlib.ysi_name_revoke("foo.test", wallets[3].privkey)
    testlib.next_block(**kw)

    # wait for them all to expire...
    for i in xrange(0, 3):
        testlib.next_block(**kw)

    # re-preorder/reregister to different addresses
    testlib.ysi_name_preorder("foo.test", wallets[4].privkey, wallets[0].addr)
    testlib.ysi_name_preorder("bar.test", wallets[4].privkey, wallets[1].addr)
    testlib.ysi_name_preorder("baz.test", wallets[4].privkey, wallets[2].addr)
    testlib.next_block(**kw)

    # re-register
    testlib.ysi_name_register("foo.test", wallets[4].privkey, wallets[0].addr)
    testlib.ysi_name_register("bar.test", wallets[4].privkey, wallets[1].addr)
    testlib.ysi_name_register("baz.test", wallets[4].privkey, wallets[2].addr)
    testlib.next_block(**kw)

    # foo's DID should no longer resolve, since foo was revoked
    res = ysi_client.proxy.get_DID_blockchain_record(foo_did)
    if 'error' not in res:
        print 'accidentally resolved {}'.format(foo_did)
        print res
        return False

    # non-revoked DIDs should resolve to the new addresses
    for did, addr in zip([bar_did, baz_did],
                         [wallets[1].addr, wallets[2].addr]):
        res = ysi_client.proxy.get_DID_blockchain_record(did)
        if 'error' in res:
            print res
            return False

        if res['address'] != addr:
            print 'wrong address post-reregister; expected {}'.format(addr)
            print json.dumps(res, indent=4, sort_keys=True)
            return False

    # dids for the new names
    foo2_did = 'did:stack:v0:{}-0'.format(wallets[0].addr)
    bar2_did = 'did:stack:v0:{}-0'.format(wallets[1].addr)
    baz2_did = 'did:stack:v0:{}-0'.format(wallets[2].addr)

    # new DIDs should all resolve to new addresses
    for did, addr in zip([foo2_did, bar2_did, baz2_did],
                         [wallets[0].addr, wallets[1].addr, wallets[2].addr]):
        res = ysi_client.proxy.get_DID_blockchain_record(did)
        if 'error' in res:
            print res
            return False

        if res['address'] != addr:
            print 'wrong address post-reregister: expected {}'.format(addr)
            print json.dumps(res, indent=4, sort_keys=True)
            return False

    # transfer all names back to wallets[3]
    testlib.ysi_name_transfer("foo.test", wallets[3].addr, True,
                              wallets[0].privkey)
    testlib.ysi_name_transfer("bar.test", wallets[3].addr, True,
                              wallets[1].privkey)
    testlib.ysi_name_transfer("baz.test", wallets[3].addr, True,
                              wallets[2].privkey)
    testlib.next_block(**kw)

    # all DIDs except for the original DID for foo.test should now resolve to wallets[3].addr
    for did in [bar_did, baz_did, foo2_did, bar2_did, baz2_did]:
        res = ysi_client.proxy.get_DID_blockchain_record(did)
        if 'error' in res:
            print res
            return False

        if res['address'] != wallets[3].addr:
            print 'wrong address post-reregister: expected {}'.format(
                wallets[3].addr)
            print json.dumps(res, indent=4, sort_keys=True)
            return False

    # foo's original DID should not resolve
    res = ysi_client.proxy.get_DID_blockchain_record(foo_did)
    if 'error' not in res:
        print 'accidentally resolved {}'.format(foo_did)
        print res
        return False
Exemple #15
0
def scenario(wallets, **kw):

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

    testlib.next_block(**kw)

    resp = 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)
    if 'error' in resp:
        print json.dumps(resp, indent=4)
        return False

    testlib.next_block(**kw)

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

    # derive importer keys and do imports
    # NOTE: breaks consensus trace from 0.14.0
    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, len(names) - 1):
        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)

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

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

        resp = testlib.ysi_name_import(name,
                                       register_wallet.addr,
                                       str(9 - i) * 40,
                                       import_key,
                                       safety_checks=False)
        if 'error' in resp:
            print json.dumps(resp, indent=4)
            return False

    testlib.next_block(**kw)

    # namespace ready...
    resp = testlib.ysi_namespace_ready("test", wallets[1].privkey)
    if 'error' in resp:
        print json.dumps(resp, indent=4)
        return False

    testlib.next_block(**kw)

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

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

        resp = testlib.ysi_name_update(name,
                                       str(i + 2) * 40,
                                       register_wallet.privkey)
        if 'error' in resp:
            print json.dumps(resp, indent=4)
            return False

    testlib.next_block(**kw)

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

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

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

    testlib.next_block(**kw)

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

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

        resp = testlib.ysi_name_transfer(name, transfer_wallet.addr, True,
                                         register_wallet.privkey)
        if 'error' in resp:
            print json.dumps(resp, indent=4)
            return False

    testlib.next_block(**kw)

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

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

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

        resp = testlib.ysi_name_revoke(name, register_wallet.privkey)
        if 'error' in resp:
            print json.dumps(resp, indent=4)
            return False

    # iterate the blocks a few times
    for i in xrange(0, 5):
        testlib.next_block(**kw)
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 )

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

    testlib.next_block( **kw )

    print "\nImport 25 names for %s" % wallets[3].addr

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

        if i % 2 == 1:
            testlib.next_block( **kw )

    testlib.next_block( **kw )

    print "\nImport 26 names for %s" % wallets[4].addr

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

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

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

    testlib.next_block( **kw )

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

    testlib.next_block( **kw )
    testlib.expect_snv_fail_at( "foofail.test", testlib.get_current_block(**kw))

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

    testlib.next_block( **kw )

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

    testlib.next_block( **kw )

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

    testlib.next_block( **kw )
    testlib.expect_snv_fail_at( "barfail.test", testlib.get_current_block(**kw))

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

    testlib.next_block( **kw )
    testlib.expect_snv_fail_at( "bar0.test", testlib.get_current_block(**kw))

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

    testlib.next_block( **kw )

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

    testlib.next_block( **kw )
    testlib.expect_snv_fail_at( "bar0.test", testlib.get_current_block(**kw))

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

    testlib.next_block( **kw )

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

    testlib.next_block( **kw )

    testlib.expect_snv_fail( "foofail.test" )
    testlib.expect_snv_fail( "barfail.test" )
def scenario(wallets, **kw):

    global debug

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

    testlib.next_block(**kw)

    resp = testlib.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)
    if debug or 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))