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)
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)
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_multi(
        ["foo.test", "bar.test", "baz.test"], wallets[2].privkey,
        [wallets[3].addr, wallets[4].addr, wallets[5].addr])
    if 'error' in resp:
        print json.dumps(resp, indent=4)
        sys.exit(1)

    testlib.next_block(**kw)
    preorder_consensus = testlib.get_consensus_at(testlib.get_current_block())

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

    testlib.next_block(**kw)

    resp = testlib.ysi_name_register("bar.test", wallets[2].privkey,
                                     wallets[4].addr)
    if 'error' in resp:
        print json.dumps(resp, indent=4)
        sys.exit(1)

    testlib.next_block(**kw)

    resp = testlib.ysi_name_register("baz.test", wallets[2].privkey,
                                     wallets[5].addr)
    if 'error' in resp:
        print json.dumps(resp, indent=4)
        sys.exit(1)

    testlib.next_block(**kw)
Esempio n. 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)
Esempio n. 5
0
def scenario(wallets, **kw):

    global last_first_block, first_preorder

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

    # NOTE: names expire in 5 * NAMESPACE_LIFETIME_MULTIPLER blocks
    testlib.ysi_namespace_reveal(
        "test", wallets[1].addr, 5, 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)

    first_preorder = testlib.get_current_block(**kw)

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

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

    # epoch shifts here
    # 266
    testlib.next_block(**kw)

    # actually expire
    for i in xrange(
            0, 5 * ysi_server.config.get_epoch_namespace_lifetime_multiplier(
                testlib.get_current_block(**kw), "test") - 5):
        testlib.next_block(**kw)

    # should work now
    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)

    last_first_block = testlib.get_current_block(**kw)
Esempio n. 6
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)
    testlib.next_block(**kw)
def scenario(wallets, **kw):

    global last_first_block, first_preorder

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

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

    # preorder, register, expire (multiple times)
    for i in xrange(2, 5):
        resp = testlib.ysi_name_preorder("foo.test",
                                         wallets[i].privkey,
                                         wallets[(i + 1) % 5].addr,
                                         safety_checks=False)
        if 'error' in resp:
            print json.dumps(resp, indent=4)

        testlib.next_block(**kw)

        if first_preorder is None:
            first_preorder = testlib.get_current_block(**kw)

        resp = testlib.ysi_name_register("foo.test",
                                         wallets[i].privkey,
                                         wallets[(i + 1) % 5].addr,
                                         safety_checks=False)
        if 'error' in resp:
            print json.dumps(resp, indent=4)

        testlib.next_block(**kw)

        last_first_block = testlib.get_current_block(**kw)

        if i == 4:
            break

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

    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 )
        return False

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

    namespace_rec = testlib.ysi_cli_get_namespace_blockchain_record("test")
    if 'error' in namespace_rec:
        print namespace_rec
        return False

    namespace_balance = testlib.get_balance(namespace_rec['address'])

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

    new_namespace_balance = testlib.get_balance(namespace_rec['address'])
    name_rec = testlib.get_name_blockchain_record('foo.test')
    name_cost = name_rec['op_fee']

    if new_namespace_balance - namespace_balance != name_cost:
        print 'address {} did not get credited'.format(namespace_rec['address'])
        print '{} != {} + {}'.format(new_namespace_balance, namespace_balance, name_cost)
        return False

    testlib.ysi_name_renew("foo.test", wallets[3].privkey, recipient_addr=wallets[4].addr, zonefile_hash='22' * 20)
    testlib.next_block(**kw)

    new_namespace_balance = testlib.get_balance(namespace_rec['address'])
    name_rec = testlib.get_name_blockchain_record('foo.test')
    name_cost = name_rec['op_fee']

    if new_namespace_balance - namespace_balance != 2*name_cost:
        print 'address {} did not get credited'.format(namespace_rec['address'])
        print '{} != {} + {}'.format(new_namespace_balance, namespace_balance, 2*name_cost)
        return False
