def scenario( wallets, **kw ): global final_consensus testlib.ysi_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey ) testlib.next_block( **kw ) testlib.ysi_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) resp = testlib.ysi_name_preorder_multi( ["foo.test", "bar.test", "baz.test"], wallets[2].privkey, [wallets[3].addr, wallets[4].addr, wallets[5].addr] ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw ) resp = testlib.ysi_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw ) resp = testlib.ysi_name_preorder( "goo.test", wallets[2].privkey, wallets[3].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw ) resp = testlib.ysi_name_register( "bar.test", wallets[2].privkey, wallets[4].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) resp = testlib.ysi_name_register( "goo.test", wallets[2].privkey, wallets[3].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) resp = testlib.ysi_name_register( "baz.test", wallets[2].privkey, wallets[5].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw )
def scenario(wallets, **kw): global final_consensus testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) resp = testlib.ysi_name_preorder_multi( ["foo.test", "bar.test", "baz.test"], wallets[2].privkey, [wallets[3].addr, wallets[4].addr, wallets[5].addr]) if 'error' in resp: print json.dumps(resp, indent=4) sys.exit(1) testlib.next_block(**kw) preorder_consensus = testlib.get_consensus_at(testlib.get_current_block()) # these should all fail, since they're paired with the wrong addresses resp = testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[5].addr) if 'error' in resp: print json.dumps(resp, indent=4) sys.exit(1) resp = testlib.ysi_name_register("bar.test", wallets[2].privkey, wallets[3].addr) if 'error' in resp: print json.dumps(resp, indent=4) sys.exit(1) resp = testlib.ysi_name_register("baz.test", wallets[2].privkey, wallets[4].addr) if 'error' in resp: print json.dumps(resp, indent=4) sys.exit(1) testlib.next_block(**kw)
def scenario( wallets, **kw ): global final_consensus testlib.ysi_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey ) testlib.next_block( **kw ) testlib.ysi_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) resp = testlib.ysi_name_preorder_multi( ["foo.test", "bar.test", "baz.test"], wallets[2].privkey, [wallets[3].addr, wallets[4].addr, wallets[5].addr] ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw ) preorder_consensus = testlib.get_consensus_at( testlib.get_current_block() ) resp = testlib.ysi_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) resp = testlib.ysi_name_register( "bar.test", wallets[2].privkey, wallets[4].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw ) # should cause the whole thing to fail, since we didn't preorder this separately resp = testlib.ysi_name_register( "goo.test", wallets[2].privkey, wallets[5].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) resp = testlib.ysi_name_register( "baz.test", wallets[2].privkey, wallets[5].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw )
def scenario( wallets, **kw ): global last_consensus, snv_block_id testlib.ysi_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey ) testlib.next_block( **kw ) testlib.ysi_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) resp = testlib.ysi_name_preorder_multi( ["foo.test", "bar.test", "baz.test"], wallets[2].privkey, [wallets[3].addr, wallets[4].addr, wallets[5].addr] ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw ) preorder_consensus = testlib.get_consensus_at( testlib.get_current_block() ) resp = testlib.ysi_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw ) resp = testlib.ysi_name_register( "bar.test", wallets[2].privkey, wallets[4].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) resp = testlib.ysi_name_register( "baz.test", wallets[2].privkey, wallets[5].addr ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw ) # all blocks registered here snv_block_id = testlib.get_current_block( **kw ) testlib.next_block( **kw ) last_consensus = testlib.get_consensus_at( testlib.get_current_block( **kw ), **kw )
def scenario(wallets, **kw): global last_consensus, snv_block_id # make a test namespace resp = testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_namespace_ready("test", wallets[1].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # preorder 3 names in the same block: foo.test, bar.test, baz.test names = ['foo.test', 'bar.test', 'baz.test'] name_preorder_wallets = [wallets[2], wallets[3], wallets[4]] name_register_wallets = [wallets[5], wallets[6], wallets[7]] name_transfer_wallets = [wallets[6], wallets[7], wallets[5]] resp = testlib.ysi_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.ysi_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.ysi_name_update(name, str(i + 1) * 40, register_wallet.privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # transfer 3 names in the same block for i in xrange(0, len(names)): name = names[i] register_wallet = name_register_wallets[i] transfer_wallet = name_transfer_wallets[i] resp = testlib.ysi_name_transfer(name, transfer_wallet.addr, True, register_wallet.privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # exchange after transfer... tmp = name_register_wallets name_register_wallets = name_transfer_wallets name_transfer_wallets = tmp # renew 3 names in the same block for i in xrange(0, len(names)): name = names[i] register_wallet = name_register_wallets[i] resp = testlib.ysi_name_renew(name, register_wallet.privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # revoke 3 names in the same block for i in xrange(0, len(names)): name = names[i] register_wallet = name_register_wallets[i] resp = testlib.ysi_name_revoke(name, register_wallet.privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) # iterate the blocks a few times for i in xrange(0, 5): testlib.next_block(**kw) last_consensus = testlib.get_consensus_at(testlib.get_current_block(**kw), **kw)
def scenario( wallets, **kw ): testlib.ysi_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey ) testlib.next_block( **kw ) testlib.ysi_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) resp = testlib.ysi_name_preorder_multi( ["foo2.test", "bar2.test"], wallets[2].privkey, [wallets[3].addr, wallets[4].addr]) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw ) print "\n%s %s %s" % (["foo4.test", "bar4.test", "baz4.test", "goo4.test"], pybitcoin.make_pay_to_address_script(wallets[2].addr), \ [wallets[3].addr, wallets[4].addr, wallets[5].addr, wallets[6].addr]) import ysi.lib.operations as ops h = ops.preorder_multi_hash_names( ["foo4.test", "bar4.test", "baz4.test", "goo4.test"], pybitcoin.make_pay_to_address_script(wallets[2].addr), \ [wallets[3].addr, wallets[4].addr, wallets[5].addr, wallets[6].addr]) print "hash: %s\n" % h resp = testlib.ysi_name_preorder_multi( ["foo4.test", "bar4.test", "baz4.test", "goo4.test"], wallets[2].privkey, [wallets[3].addr, wallets[4].addr, wallets[5].addr, wallets[6].addr] ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw ) resp = testlib.ysi_name_preorder_multi( ["foo6.test", "bar6.test", "baz6.test", "goo6.test", "quux6.test", "norf6.test"], wallets[2].privkey, \ [wallets[0].addr, wallets[1].addr, wallets[2].addr, wallets[3].addr, wallets[4].addr, wallets[5].addr] ) if 'error' in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw ) # should fail resp = testlib.ysi_name_preorder_multi( ["foo1.test"], wallets[2].privkey, [wallets[3].addr] ) if 'error' not in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw ) # should fail resp = testlib.ysi_name_preorder_multi( ["foo3.test", "bar3.test", "baz3.test"], wallets[2].privkey, [wallets[3].addr, wallets[4].addr, wallets[5].addr]) if 'error' not in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw ) # should fail resp = testlib.ysi_name_preorder_multi( ["foo5.test", "bar5.test", "baz5.test", "goo5.test", "quux5.test"], wallets[2].privkey, \ [wallets[0].addr, wallets[1].addr, wallets[2].addr, wallets[3].addr, wallets[4].addr] ) if 'error' not in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw ) # should fail resp = testlib.ysi_name_preorder_multi( ["foo7.test", "bar7.test", "baz7.test", "goo7.test", "quux7.test", "norf7.test", "xyzzy7.test"], wallets[2].privkey, \ [wallets[0].addr, wallets[1].addr, wallets[2].addr, wallets[3].addr, wallets[4].addr, wallets[5].addr, wallets[6].addr] ) if 'error' not in resp: print json.dumps( resp, indent=4 ) sys.exit(1) testlib.next_block( **kw )