def scenario( wallets, **kw ): global last_first_block, first_preorder testlib.ysi_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) # NOTE: names expire in 5 * NAMESPACE_LIFETIME_MULTIPLER blocks testlib.ysi_namespace_reveal( "test", wallets[1].addr, 2, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey ) testlib.next_block( **kw ) testlib.ysi_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) testlib.ysi_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.ysi_name_preorder( "foo.test", wallets[3].privkey, wallets[4].addr ) testlib.next_block( **kw ) first_preorder = testlib.get_current_block( **kw ) testlib.ysi_name_register( "foo.test", wallets[2].privkey, wallets[3].addr ) testlib.next_block( **kw ) for i in xrange(0, 2 * ysi_server.config.get_epoch_namespace_lifetime_multiplier( testlib.get_current_block(**kw), "test" ) + 1): testlib.next_block( **kw ) testlib.next_block( **kw ) # should fail testlib.ysi_name_register( "foo.test", wallets[3].privkey, wallets[4].addr ) testlib.next_block( **kw ) testlib.expect_snv_fail_at('foo.test', testlib.get_current_block(**kw)) last_first_block = testlib.get_current_block( **kw )
def scenario(wallets, **kw): global snv_block_id, last_consensus testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) snv_block_id = testlib.get_current_block() resp = testlib.ysi_name_revoke("foo.test", wallets[3].privkey) testlib.next_block(**kw) last_consensus = testlib.get_consensus_at(testlib.get_current_block())
def scenario(wallets, **kw): testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) # wait for a bit... for i in xrange(0, 10): testlib.next_block(**kw) # has to be the same key that registered... resp = testlib.ysi_name_renew("foo.test", wallets[4].privkey, safety_checks=False, tx_fee=10000 * 5) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) testlib.next_block(**kw)
def scenario(wallets, **kw): testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) # update and transfer back and forth a few times for i in xrange(0, 5): result = testlib.ysi_name_update("foo.test", str(i) * 40, wallets[3 + (i % 2)].privkey) update_hashes.append(str(i) * 40) testlib.next_block(**kw) result = testlib.ysi_name_transfer("foo.test", wallets[3 + ((i + 1) % 2)].addr, True, wallets[3 + (i % 2)].privkey) testlib.next_block(**kw)
def scenario(wallets, **kw): testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) # wait for a bit... for i in xrange(0, 10): testlib.next_block(**kw) resp = testlib.ysi_name_renew("foo.test", wallets[3].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) testlib.next_block(**kw)
def scenario(wallets, **kw): testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) # only wallets[3] should get it testlib.ysi_name_register("foo.test", wallets[4].privkey, wallets[3].addr, safety_checks=False) testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr, safety_checks=False) testlib.next_block(**kw) testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw))
def scenario(wallets, **kw): testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 5, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) # pre-0.0.14 uses lifetime field literally; this should no longer work. for i in xrange(0, 5 * NAMESPACE_LIFETIME_MULTIPLIER): testlib.next_block(**kw) testlib.next_block(**kw)
def scenario(wallets, **kw): # save the wallet wallet = testlib.ysi_client_initialize_wallet("0123456789abcdef", wallets[2].privkey, wallets[3].privkey, wallets[4].privkey, start_rpc=False) if 'error' in wallet: print 'failed to set wallet: {}'.format(wallet) return False testlib.ysi_namespace_preorder("id", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "id", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("id", wallets[1].privkey) testlib.next_block(**kw) testlib.ysi_name_preorder("demo.id", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("demo.id", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw)
def scenario(wallets, **kw): global working_dir testlib.ysi_namespace_preorder("id", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "id", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("id", wallets[1].privkey) testlib.next_block(**kw) testlib.ysi_name_preorder("judecn.id", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("judecn.id", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) resp = testlib.ysi_announce("hello world!", wallets[3].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_announce("This should not appear", wallets[4].privkey) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # save... working_dir = testlib.get_working_dir(**kw)
def scenario(wallets, **kw): testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_update("foo.test", "11" * 20, wallets[3].privkey) testlib.next_block(**kw) testlib.ysi_name_transfer("foo.test", wallets[4].addr, False, wallets[3].privkey) testlib.next_block(**kw)
def scenario(wallets, **kw): testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) # NOTE: names expire in 5 * NAMESPACE_LIFETIME_MULTIPLER blocks testlib.ysi_namespace_reveal( "test", wallets[1].addr, 5, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) for i in xrange(0, 5 * NAMESPACE_LIFETIME_MULTIPLIER): testlib.next_block(**kw) testlib.next_block(**kw)
def scenario(wallets, **kw): global snv_block_id, last_consensus testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) # NOTE: names expire in 5 * NAMESPACE_LIFETIME_MULTIPLIER blocks testlib.ysi_namespace_reveal( "test", wallets[1].addr, 5, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) snv_block_id = testlib.get_current_block() for i in xrange(0, 5 * NAMESPACE_LIFETIME_MULTIPLIER): testlib.next_block(**kw) # this one expires the name testlib.next_block(**kw) last_consensus = testlib.get_consensus_at(testlib.get_current_block())
def scenario( wallets, **kw ): global update_block # make a test namespace resp = testlib.ysi_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.ysi_namespace_reveal( "test", wallets[1].addr, 6, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.ysi_name_import( "foo.test", wallets[3].addr, "11" * 20, wallets[1].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.ysi_namespace_ready( "test", wallets[1].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # wait for a bit... for i in xrange(0, 6): testlib.next_block( **kw ) resp = testlib.ysi_name_renew( "foo.test", wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # update resp = testlib.ysi_name_update( "foo.test", "22" * 20, wallets[3].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) update_block = testlib.get_current_block( **kw ) # expire for i in xrange(0, 6 * NAMESPACE_LIFETIME_MULTIPLIER): testlib.next_block( **kw ) # re-register testlib.ysi_name_preorder( "foo.test", wallets[7].privkey, wallets[8].addr ) testlib.next_block( **kw ) testlib.ysi_name_register( "foo.test", wallets[7].privkey, wallets[8].addr ) testlib.next_block( **kw )
def scenario(wallets, **kw): testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) # 689 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) # 690 testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) # 691 testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) # 692 # should fail (safety checks stop it) resp = testlib.ysi_name_register('foo.test', wallets[2].privkey, wallets[3].addr, zonefile_hash='22' * 20) if 'error' not in resp: print resp return False # should succeed in being sent, but will be rejected resp = testlib.ysi_name_register('foo.test', wallets[2].privkey, wallets[3].addr, zonefile_hash='22' * 20, safety_checks=False, tx_fee=300 * 5) if 'error' in resp: print resp return False testlib.next_block(**kw) # 693 testlib.expect_snv_fail_at("foo.test", testlib.get_current_block(**kw)) # must NOT be registered resp = testlib.ysi_cli_whois('foo.test') if 'error' not in resp: print resp return False # epoch 3 now active. # try again, and it should succeed resp = testlib.ysi_name_register('foo.test', wallets[2].privkey, wallets[3].addr, zonefile_hash='22' * 20) if 'error' in resp: print resp return False testlib.next_block(**kw) # 694
def scenario( wallets, **kw ): global import_block_1, import_block_2 # make a test namespace resp = testlib.ysi_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.ysi_namespace_reveal( "test", wallets[1].addr, 10, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) resp = testlib.ysi_name_import( "foo.test", wallets[3].addr, "11" * 20, wallets[1].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) import_block_1 = testlib.get_current_block( **kw ) testlib.next_block( **kw ) resp = testlib.ysi_name_import( "foo.test", wallets[4].addr, "22" * 20, wallets[1].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) import_block_2 = testlib.get_current_block( **kw ) testlib.next_block( **kw ) resp = testlib.ysi_namespace_ready( "test", wallets[1].privkey ) if debug or 'error' in resp: print json.dumps( resp, indent=4 ) testlib.next_block( **kw ) # wait for expiration (with multipler)... for i in xrange(0, 10 * NAMESPACE_LIFETIME_MULTIPLIER): testlib.next_block( **kw ) # re-register testlib.ysi_name_preorder( "foo.test", wallets[7].privkey, wallets[8].addr ) testlib.next_block( **kw ) testlib.ysi_name_register( "foo.test", wallets[7].privkey, wallets[8].addr ) testlib.next_block( **kw )
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): 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) # try to exceed quota (currently 25) for i in xrange(0, 25): resp = testlib.ysi_name_preorder("foo%s.test" % i, wallets[2].privkey, wallets[3].addr) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) for i in xrange(0, 25): resp = testlib.ysi_name_register("foo%s.test" % i, wallets[2].privkey, wallets[3].addr) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_name_preorder("bar.test", wallets[2].privkey, wallets[3].addr) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) # should fail resp = testlib.ysi_name_register("bar.test", wallets[2].privkey, wallets[3].addr, safety_checks=False) if 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) testlib.expect_snv_fail_at('bar.test', testlib.get_current_block(**kw))
def scenario( wallets, **kw ): testlib.ysi_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 2, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey, version_bits=2) testlib.next_block( **kw ) resp = testlib.ysi_name_import( "foo.test", wallets[3].addr, "11" * 20, wallets[1].privkey ) if 'error' in resp: print json.dumps( resp, indent=4 ) return False testlib.next_block( **kw ) testlib.ysi_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) # expire it for i in xrange(0, 4): testlib.next_block(**kw) whois = testlib.ysi_cli_whois('foo.test') if 'error' not in whois: print whois return False namespace_rec = testlib.ysi_cli_get_namespace_blockchain_record("test") if 'error' in namespace_rec: print namespace_rec return False namespace_balance = testlib.get_balance(namespace_rec['address']) res = testlib.ysi_name_preorder( "foo.test", wallets[2].privkey, wallets[4].addr ) if 'error' in res: print res return False testlib.next_block( **kw ) res = testlib.ysi_name_register( "foo.test", wallets[2].privkey, wallets[4].addr, zonefile_hash='22' * 20 ) if 'error' in res: print res return False testlib.next_block( **kw ) new_namespace_balance = testlib.get_balance(namespace_rec['address']) name_rec = testlib.get_name_blockchain_record('foo.test') name_cost = name_rec['op_fee'] if new_namespace_balance - namespace_balance != name_cost: print 'address {} did not get credited'.format(namespace_rec['address']) print '{} != {} + {}'.format(new_namespace_balance, namespace_balance, name_cost) return False if name_rec['value_hash'] != '22' * 20: print 'wrong value hash' return False
def scenario( wallets, **kw ): testlib.ysi_namespace_preorder( "test", wallets[1].addr, wallets[0].privkey ) testlib.next_block( **kw ) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0], 10, 10, wallets[0].privkey ) testlib.next_block( **kw ) testlib.ysi_namespace_ready( "test", wallets[1].privkey ) testlib.next_block( **kw ) resp = testlib.ysi_name_preorder( "foo.test", wallets[2].privkey, wallets[3].addr ) if 'error' in resp: print json.dumps( resp ) testlib.next_block( **kw ) # wait for it to expire (takes a day) for i in xrange(0, 145): testlib.next_block( **kw ) # re-preorder it resp = testlib.ysi_name_preorder( "foo.test", wallets[3].privkey, wallets[4].addr ) if 'error' in resp: print json.dumps( resp ) testlib.next_block( **kw ) # register it resp = testlib.ysi_name_register( "foo.test", wallets[3].privkey, wallets[4].addr ) if 'error' in resp: print json.dumps( resp ) testlib.next_block( **kw )
def scenario(wallets, **kw): global debug, consensus resp = testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_namespace_ready("test", wallets[1].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_name_transfer("foo.test", wallets[4].addr, True, wallets[3].privkey) if debug or 'error' in resp: print json.dumps(resp, indent=4) testlib.next_block(**kw) resp = testlib.ysi_name_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.ysi_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): print '\nactivating segwit\n' virtualchain.set_features("segwit", True) print '\nsegwit state: {}\n'.format(virtualchain.get_features('segwit')) testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) virtualchain.set_features("segwit", False) testlib.next_block(**kw) virtualchain.set_features("segwit", True) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) virtualchain.set_features("segwit", False) testlib.next_block(**kw) virtualchain.set_features("segwit", True) testlib.ysi_namespace_ready("test", wallets[1].privkey) virtualchain.set_features("segwit", False) testlib.next_block(**kw) virtualchain.set_features("segwit", True) testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr, wallet=wallets[3]) virtualchain.set_features("segwit", False) testlib.next_block(**kw) virtualchain.set_features("segwit", True) testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr, wallet=wallets[3]) virtualchain.set_features("segwit", False) testlib.next_block(**kw) virtualchain.set_features("segwit", True)
def scenario(wallets, **kw): global last_first_block, first_preorder testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) # NOTE: names expire in 5 * NAMESPACE_LIFETIME_MULTIPLER blocks testlib.ysi_namespace_reveal( "test", wallets[1].addr, 5, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) first_preorder = testlib.get_current_block(**kw) testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) for i in xrange(0, 5): testlib.next_block(**kw) # epoch shifts here # 266 testlib.next_block(**kw) # actually expire for i in xrange( 0, 5 * ysi_server.config.get_epoch_namespace_lifetime_multiplier( testlib.get_current_block(**kw), "test") - 5): testlib.next_block(**kw) # should work now testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) last_first_block = testlib.get_current_block(**kw)
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 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 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 update_blocks, transfer_blocks, update_hashes, transfer_recipients testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 2, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) # preorder, register, update, expire (multiple times) for i in xrange(2, 5): resp = testlib.ysi_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.ysi_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.ysi_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.ysi_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): # save the wallet wallet = testlib.ysi_client_initialize_wallet("0123456789abcdef", wallets[2].privkey, wallets[3].privkey, wallets[4].privkey, start_rpc=False) if 'error' in wallet: print 'failed to set wallet: {}'.format(wallet) return False testlib.ysi_namespace_preorder("id", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "id", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("id", wallets[1].privkey) testlib.next_block(**kw) testlib.ysi_name_preorder("foo.id", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("foo.id", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) # start api server res = testlib.start_api("0123456789abcdef") if 'error' in res: print 'failed to start API server: {}'.format(res) return False # set up node environment nodedir = testlib.nodejs_setup() # run 'core-test' test on ysi (tests authentication from ysi.js to Core API) testlib.nodejs_copy_package(nodedir, "ysi") testlib.nodejs_copy_package(nodedir, "ysi-storage") testlib.nodejs_run_test(nodedir, "integration-test-storage") testlib.nodejs_cleanup(nodedir)
def scenario(wallets, **kw): global update_hashes, update_blocks testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 1, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) # preorder, register, update, expire (multiple times) # take into account the new namespace lifetime multipler for i in xrange(2, 11): resp = testlib.ysi_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.ysi_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) testlib.next_block(**kw) resp = testlib.ysi_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) testlib.next_block(**kw) update_blocks.append(testlib.get_current_block(**kw)) update_hashes.append(("%02x" % i) * 20) # wait for expiration for j in xrange(0, NAMESPACE_LIFETIME_MULTIPLIER - 2): testlib.next_block(**kw) if i == 10: break testlib.next_block(**kw)
def scenario(wallets, **kw): testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 52595, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey, version_bits=2) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) namespace_rec = testlib.ysi_cli_get_namespace_blockchain_record("test") if 'error' in namespace_rec: print namespace_rec return False namespace_balance = testlib.get_balance(namespace_rec['address']) testlib.ysi_name_preorder("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) testlib.ysi_name_register("foo.test", wallets[2].privkey, wallets[3].addr) testlib.next_block(**kw) new_namespace_balance = testlib.get_balance(namespace_rec['address']) name_rec = testlib.get_name_blockchain_record('foo.test') name_cost = name_rec['op_fee'] if new_namespace_balance - namespace_balance != name_cost: print 'address {} did not get credited'.format( namespace_rec['address']) print '{} != {} + {}'.format(new_namespace_balance, namespace_balance, name_cost) return False
def scenario(wallets, **kw): testlib.ysi_namespace_preorder("test", wallets[1].addr, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_reveal( "test", wallets[1].addr, 2, 250, 4, [6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 10, 10, wallets[0].privkey) testlib.next_block(**kw) testlib.ysi_namespace_ready("test", wallets[1].privkey) testlib.next_block(**kw) # preorder, register, update, expire (multiple times) # do NOT take into account the new namespace lifetime multipler for i in xrange(2, 4): resp = testlib.ysi_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.ysi_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) + 1) testlib.next_block(**kw) if i == 3: break resp = testlib.ysi_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) + 1) testlib.next_block(**kw)