Пример #1
0
def scenario(wallets, **kw):
    virtualchain.set_features('segwit', True)

    global preorder_block, reveal_block

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

    preorder_block = testlib.get_current_block(**kw) + 1
    testlib.next_block(**kw)

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

    reveal_block = testlib.get_current_block(**kw) + 1
    testlib.next_block(**kw)
def scenario(wallets, **kw):

    print '\nactivating segwit\n'

    virtualchain.set_features("segwit", True)

    print '\nsegwit state: {}\n'.format(virtualchain.get_features('segwit'))

    # make a test namespace
    resp = testlib.blockstack_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.blockstack_namespace_reveal(
        "test", wallets[1].addr, 52595, 250, 4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10,
        wallets[0].privkey)
    if debug or 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)

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

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

    print '\nactivating segwit\n'

    virtualchain.set_features("segwit", True)

    print '\nsegwit state: {}\n'.format(virtualchain.get_features('segwit'))

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

    testlib.blockstack_namespace_reveal(
        "test", wallets[1].addr, 52595, 250, 4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10,
        wallets[5].privkey)
    testlib.blockstack_namespace_reveal(
        "mult",
        wallets[2].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,
        version_bits=2)
    testlib.next_block(**kw)

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

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

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

    # should succeed
    resp = testlib.blockstack_name_import("foo.mult", wallets[2].addr,
                                          '00' * 20, private_keys[0])
    if 'error' in resp:
        print json.dumps(resp, indent=4, sort_keys=True)
        return False

    testlib.next_block(**kw)

    # should succeed
    resp = testlib.blockstack_name_import("bar.mult", wallets[3].addr,
                                          "11" * 20, private_keys[1])
    if 'error' in resp:
        print json.dumps(resp, indent=4, sort_keys=True)
        return False

    # should succeed
    resp = testlib.blockstack_name_import("baz.mult", wallets[4].addr,
                                          "22" * 20, private_keys[2])
    if 'error' in resp:
        print json.dumps(resp, indent=4, sort_keys=True)
        return False

    # should succeed
    resp = testlib.blockstack_name_import("goo.mult", wallets[5].addr,
                                          "33" * 20, private_keys[3])
    if 'error' in resp:
        print json.dumps(resp, indent=4, sort_keys=True)
        return False

    testlib.next_block(**kw)

    testlib.blockstack_namespace_ready("test", wallets[1].privkey)
    testlib.blockstack_namespace_ready("mult", wallets[2].privkey)
    testlib.next_block(**kw)

    namespace_balance = testlib.get_balance(wallets[0].addr)

    # get prices
    hello_cost = testlib.blockstack_get_name_cost('hello.mult')
    world_cost = testlib.blockstack_get_name_cost('world.mult')
    foo_cost = testlib.blockstack_get_name_cost('foo.mult')

    # register/renew
    res = testlib.blockstack_name_preorder("hello.mult", wallets[1].privkey,
                                           wallets[2].addr)
    if 'error' in res:
        print res
        return False

    res = testlib.blockstack_name_preorder('world.mult',
                                           wallets[6].privkey,
                                           wallets[7].addr,
                                           wallet=wallets[7])
    if 'error' in res:
        print res
        return False

    res = testlib.blockstack_name_renew('foo.mult', wallets[2].privkey)
    if 'error' in res:
        print res
        return False

    testlib.next_block(**kw)

    new_namespace_balance = testlib.get_balance(wallets[0].addr)

    if new_namespace_balance != namespace_balance + hello_cost + world_cost + foo_cost:
        print 'wrong balance'
        print new_namespace_balance
        print namespace_balance
        print hello_cost
        print foo_cost
        return False

    res = testlib.blockstack_name_register("hello.mult", wallets[1].privkey,
                                           wallets[2].addr)
    if 'error' in res:
        print res
        return False

    res = testlib.blockstack_name_register('world.mult',
                                           wallets[6].privkey,
                                           wallets[7].addr,
                                           wallet=wallets[7],
                                           zonefile_hash='44' * 20)
    if 'error' in res:
        print res
        return False

    testlib.next_block(**kw)
Пример #4
0
def scenario(wallets, **kw):

    print '\nactivating segwit\n'

    virtualchain.set_features("segwit", True)

    print '\nsegwit state: {}\n'.format(virtualchain.get_features('segwit'))

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

    virtualchain.set_features("segwit", False)
    testlib.next_block(**kw)
    virtualchain.set_features("segwit", True)

    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)

    virtualchain.set_features("segwit", False)
    testlib.next_block(**kw)
    virtualchain.set_features("segwit", True)

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

    virtualchain.set_features("segwit", False)
    testlib.next_block(**kw)
    virtualchain.set_features("segwit", True)

    testlib.ysi_name_preorder("foo.test",
                              wallets[2].privkey,
                              wallets[3].addr,
                              wallet=wallets[3])

    virtualchain.set_features("segwit", False)
    testlib.next_block(**kw)
    virtualchain.set_features("segwit", True)

    testlib.ysi_name_register("foo.test",
                              wallets[2].privkey,
                              wallets[3].addr,
                              wallet=wallets[3])

    virtualchain.set_features("segwit", False)
    testlib.next_block(**kw)
    virtualchain.set_features("segwit", True)