Esempio n. 9
0
def scenario( wallets, **kw ):

    global update_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 )

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

    testlib.next_block( **kw )

    update_block = testlib.get_current_block( **kw )

    # 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 )
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_renew("foo.test", wallets[4].privkey)
    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[4].privkey)
    if debug or 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)
Esempio n. 11
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)
Esempio n. 12
0
def scenario( wallets, **kw ):

    global final_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 )

    resp = testlib.ysi_name_preorder_multi( ["foo.test", "bar.test", "baz.test"], wallets[2].privkey, [wallets[3].addr, wallets[4].addr, wallets[5].addr] )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )
        sys.exit(1)
        
    testlib.next_block( **kw )
    preorder_consensus = testlib.get_consensus_at( testlib.get_current_block() )

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

    testlib.next_block( **kw )

    # should cause the whole thing to fail, since we didn't preorder this separately 
    resp = testlib.ysi_name_register( "goo.test", wallets[2].privkey, wallets[5].addr )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )
        sys.exit(1)

    resp = testlib.ysi_name_register( "baz.test", wallets[2].privkey, wallets[5].addr )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )
        sys.exit(1)

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

    # can't import once ready
    resp = testlib.ysi_name_import( "foo.test", wallets[1].addr, "11" * 20, wallets[0].privkey, safety_checks=False )
    if 'error' in resp:
        print json.dumps( resp, indent=4 )

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

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

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

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

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

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

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

    # run 'core-test' test on ysi (tests authentication from ysi.js to Core API)
    testlib.nodejs_copy_package(nodedir, "ysi")
    testlib.nodejs_copy_package(nodedir, "ysi-storage")
    testlib.nodejs_run_test(nodedir, "integration-test-storage")
    testlib.nodejs_cleanup(nodedir)
Esempio n. 15
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, indent=4 )
        sys.exit(1)

    testlib.next_block( **kw )

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

    testlib.next_block( **kw )

    # wait for a bit...
    for i in xrange(0, 10):
        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 )
    testlib.next_block( **kw )

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


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

    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)
Esempio n. 17
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,
        version_bits=2)
    testlib.next_block(**kw)

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

    namespace_rec = testlib.ysi_cli_get_namespace_blockchain_record("test")
    if 'error' in namespace_rec:
        print namespace_rec
        return False

    namespace_balance = testlib.get_balance(namespace_rec['address'])

    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)

    new_namespace_balance = testlib.get_balance(namespace_rec['address'])
    name_rec = testlib.get_name_blockchain_record('foo.test')
    name_cost = name_rec['op_fee']

    if new_namespace_balance - namespace_balance != name_cost:
        print 'address {} did not get credited'.format(
            namespace_rec['address'])
        print '{} != {} + {}'.format(new_namespace_balance, namespace_balance,
                                     name_cost)
        return False
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)

    # put this here to help with interactive testing
    testlib.ysi_client_initialize_wallet("0123456789abcdef",
                                         wallets[2].privkey,
                                         wallets[3].privkey,
                                         wallets[4].privkey)
Esempio n. 19
0
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)

    resp = testlib.ysi_name_update("foo.test", "22" * 20, wallets[3].privkey)
    if '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 'error' in resp:
        print json.dumps(resp, indent=4)

    testlib.next_block(**kw)

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

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

    testlib.next_block(**kw)
    testlib.next_block(**kw)
Esempio n. 20
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_name_import("foo.test", wallets[2].addr, "11" * 20,
                            wallets[1].privkey)
    testlib.ysi_name_import("bar.test", wallets[3].addr, "22" * 20,
                            wallets[1].privkey)
    testlib.ysi_name_import("baz.test", wallets[4].addr, "33" * 20,
                            wallets[1].privkey)

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

    print >> sys.stderr, "We're a go!"
