def scenario(wallets, **kw): global transfer_block testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.blockstack_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.blockstack_name_register("foo.test", wallets[2].privkey, wallets[3].addr) # should fail testlib.blockstack_name_transfer('foo.test', wallets[4].addr, True, wallets[3].privkey, safety_checks=False, tx_fee=30000) testlib.next_block(**kw) transfer_block = testlib.get_current_block(**kw) testlib.expect_snv_fail_at('foo.test', transfer_block)
def scenario( wallets, **kw ): testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) testlib.blockstack_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[3].privkey ) testlib.next_block( **kw ) # should fail--can't give a name to yourself testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[4].privkey ) testlib.next_block( **kw ) # should fail--can't steal a name testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[0].privkey ) testlib.next_block( **kw )
def scenario(wallets, **kw): testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.blockstack_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.blockstack_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.blockstack_name_update("foo.test", "11" * 20, wallets[3].privkey) testlib.next_block(**kw) # should fail--can't give a name to yourself testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[4].privkey) testlib.next_block(**kw) # should fail--can't steal a name testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[0].privkey) testlib.next_block(**kw)
def scenario(wallets, **kw): testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.blockstack_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.blockstack_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.blockstack_name_update("foo.test", "11" * 20, wallets[3].privkey) testlib.next_block(**kw) testlib.blockstack_name_transfer("foo.test", wallets[4].addr, False, wallets[3].privkey) testlib.next_block(**kw)
def scenario(wallets, **kw): testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey, version_bits=blockstack.NAMESPACE_VERSION_PAY_WITH_STACKS) testlib.next_block(**kw) testlib.blockstack_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.blockstack_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.blockstack_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey) testlib.next_block(**kw)
def scenario(wallets, **kw): global debug 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_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_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.blockstack_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.blockstack_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.blockstack_name_transfer("foo.test", wallets[0].addr, True, wallets[4].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw)
def scenario( wallets, **kw ): global debug, consensus 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_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_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.blockstack_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.blockstack_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.blockstack_name_transfer( "foo.test", wallets[0].addr, True, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[0].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) consensus = testlib.get_consensus_at( testlib.get_current_block( **kw ), **kw ) testlib.next_block( **kw )
def scenario(wallets, **kw): # 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[3].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_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstack_name_transfer("foo.test", wallets[0].addr, True, wallets[4].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstack_name_update("foo.test", "22" * 20, wallets[0].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw)
def scenario( wallets, **kw ): testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) testlib.blockstack_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) # update and transfer back and forth a few times for i in xrange(0, 5): result = testlib.blockstack_name_update( "foo.test", str(i) * 40, wallets[3 + (i%2)].privkey ) update_hashes.append( str(i) * 40 ) testlib.next_block( **kw ) result = testlib.blockstack_name_transfer( "foo.test", wallets[3 + ((i+1)%2)].addr, True, wallets[3 + (i%2)].privkey ) testlib.next_block( **kw )
def do_interleaving( name, namerecs, order ): # order should be a string of "u", "t", and "r" order = list(order) for i in xrange(0, len(order)): op = order[i] if op == 'r': # renew print "\nrenew '%s' with %s\n" % (name, pybitcoin.make_pay_to_address_script( namerecs[name][0].addr )) resp = testlib.blockstack_name_renew( name, namerecs[name][0].privkey, register_addr=namerecs[name][0].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) elif op == 'u': # update resp = testlib.blockstack_name_update( name, ("%s%s" % (i, i)) * 20, namerecs[name][0].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) elif op == 't': # transfer and exchange wallets print "\ntransfer '%s' from %s to %s" % (name, pybitcoin.make_pay_to_address_script( namerecs[name][0].addr ), pybitcoin.make_pay_to_address_script( namerecs[name][1].addr )) resp = testlib.blockstack_name_transfer( name, namerecs[name][1].addr, True, namerecs[name][0].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) tmp = namerecs[name][0] namerecs[name][0] = namerecs[name][1] namerecs[name][1] = tmp
def scenario(wallets, **kw): global update_blocks, transfer_blocks, update_hashes, transfer_recipients testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_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.blockstack_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) # preorder, register, update, expire (multiple times) for i in xrange(2, 5): resp = testlib.blockstack_name_preorder("foo.test", wallets[i].privkey, wallets[(i + 1) % 11].addr) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstack_name_register("foo.test", wallets[i].privkey, wallets[(i + 1) % 11].addr) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstack_name_update("foo.test", ("%02x" % i) * 20, wallets[(i + 1) % 11].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) update_blocks.append(testlib.get_current_block(**kw)) update_hashes.append(("%02x" % i) * 20) resp = testlib.blockstack_name_transfer("foo.test", wallets[i].addr, True, wallets[(i + 1) % 11].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) transfer_blocks.append(testlib.get_current_block(**kw)) transfer_recipients.append(wallets[i].addr) if i == 4: break for j in xrange(0, 2 * NAMESPACE_LIFETIME_MULTIPLIER - 1): testlib.next_block(**kw)
def scenario(wallets, **kw): # 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, 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.blockstack_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.blockstack_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 * NAMESPACE_LIFETIME_MULTIPLIER - 4): testlib.next_block(**kw) resp = testlib.blockstack_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) # transfer resp = testlib.blockstack_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) testlib.next_block(**kw) # update resp = testlib.blockstack_name_update("foo.test", "22" * 20, wallets[4].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw)
def scenario( wallets, **kw ): testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 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.blockstack_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) # preorder, register, update, expire (multiple times) for i in xrange(2, 11): resp = testlib.blockstack_name_preorder( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr, consensus_hash=consensus_hash ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_register( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[i].addr, True, wallets[(i+1)%11].privkey, consensus_hash=consensus_hash ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_update( "foo.test", ("%02x" % i) * 20, wallets[i].privkey, consensus_hash=consensus_hash ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) if i == 10: break testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw )
def scenario( wallets, **kw ): global fail_blocks testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_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.blockstack_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) testlib.blockstack_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) # 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.blockstack_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.blockstack_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.blockstack_name_renew( "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)) # should fail resp = testlib.blockstack_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 transfer_block # 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, 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.blockstack_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.blockstack_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.blockstack_name_renew( "foo.test", wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # transfer resp = testlib.blockstack_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 ) transfer_block = testlib.get_current_block( **kw ) # expire for i in xrange(0, 6 * NAMESPACE_LIFETIME_MULTIPLIER ): testlib.next_block( **kw ) # re-register testlib.blockstack_name_preorder( "foo.test", wallets[7].privkey, wallets[8].addr ) testlib.next_block( **kw ) testlib.blockstack_name_register( "foo.test", wallets[7].privkey, wallets[8].addr ) testlib.next_block( **kw )
def scenario( wallets, **kw ): testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 4, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) # preorder, register, update, expire (twice; should fail the second time) for i in xrange(2, 4): resp = testlib.blockstack_name_preorder( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_register( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) if i == 3: testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) testlib.next_block( **kw ) resp = testlib.blockstack_name_update( "foo.test", ("%02x" % i) * 20, wallets[(i+1)%11].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) if i == 3: testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) testlib.next_block( **kw ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[i].addr, True, wallets[(i+1)%11].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) if i == 3: testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) testlib.next_block( **kw ) resp = testlib.blockstack_name_renew( "foo.test", wallets[i].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) if i == 3: testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) if i == 3: break testlib.next_block( **kw )
def scenario(wallets, **kw): global debug 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_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_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.blockstack_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.blockstack_name_transfer("foo.test", wallets[4].addr, False, wallets[3].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # original owner *can't* update resp = testlib.blockstack_name_update("foo.test", "11" * 20, wallets[3].privkey, safety_checks=False) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw)
def scenario( wallets, **kw ): global snv_block_id_foo, snv_txid_bar, snv_txid_baz, last_consensus # 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[3].addr, "11" * 20, wallets[1].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) snv_block_id_foo = testlib.get_current_block() resp = testlib.blockstack_name_import( "bar.test", wallets[5].addr, "33" * 20, wallets[1].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_import( "baz.test", wallets[6].addr, "33" * 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_transfer( "bar.test", wallets[4].addr, True, wallets[5].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) snv_txid_bar = resp['transaction_hash'] testlib.next_block( **kw ) resp = testlib.blockstack_name_update( "baz.test", "22" * 20, wallets[6].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) last_consensus = testlib.get_consensus_at( testlib.get_current_block() )
def scenario(wallets, **kw): testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) resp = testlib.blockstack_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.blockstack_name_update("foo.test", "11" * 20, wallets[3].privkey) if 'error' in resp: print json.dumps(resp) testlib.next_block(**kw) resp = testlib.blockstack_name_renew("foo.test", wallets[3].privkey) if 'error' in resp: print json.dumps(resp) testlib.next_block(**kw) resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey) if 'error' in resp: print json.dumps(resp) testlib.next_block(**kw) # try both addresses (should both fail) resp = testlib.blockstack_name_revoke("foo.test", wallets[4].privkey) if 'error' in resp: print json.dumps(resp) testlib.next_block(**kw) resp = testlib.blockstack_name_revoke("foo.test", wallets[3].privkey) if 'error' in resp: print json.dumps(resp)
def scenario( wallets, **kw ): testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) resp = testlib.blockstack_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.blockstack_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.blockstack_name_renew( "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)) resp = testlib.blockstack_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.blockstack_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.blockstack_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 debug 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_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_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.blockstack_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.blockstack_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.blockstack_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.blockstack_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))
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 ): global update_blocks, transfer_blocks, update_hashes, transfer_recipients testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_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.blockstack_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) # preorder, register, update, expire (multiple times) for i in xrange(2, 5): resp = testlib.blockstack_name_preorder( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_register( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_update( "foo.test", ("%02x" % i) * 20, wallets[(i+1)%11].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) update_blocks.append( testlib.get_current_block( **kw )) update_hashes.append( ("%02x" % i) * 20 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[i].addr, True, wallets[(i+1)%11].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) transfer_blocks.append( testlib.get_current_block( **kw ) ) transfer_recipients.append( wallets[i].addr ) if i == 4: break for j in xrange(0, 2 * NAMESPACE_LIFETIME_MULTIPLIER - 1): testlib.next_block( **kw )
def scenario(wallets, **kw): testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 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.blockstack_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) # preorder, register, update, expire (multiple times) for i in xrange(2, 11): resp = testlib.blockstack_name_preorder("foo.test", wallets[i].privkey, wallets[(i + 1) % 11].addr) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstack_name_register("foo.test", wallets[i].privkey, wallets[(i + 1) % 11].addr) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstack_name_update("foo.test", ("%02x" % i) * 20, wallets[(i + 1) % 11].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstack_name_transfer("foo.test", wallets[i].addr, True, wallets[(i + 1) % 11].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) if i == 10: break testlib.next_block(**kw)
def scenario( wallets, **kw ): # 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[3].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[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_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.blockstack_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 )
def scenario( wallets, **kw ): testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 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.blockstack_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) # preorder, register, update, expire (multiple times) # only the first round should succeed, due to the namespace lifetime multipler # introduced in 0.14 for i in xrange(2, 4): resp = testlib.blockstack_name_preorder( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_register( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) if i == 3: testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block( **kw )) testlib.next_block( **kw ) resp = testlib.blockstack_name_update( "foo.test", ("%02x" % i) * 20, wallets[(i+1)%11].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) if i == 3: testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block( **kw )) testlib.next_block( **kw ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[i].addr, True, wallets[(i+1)%11].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) if i == 3: testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block( **kw )) testlib.next_block( **kw )
def do_interleaving(name, namerecs, order): # order should be a string of "u", "t", and "r" order = list(order) for i in xrange(0, len(order)): op = order[i] if op == 'r': # renew print "\nrenew '%s' with %s\n" % ( name, pybitcoin.make_pay_to_address_script(namerecs[name][0].addr)) resp = testlib.blockstack_name_renew( name, namerecs[name][0].privkey, register_addr=namerecs[name][0].addr, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) elif op == 'u': # update resp = testlib.blockstack_name_update(name, ("%s%s" % (i, i)) * 20, namerecs[name][0].privkey, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) elif op == 't': # transfer and exchange wallets print "\ntransfer '%s' from %s to %s" % ( name, pybitcoin.make_pay_to_address_script(namerecs[name][0].addr), pybitcoin.make_pay_to_address_script(namerecs[name][1].addr)) resp = testlib.blockstack_name_transfer(name, namerecs[name][1].addr, True, namerecs[name][0].privkey, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) tmp = namerecs[name][0] namerecs[name][0] = namerecs[name][1] namerecs[name][1] = tmp
def scenario( wallets, **kw ): 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_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_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.blockstack_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.blockstack_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.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[3].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) # advance a bit for i in xrange(0, 5): testlib.next_block( **kw )
def scenario(wallets, **kw): testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.blockstack_name_preorder("foo.test", wallets[3].privkey, wallets[4].addr) testlib.next_block(**kw) testlib.blockstack_name_register("foo.test", wallets[3].privkey, wallets[4].addr) testlib.next_block(**kw) # should succeed # in 0.13, this should go to a "None" address # in 0.14, this should go to the designated p2sh address testlib.blockstack_name_transfer("foo.test", wallets[2].addr, True, wallets[4].privkey) testlib.next_block(**kw) # should fail # in 0.13, this is because it's owned by the "None" address now # in 0.14, this is because we're waiting until F-day testlib.blockstack_name_transfer("foo.test", wallets[1].addr, True, wallets[2].privkey, safety_checks=False) testlib.next_block(**kw) testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) # next epoch # now, this should succeed testlib.blockstack_name_transfer("foo.test", wallets[0].addr, True, wallets[2].privkey) testlib.next_block(**kw)
def scenario( wallets, **kw ): global debug 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_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_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.blockstack_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 ) # should fail; wrong key resp = testlib.blockstack_name_transfer( "foo.test", wallets[0].addr, True, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw )
def scenario( wallets, **kw ): testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) testlib.blockstack_name_preorder( "foo.test", wallets[3].privkey, wallets[4].addr ) testlib.next_block( **kw ) testlib.blockstack_name_register( "foo.test", wallets[3].privkey, wallets[4].addr ) testlib.next_block( **kw ) # should succeed # in 0.13, this should go to a "None" address # in 0.14, this should go to the designated p2sh address testlib.blockstack_name_transfer( "foo.test", wallets[2].addr, True, wallets[4].privkey ) testlib.next_block( **kw ) # should fail # in 0.13, this is because it's owned by the "None" address now # in 0.14, this is because we're waiting until F-day testlib.blockstack_name_transfer( "foo.test", wallets[1].addr, True, wallets[2].privkey, safety_checks=False ) testlib.next_block( **kw ) testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) # next epoch # now, this should succeed testlib.blockstack_name_transfer( "foo.test", wallets[0].addr, True, wallets[2].privkey ) testlib.next_block( **kw )
def scenario( wallets, **kw ): testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) # note: lifetime of a name is 10 * NAMESPACE_LIFETIME_MULTIPLIER # we will make sure this all fails by *not* honoring this testlib.blockstack_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.blockstack_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) # preorder, register, update, expire (twice, with incorrect assumption about namespace lifetime) for i in xrange(2, 4): resp = testlib.blockstack_name_preorder( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr, consensus_hash=consensus_hash, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_register( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr, safety_checks=False ) testlib.next_block( **kw ) if 'error' in resp: print json.dumps( resp, indent=4 ) if i == 3: testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[i].addr, True, wallets[(i+1)%11].privkey, consensus_hash=consensus_hash, safety_checks=False ) testlib.next_block( **kw ) if 'error' in resp: print json.dumps( resp, indent=4 ) if i == 3: testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_update( "foo.test", ("%02x" % i) * 20, wallets[i].privkey, consensus_hash=consensus_hash, safety_checks=False ) testlib.next_block( **kw ) if 'error' in resp: print json.dumps( resp, indent=4 ) if i == 3: testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block(**kw)) break consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) if i == 3: break
def scenario(wallets, **kw): global debug resp = testlib.blockstack_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.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 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) resp = testlib.blockstack_namespace_ready("test", wallets[1].privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) resp = testlib.blockstack_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) resp = testlib.blockstack_name_register("foo.test", wallets[2].privkey, wallets[3].addr) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) # consensus hash should be the one from the last NAME_TRANSFER db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'wrong consensus hash: expected {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1)) print json.dumps(name_rec, indent=4, sort_keys=True) return False resp = testlib.blockstack_name_update("foo.test", "11" * 20, wallets[4].privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != testlib.get_consensus_at( testlib.get_current_block(**kw) - 1): print 'wrong consensus hash: expected {}'.format( testlib.get_consensus_at(testlib.get_current_block(**kw) - 1)) print json.dumps(name_rec, indent=4, sort_keys=True) return False update_ch = name_rec['consensus_hash'] resp = testlib.blockstack_name_renew("foo.test", wallets[4].privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != update_ch: print 'wrong consensus hash: expected {}'.format(update_ch) print json.dumps(name_rec, indent=4, sort_keys=True) return False resp = testlib.blockstack_name_transfer("foo.test", wallets[3].addr, True, wallets[4].privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) # consensus hash should be the one from the last NAME_UPDATE db = testlib.get_state_engine() name_rec = db.get_name('foo.test') if name_rec['consensus_hash'] != update_ch: print 'wrong consensus hash: expected {}'.format(update_ch) print json.dumps(name_rec, indent=4, sort_keys=True) return False
def scenario( wallets, **kw ): global debug 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_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_preorder( "foo.test", wallets[2].privkey, wallets[3].addr, wallet=wallets[3] ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr, wallet=wallets[3] ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # ping-ping a bit... 3 --> 4 --> 5 --> 4 --> 5 --> 4 resp = testlib.blockstack_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 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # update (4) resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[4].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) # ping-ping a bit... 4 --> 5 --> 4 --> 5 --> 4 --> 5 resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) # now update (5) resp = testlib.blockstack_name_update( "foo.test", "22" * 20, wallets[5].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # update transfer resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_update( "foo.test", "33" * 20, wallets[4].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # update --> transfer --> transfer --> update resp = testlib.blockstack_name_update( "foo.test", "44" * 20, wallets[4].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_update( "foo.test", "55" * 20, wallets[4].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # update --> transfer --> update --> transfer resp = testlib.blockstack_name_update( "foo.test", "66" * 20, wallets[4].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[5].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # transfer resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw )
def scenario( wallets, **kw ): global debug # TODO: insert delayed consensus hashes 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_namespace_ready( "test", wallets[1].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) resp = testlib.blockstack_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr, wallet=wallets[3], consensus_hash=consensus_hash ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr, wallet=wallets[3] ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # ping-ping a bit... 3 --> 4 --> 5 --> 4 --> 5 --> 4 resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[3].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # update (4) resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) # ping-ping a bit... 4 --> 5 --> 4 --> 5 --> 4 --> 5 resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey, consensus_hash=consensus_hash ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey, consensus_hash=consensus_hash ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey, consensus_hash=consensus_hash ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey, consensus_hash=consensus_hash ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey, consensus_hash=consensus_hash ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) # now update (5) resp = testlib.blockstack_name_update( "foo.test", "22" * 20, wallets[5].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # update transfer resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_update( "foo.test", "33" * 20, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # update --> transfer --> transfer --> update resp = testlib.blockstack_name_update( "foo.test", "44" * 20, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey, consensus_hash=consensus_hash ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey, consensus_hash=consensus_hash ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_update( "foo.test", "55" * 20, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # update --> transfer --> update --> transfer resp = testlib.blockstack_name_update( "foo.test", "66" * 20, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[5].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # transfer resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey, consensus_hash=consensus_hash ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw )
def scenario( wallets, **kw ): # 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 ) # 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]] for i in xrange(0, len(names)): name = names[i] register_wallet = name_register_wallets[i] resp = testlib.blockstack_name_import( name, register_wallet.addr, str(9 - i) * 40, wallets[1].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # namespace ready... 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 ) # 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.blockstack_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.blockstack_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 # 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.blockstack_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 update_blocks, transfer_blocks, update_hashes, transfer_recipients testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_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.blockstack_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) # preorder, register, update, expire (multiple times) # account for namespace lifetime multipler (in 0.0.14) for i in xrange(2, 11): resp = testlib.blockstack_name_preorder( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr, consensus_hash=consensus_hash ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_register( "foo.test", wallets[i].privkey, wallets[(i+1)%11].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_update( "foo.test", ("%02x" % i) * 20, wallets[(i+1)%11].privkey, consensus_hash=consensus_hash ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) update_blocks.append( testlib.get_current_block( **kw )) update_hashes.append( ("%02x" % i) * 20 ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[i].addr, True, wallets[(i+1)%11].privkey, consensus_hash=consensus_hash ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) transfer_blocks.append( testlib.get_current_block( **kw ) ) transfer_recipients.append( wallets[i].addr ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) if i == 10: break # eat up the rest of the lifetime for j in xrange(0, 10 * NAMESPACE_LIFETIME_MULTIPLIER - 10): testlib.next_block( **kw ) consensus_hash = testlib.get_consensus_at( testlib.get_current_block(**kw), **kw) testlib.next_block( **kw ) testlib.next_block( **kw ) testlib.next_block( **kw )
def scenario( wallets, **kw ): # 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 ) # 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.blockstack_name_import( name, register_wallet.addr, str(9 - i) * 40, import_key, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # namespace ready... 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 ) # 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.blockstack_name_update( name, str(i + 2) * 40, register_wallet.privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) 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.blockstack_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.blockstack_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 # 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.blockstack_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 import_block global failed_blocks # 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, 2, 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[3].addr, "11" * 20, wallets[1].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) import_block = testlib.get_current_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) # wait for expiration (with multipler)... for i in xrange(0, 2 * NAMESPACE_LIFETIME_MULTIPLIER + 1): testlib.next_block(**kw) # verify that operations fail resp = testlib.blockstack_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.blockstack_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.blockstack_name_renew("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)) # should fail resp = testlib.blockstack_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): testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) resp = testlib.blockstack_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) 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.blockstack_name_import("foo%s.test" % i, wallets[3].addr, "22" * 20, wallets[1].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) print "\nImport 27 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, 27): resp = testlib.blockstack_name_import("bar%s.test" % i, wallets[4].addr, "33" * 20, wallets[1].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) testlib.blockstack_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) print wallets[3].privkey resp = testlib.blockstack_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.blockstack_name_register("foofail.test", wallets[3].privkey, wallets[1].addr) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # should succeed resp = testlib.blockstack_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.blockstack_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.blockstack_name_register("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--have to revoke or give names away) resp = testlib.blockstack_name_update("bar0.test", '44' * 20, wallets[4].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # should succeed (give a name away) resp = testlib.blockstack_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.blockstack_name_update("bar0.test", '44' * 20, wallets[4].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # should succeed (revoke a name) resp = testlib.blockstack_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.blockstack_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 ): subsidy_wallet = wallets[5] print json.dumps( testlib.getrawtransaction( "28f78fbae22d2273341af231a2ac049d74958e1e6ce6ae622cd48d8f0fef591e", 1 ), indent=4 ) 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_namespace_ready( "test", wallets[1].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # subsidized transactions... resp = testlib.blockstack_name_preorder( "foo.test", None, wallets[3].addr, subsidy_key=subsidy_wallet.privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) # (already subsidized...) send_subsidized( None, resp, **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_register( "foo.test", None, wallets[3].addr, subsidy_key=subsidy_wallet.privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) # (already subsidized...) send_subsidized( None, resp, **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_update( "foo.test", "11" * 20, None, user_public_key=wallets[3].pubkey_hex, subsidy_key=subsidy_wallet.privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) send_subsidized( wallets[3].privkey, resp, **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, None, user_public_key=wallets[3].pubkey_hex, subsidy_key=subsidy_wallet.privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) send_subsidized( wallets[3].privkey, resp, **kw ) testlib.next_block( **kw ) resp = testlib.blockstack_name_revoke( "foo.test", None, user_public_key=wallets[4].pubkey_hex, subsidy_key=subsidy_wallet.privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) send_subsidized( wallets[4].privkey, resp, **kw ) # advance a bit for i in xrange(0, 5): testlib.next_block( **kw )
def scenario( wallets, **kw ): global fail_blocks testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_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.blockstack_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) testlib.blockstack_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) testlib.blockstack_name_revoke( "foo.test", wallets[3].privkey ) testlib.next_block( **kw ) # can't do anything with the name for another 10 blocks resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[3].privkey ) 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.blockstack_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.blockstack_name_renew( "foo.test", 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)) # 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.blockstack_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.blockstack_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.blockstack_name_renew( "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)) # re-preorder... resp = testlib.blockstack_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.blockstack_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 last_consensus, snv_block_id # 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_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]] resp = testlib.blockstack_name_preorder_multi( names, wallets[2].privkey, [wallets[5].addr, wallets[6].addr, wallets[7].addr]) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) 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.blockstack_name_register( name, wallets[2].privkey, register_wallet.addr ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) snv_block_id = testlib.get_current_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.blockstack_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.blockstack_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.blockstack_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.blockstack_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 ) last_consensus = testlib.get_consensus_at( testlib.get_current_block( **kw ), **kw )
def scenario(wallets, **kw): testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 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.blockstack_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.blockstack_name_preorder("foo1.test", wallets[2].privkey, wallets[3].addr) testlib.blockstack_name_preorder("foo2.test", wallets[2].privkey, wallets[3].addr) testlib.blockstack_name_preorder("foo3.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.blockstack_name_register("foo1.test", wallets[2].privkey, wallets[3].addr, zonefile_hash='11' * 20) testlib.blockstack_name_register("foo2.test", wallets[2].privkey, wallets[3].addr, zonefile_hash='22' * 20) testlib.blockstack_name_register("foo3.test", wallets[2].privkey, wallets[3].addr, zonefile_hash='33' * 20) testlib.next_block(**kw) def name_rec_equal(r1, r2): keys = set(r1.keys() + r2.keys()) for k in keys: if k in r1 and k in r2: if r1[k] != r2[k]: return False return True # dids for each of these names dids = [ 'did:stack:v0:{}-0'.format(wallets[3].addr), 'did:stack:v0:{}-1'.format(wallets[3].addr), 'did:stack:v0:{}-2'.format(wallets[3].addr) ] # whois for i in xrange(1, 4): name = 'foo{}.test'.format(i) res = testlib.blockstack_cli_whois(name) if 'error' in res: print res return False if not res.has_key('zonefile_hash') or res[ 'zonefile_hash'] != '{}{}'.format(i, i) * 20: print res return False if res['owner_address'] != wallets[3].addr: print res return False # DIDs for i in xrange(0, 3): name = 'foo{}.test'.format(i + 1) res = blockstack.lib.client.get_name_DID( name, hostport='http://localhost:{}'.format( blockstack.lib.config.RPC_SERVER_PORT)) if 'error' in res: print res return False if res != dids[i]: print 'DID mismatch: expected {}, got {}'.format(dids[i], res) return False res = blockstack.lib.client.get_name_record( name, hostport='http://localhost:{}'.format( blockstack.lib.client.RPC_SERVER_PORT)) if 'error' in res: print res return False name_rec = res res = blockstack.lib.client.get_DID_record( dids[i], hostport='http://localhost:{}'.format( blockstack.lib.client.RPC_SERVER_PORT)) if 'error' in res: print res return False did_rec = res if not name_rec_equal(name_rec, did_rec): print 'record mismatch' print json.dumps(name_rec, sort_keys=True) print json.dumps(did_rec, sort_keys=True) return False # do stuff with these names testlib.blockstack_name_update("foo1.test", "1b" * 20, wallets[3].privkey) testlib.blockstack_name_update("foo2.test", "2b" * 20, wallets[3].privkey) testlib.blockstack_name_update("foo3.test", "3b" * 20, wallets[3].privkey) testlib.blockstack_name_revoke("foo1.test", wallets[3].privkey) testlib.blockstack_name_transfer("foo2.test", wallets[4].addr, True, wallets[3].privkey) testlib.blockstack_name_transfer("foo3.test", wallets[4].addr, True, wallets[3].privkey) testlib.next_block(**kw) name_recs = { 'foo1.test': blockstack.lib.client.get_name_record( 'foo1.test', hostport='http://localhost:{}'.format( blockstack.lib.client.RPC_SERVER_PORT)), 'foo2.test': blockstack.lib.client.get_name_record( 'foo2.test', hostport='http://localhost:{}'.format( blockstack.lib.client.RPC_SERVER_PORT)), 'foo3.test': blockstack.lib.client.get_name_record( 'foo3.test', hostport='http://localhost:{}'.format( blockstack.lib.client.RPC_SERVER_PORT)), } assert name_recs['foo1.test']['revoked'] assert virtualchain.address_reencode(str( name_recs['foo2.test']['address'])) == virtualchain.address_reencode( str(wallets[4].addr)) assert virtualchain.address_reencode(str( name_recs['foo3.test']['address'])) == virtualchain.address_reencode( str(wallets[4].addr)) # expire. Reregister under the same owner testlib.next_block(**kw) testlib.next_block(**kw) testlib.next_block(**kw) testlib.next_block(**kw) testlib.next_block(**kw) testlib.blockstack_name_preorder("foo1.test", wallets[2].privkey, wallets[3].addr) testlib.blockstack_name_preorder("foo2.test", wallets[2].privkey, wallets[3].addr) testlib.blockstack_name_preorder("foo3.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.blockstack_name_register("foo1.test", wallets[2].privkey, wallets[3].addr, zonefile_hash='1a' * 20) testlib.blockstack_name_register("foo2.test", wallets[2].privkey, wallets[3].addr, zonefile_hash='2a' * 20) testlib.blockstack_name_register("foo3.test", wallets[2].privkey, wallets[3].addr, zonefile_hash='3a' * 20) testlib.next_block(**kw) # whois for i in xrange(1, 4): name = 'foo{}.test'.format(i) res = testlib.blockstack_cli_whois(name) if 'error' in res: print res return False if not res.has_key('zonefile_hash' ) or res['zonefile_hash'] != '{}a'.format(i) * 20: print res return False if res['owner_address'] != wallets[3].addr: print res return False # dids for each of these names new_dids = [ 'did:stack:v0:{}-3'.format(wallets[3].addr), 'did:stack:v0:{}-4'.format(wallets[3].addr), 'did:stack:v0:{}-5'.format(wallets[3].addr) ] # new DIDs for i in xrange(0, 3): name = 'foo{}.test'.format(i + 1) res = blockstack.lib.client.get_name_DID( name, hostport='http://localhost:{}'.format( blockstack.lib.config.RPC_SERVER_PORT)) if 'error' in res: print res return False if res != new_dids[i]: print 'DID mismatch: expected {}, got {}'.format(new_dids[i], res) return False res = blockstack.lib.client.get_name_record( name, hostport='http://localhost:{}'.format( blockstack.lib.client.RPC_SERVER_PORT)) if 'error' in res: print res return False name_rec = res res = blockstack.lib.client.get_DID_record( new_dids[i], hostport='http://localhost:{}'.format( blockstack.lib.client.RPC_SERVER_PORT)) if 'error' in res: print res return False did_rec = res if not name_rec_equal(name_rec, did_rec): print 'record mismatch' print json.dumps(name_rec, sort_keys=True) print json.dumps(did_rec, sort_keys=True) return False # old DIDs for i in xrange(0, 3): name = 'foo{}.test'.format(i + 1) res = blockstack.lib.client.get_DID_record( dids[i], hostport='http://localhost:{}'.format( blockstack.lib.client.RPC_SERVER_PORT)) did_rec = res old_rec = name_recs[name] if old_rec.get('revoked') and 'error' not in did_rec: print 'revoked did is sitll valid: {}'.format(dids[i]) print did_rec return False elif not name_rec_equal(did_rec, old_rec): print 'old record mismatch' print json.dumps(did_rec, sort_keys=True) print json.dumps(old_rec, sort_keys=True) return False
def scenario( wallets, **kw ): testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey ) testlib.next_block( **kw ) resp = testlib.blockstack_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 ) 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.blockstack_name_import( "foo%s.test" % i, wallets[3].addr, "22" * 20, wallets[1].privkey ) if 'error' in resp: print json.dumps(resp, indent=4 ) testlib.next_block( **kw ) print "\nImport 27 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, 27): resp = testlib.blockstack_name_import( "bar%s.test" % i, wallets[4].addr, "33" * 20, wallets[1].privkey ) if 'error' in resp: print json.dumps(resp, indent=4 ) testlib.next_block( **kw ) testlib.blockstack_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) print wallets[3].privkey resp = testlib.blockstack_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.blockstack_name_register( "foofail.test",wallets[3].privkey, wallets[1].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # should succeed resp = testlib.blockstack_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.blockstack_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.blockstack_name_register( "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--have to revoke or give names away) resp = testlib.blockstack_name_update( "bar0.test", '44' * 20, wallets[4].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # should succeed (give a name away) resp = testlib.blockstack_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.blockstack_name_update( "bar0.test", '44' * 20, wallets[4].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # should succeed (revoke a name) resp = testlib.blockstack_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.blockstack_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, consensus 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_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_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.blockstack_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.blockstack_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.blockstack_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.blockstack_name_update("foo.test", "22" * 20, wallets[4].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstack_name_transfer("foo.test", wallets[3].addr, False, wallets[4].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstack_name_update("foo.test", "33" * 20, wallets[3].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) consensus = testlib.get_consensus_at(testlib.get_current_block(**kw), **kw) testlib.next_block(**kw) resp = testlib.blockstack_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)
def scenario(wallets, **kw): global first_name_block # make a test namespace resp = testlib.blockstack_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) # end of 689 # 4-block lifetime in practice resp = testlib.blockstack_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) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) # 690 resp = testlib.blockstack_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.next_block(**kw) # 691 first_name_block = testlib.get_current_block(**kw) resp = testlib.blockstack_namespace_ready("test", wallets[1].privkey) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) # end of 692. epoch 2 activates now whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print 'failed to whois foo.test' print json.dumps(whois, indent=4) return False # this should be the second-to-last block if whois['expire_block'] != testlib.get_current_block(**kw) + 2: print 'wrong expire block (now: {})'.format( testlib.get_current_block(**kw)) print whois return False print whois testlib.next_block(**kw) # end of 693 whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print 'failed to whois foo.test' print json.dumps(whois, indent=4) return False # we should have 3 more block to go now. if whois['expire_block'] != testlib.get_current_block(**kw) + 3: print 'wrong expire block (should be 3 blocks away from {})'.format( testlib.get_current_block(**kw)) print whois return False print whois resp = testlib.blockstack_name_transfer('foo.test', wallets[4].addr, True, wallets[3].privkey) if 'error' in resp: print resp return False testlib.next_block(**kw) # end of 694, begin epoch 3 whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print 'failed to whois foo.test' print json.dumps(whois, indent=4) return False # we should have 2 more blocks to go now. if whois['expire_block'] != testlib.get_current_block(**kw) + 2: print 'wrong expire block' print whois return False if whois['renewal_deadline'] != testlib.get_current_block(**kw) + 2: print 'wrong renewal deadline' print whois return False print whois testlib.next_block(**kw) # end of 695 whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print 'failed to whois foo.test' print json.dumps(whois, indent=4) return False # we should have 1 more blocks to go now. if whois['expire_block'] != testlib.get_current_block(**kw) + 1: print 'wrong expire block' print whois return False if whois['renewal_deadline'] != testlib.get_current_block(**kw) + 6: print 'wrong renewal deadline' print whois return False print whois testlib.next_block(**kw) # end of 696. Name should be expired # update should be impossible, since we're now in the renewal period resp = testlib.blockstack_name_update('foo.test', '66' * 20, wallets[4].privkey, expect_fail=True) if 'error' not in resp: print resp return False # renew should work resp = testlib.blockstack_name_renew('foo.test', wallets[4].privkey, zonefile_hash='22' * 20, recipient_addr=wallets[2].addr) if 'error' in resp: print resp return False testlib.next_block(**kw) # end of 697 whois = testlib.blockstack_cli_whois('foo.test') if 'error' in whois: print whois return False print whois if whois['expire_block'] != testlib.get_current_block(**kw) + 4: print 'expire block: {}'.format(whois['expire_block']) print 'current block + 4: {}'.format( testlib.get_current_block(**kw) + 4) return False if whois['renewal_deadline'] != testlib.get_current_block(**kw) + 9: print 'renewal deadline: {}'.format(whois['renewal_deadline']) print 'current block + 9: {}'.format( testlib.get_current_block(**kw) + 9) return False
def scenario(wallets, **kw): global renew_block testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_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.blockstack_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.blockstack_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.blockstack_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) whois = testlib.blockstack_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.blockstack_name_update("foo.test", '22' * 20, wallets[3].privkey) if 'error' not in res: print res return False res = testlib.blockstack_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.blockstack_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.blockstack_name_transfer('foo.test', wallets[4].addr, True, wallets[3].privkey) if 'error' not in res: print res return False res = testlib.blockstack_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.blockstack_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.blockstack_name_revoke('foo.test', wallets[3].privkey) if 'error' not in res: print res return False res = testlib.blockstack_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.blockstack_cli_whois('foo.test') if 'error' in res: print res return False # can renew res = testlib.blockstack_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)
def scenario(wallets, **kw): global debug 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_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_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.blockstack_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.blockstack_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.blockstack_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.blockstack_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))
def scenario(wallets, **kw): testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 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.blockstack_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) # preorder, register, update, expire (multiple times) # only the first round should succeed, due to the namespace lifetime multipler # introduced in 0.14 for i in xrange(2, 4): resp = testlib.blockstack_name_preorder("foo.test", wallets[i].privkey, wallets[(i + 1) % 11].addr, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.blockstack_name_register("foo.test", wallets[i].privkey, wallets[(i + 1) % 11].addr, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) if i == 3: testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) testlib.next_block(**kw) resp = testlib.blockstack_name_update("foo.test", ("%02x" % i) * 20, wallets[(i + 1) % 11].privkey, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) if i == 3: testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) testlib.next_block(**kw) resp = testlib.blockstack_name_transfer("foo.test", wallets[i].addr, True, wallets[(i + 1) % 11].privkey, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) if i == 3: testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) testlib.next_block(**kw)
def scenario(wallets, **kw): # make a test namespace resp = testlib.blockstack_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.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 '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.blockstack_name_import(name, register_wallet.addr, str(9 - i) * 40, import_key) if 'error' in resp: print json.dumps(resp, indent=4) return False testlib.next_block(**kw) # namespace ready... resp = testlib.blockstack_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.blockstack_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.blockstack_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.blockstack_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.blockstack_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.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.blockstack_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.blockstack_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) testlib.blockstack_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) resp = testlib.blockstack_name_update( "foo.test", "00" * 20, wallets[3].privkey ) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block( **kw ) testlib.blockstack_name_revoke( "foo.test", wallets[3].privkey ) testlib.next_block( **kw ) # can't do anything with the name for another 10 blocks resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # should fail resp = testlib.blockstack_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 ) # should fail resp = testlib.blockstack_name_renew( "foo.test", wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # wait for it to expire... for i in xrange(0, 8): testlib.next_block( **kw ) # verify that operations continue to fail resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # should fail resp = testlib.blockstack_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 ) # should fail resp = testlib.blockstack_name_renew( "foo.test", wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # re-preorder... resp = testlib.blockstack_name_preorder( "foo.test", wallets[4].privkey, wallets[0].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # re-register resp = testlib.blockstack_name_register( "foo.test", wallets[4].privkey, wallets[0].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # re-update resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[0].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw )
def scenario( wallets, **kw ): 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 ) # should get rejected 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 ) # should get rejected (NOTE: the underlying mock utxo provider doesn't handle double-spends!) 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 ) # should get accepted 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 ) # should get rejected (but only because the namespace isn't revealed until the block goes through) 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_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_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 ) # should get rejected resp = testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) # should get rejected (NOTE: the underlying mock utxo provider doesn't handle double-spends!) resp = testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # should succeed resp = testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # (this should succeed) resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) # (this should also succeed) resp = testlib.blockstack_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 ) # (this should succeed) resp = testlib.blockstack_name_renew( "foo.test", wallets[4].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) # (this should also succeed) resp = testlib.blockstack_name_update( "foo.test", "22" * 20, wallets[4].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) # (this should succeed) resp = testlib.blockstack_name_transfer( "foo.test", wallets[3].addr, True, wallets[4].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # lots of updates for i in xrange(0, 9): resp = testlib.blockstack_name_update( "foo.test", ("%s%s" % (i,i)) * 20, wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # transfer loop for i in xrange(0, 5): #resp = testlib.blockstack_name_transfer( "foo.test", wallets[3].addr, True, wallets[4].privkey ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[3].addr, True, wallets[4].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # update/transfer/update/transfer for i in xrange(0, 5): resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_update("foo.test", "aa" * 20, wallets[4].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer("foo.test", wallets[3].addr, True, wallets[4].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_update("foo.test", "bb" * 20, wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw )
def scenario( wallets, **kw ): resp = testlib.blockstack_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # should get rejected 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, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) # should get rejected (NOTE: the underlying mock utxo provider doesn't handle double-spends!) 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, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # should get accepted 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, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) # should get rejected (but only because the namespace isn't revealed until the block goes through) resp = testlib.blockstack_namespace_ready( "test", wallets[1].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_namespace_ready( "test", wallets[1].privkey, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.blockstack_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr, safety_checks=False ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # should get rejected resp = testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) # should get rejected (NOTE: the underlying mock utxo provider doesn't handle double-spends!) resp = testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) # don't SNV-check these testlib.expect_snv_fail_at( "foo.test", testlib.get_current_block( **kw )+1 ) testlib.next_block( **kw ) # should succeed resp = testlib.blockstack_name_register( "foo.test", wallets[2].privkey, wallets[3].addr, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # (this should succeed) resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[3].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) # (this should also succeed) resp = testlib.blockstack_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 ) # (this should succeed) resp = testlib.blockstack_name_renew( "foo.test", wallets[4].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) # (this should also succeed) resp = testlib.blockstack_name_update( "foo.test", "22" * 20, wallets[4].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) # (this should succeed) resp = testlib.blockstack_name_transfer( "foo.test", wallets[3].addr, True, wallets[4].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # lots of updates for i in xrange(0, 9): resp = testlib.blockstack_name_update( "foo.test", ("%s%s" % (i,i)) * 20, wallets[3].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # transfer loop for i in xrange(0, 5): #resp = testlib.blockstack_name_transfer( "foo.test", wallets[3].addr, True, wallets[4].privkey ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[3].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[3].addr, True, wallets[4].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # update/transfer/update/transfer for i in xrange(0, 5): resp = testlib.blockstack_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_update("foo.test", "aa" * 20, wallets[4].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer("foo.test", wallets[3].addr, True, wallets[4].privkey, safety_checks=False ) if 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_update("foo.test", "bb" * 20, wallets[3].privkey, safety_checks=False ) 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 debug 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_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_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.blockstack_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 ) # ping-ping a bit... 3 --> 4 --> 5 --> 4 --> 5 --> 4 resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, False, wallets[3].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, False, wallets[5].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, False, wallets[5].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # update (4) resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) # ping-ping a bit... 4 --> 5 --> 4 --> 5 --> 4 --> 5 resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, False, wallets[5].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, False, wallets[5].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, True, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) # now update (5) resp = testlib.blockstack_name_update( "foo.test", "22" * 20, wallets[5].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # transfer and update resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_update( "foo.test", "33" * 20, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # update, transfer, transfer, update resp = testlib.blockstack_name_update( "foo.test", "44" * 20, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, False, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_update( "foo.test", "55" * 20, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # update, transfer, update resp = testlib.blockstack_name_update( "foo.test", "66" * 20, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, False, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_update( "foo.test", "11" * 20, wallets[5].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # transfer and update resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_update( "foo.test", "33" * 20, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # update, transfer resp = testlib.blockstack_name_update( "foo.test", "99" * 20, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) resp = testlib.blockstack_name_transfer( "foo.test", wallets[5].addr, False, wallets[4].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # transfer resp = testlib.blockstack_name_transfer( "foo.test", wallets[4].addr, True, wallets[5].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw )
def scenario(wallets, **kw): testlib.blockstack_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.blockstack_namespace_reveal( "test", wallets[1].addr, 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.blockstack_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.blockstack_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.blockstack_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) resp = testlib.blockstack_name_update("foo.test", "00" * 20, wallets[3].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) testlib.blockstack_name_revoke("foo.test", wallets[3].privkey) testlib.next_block(**kw) # can't do anything with the name for another 10 blocks resp = testlib.blockstack_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.blockstack_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.blockstack_name_renew("foo.test", 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)) # 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.blockstack_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.blockstack_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.blockstack_name_renew("foo.test", 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)) # re-preorder... resp = testlib.blockstack_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.blockstack_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.blockstack_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)