def scenario( wallets, **kw ):

    global import_block_1, import_block_2

    # 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, 10, 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 )

    import_block_1 = testlib.get_current_block( **kw )

    testlib.next_block( **kw )

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

    testlib.next_block( **kw )
    
    import_block_2 = testlib.get_current_block( **kw )

    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 expiration (with multipler)...
    for i in xrange(0, 10 * 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 )
Esempio n. 23
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)

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

    # should fail--can't give a name to yourself
    testlib.ysi_name_transfer("foo.test",
                              wallets[4].addr,
                              True,
                              wallets[4].privkey,
                              safety_checks=False)
    testlib.next_block(**kw)
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))

    # should fail--can't steal a name
    testlib.ysi_name_transfer("foo.test",
                              wallets[4].addr,
                              True,
                              wallets[0].privkey,
                              safety_checks=False)
    testlib.next_block(**kw)
    testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))
def scenario(wallets, **kw):

    # order 3 namespaces
    testlib.ysi_namespace_preorder("test1", wallets[1].addr,
                                   wallets[0].privkey)
    testlib.ysi_namespace_preorder("test2", wallets[3].addr,
                                   wallets[2].privkey)
    testlib.ysi_namespace_preorder("test3", wallets[5].addr,
                                   wallets[4].privkey)
    testlib.next_block(**kw)

    # reveal them all
    testlib.ysi_namespace_reveal(
        "test1", wallets[1].addr, 52595, 250, 4,
        [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 11,
        wallets[0].privkey)
    testlib.ysi_namespace_reveal(
        "test2", wallets[3].addr, 52596, 251, 5,
        [7, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 11, 12,
        wallets[2].privkey)
    testlib.ysi_namespace_reveal(
        "test3", wallets[5].addr, 52597, 252, 6,
        [8, 7, 6, 5, 4, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], 12, 13,
        wallets[4].privkey)
    testlib.next_block(**kw)

    # ready them all
    testlib.ysi_namespace_ready("test1", wallets[1].privkey)
    testlib.ysi_namespace_ready("test2", wallets[3].privkey)
    testlib.ysi_namespace_ready("test3", wallets[5].privkey)
    testlib.next_block(**kw)
def scenario(wallets, **kw):

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

    # wait 10 blocks between
    for i in xrange(0, 10):
        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)

    # wait 10 blocks between
    for i in xrange(0, 10):
        testlib.next_block(**kw)

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

    # wait 10 blocks between
    for i in xrange(0, 10):
        testlib.next_block(**kw)
def scenario(wallets, **kw):

    global txids
    global consensuses

    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)

    testlib.next_block(**kw)
    # do a sequence of updates, every other block
    for i in xrange(0, 20):

        if (i % 2) != 0:
            update_hash = ("%02x" % (i)) * 20
            resp = testlib.ysi_name_update("foo.test", update_hash,
                                           wallets[3].privkey)

            txids[update_hash] = resp['transaction_hash']
            consensuses[update_hash] = testlib.get_consensus_at(
                testlib.get_current_block(**kw), **kw)

        testlib.next_block(**kw)

    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)

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

    consensus_hash = testlib.get_consensus_at(testlib.get_current_block(**kw),
                                              **kw)

    # lots of blocks later...
    for i in xrange(0, 50):
        testlib.next_block(**kw)

    # update with stale consensus hash (should fail)
    print "\n\nsend update with consensus hash %s\n\n" % consensus_hash
    testlib.ysi_name_update("foo.test",
                            "22" * 20,
                            wallets[3].privkey,
                            consensus_hash=consensus_hash,
                            safety_checks=False)
    testlib.next_block(**kw)
Esempio n. 28
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)

    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)

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)

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

    testlib.next_block(**kw)

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

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

    global snv_consensus, snv_block_id
    snv_block_id = testlib.get_current_block()
    snv_consensus = testlib.get_consensus_at(snv_block_id)