def scenario(wallets, **kw): resp = testlib.ysi_cli_namespace_preorder("test", wallets[0].privkey, wallets[1].privkey) if 'error' in resp: print json.dumps(resp, indent=4, sort_keys=True) return False testlib.next_block(**kw) resp = testlib.ysi_cli_namespace_reveal('test', wallets[0].privkey, wallets[1].privkey, 52560, 4, 4, '6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0', 10, 10) if 'error' in resp: print json.dumps(resp, indent=4, sort_keys=True) return False testlib.next_block(**kw) resp = testlib.ysi_cli_namespace_ready('test', wallets[1].privkey) if 'error' in resp: print json.dumps(resp, indent=4, sort_keys=True) return False testlib.next_block(**kw)
def scenario(wallets, **kw): virtualchain.set_features('segwit', True) global preorder_block, reveal_block resp = testlib.ysi_cli_namespace_preorder("test", wallets[5].privkey, wallets[1].privkey) if 'error' in resp: print json.dumps(resp, indent=4, sort_keys=True) return False preorder_block = testlib.get_current_block(**kw) + 1 testlib.next_block(**kw) resp = testlib.ysi_cli_namespace_reveal('test', wallets[5].privkey, wallets[1].privkey, 52595, 250, 4, '6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0', 10, 10, version_bits=2) if 'error' in resp: print json.dumps(resp, indent=4, sort_keys=True) return False reveal_block = testlib.get_current_block(**kw) + 1 testlib.next_block(**kw)
def scenario( wallets, **kw ): # has the side-effect of starting the API server resp = testlib.ysi_client_initialize_wallet( "0123456789abcdef", wallets[2].privkey, wallets[3].privkey, wallets[4].privkey ) if 'error' in resp: print json.dumps(resp, indent=4, sort_keys=True) return False resp = testlib.ysi_cli_namespace_preorder("test", wallets[0].privkey, wallets[1].privkey) if 'error' in resp: print json.dumps(resp, indent=4, sort_keys=True) return False testlib.next_block(**kw) resp = testlib.ysi_cli_namespace_reveal('test', wallets[0].privkey, wallets[1].privkey, 52560, 4, 4, '6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0', 10, 10) if 'error' in resp: print json.dumps(resp, indent=4, sort_keys=True) return False testlib.next_block(**kw) 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, 4): import_key = private_keychain.child(i).private_key() print "fund {} (child {})".format(import_key, i) res = testlib.send_funds( wallets[1].privkey, 100000000, virtualchain.BitcoinPrivateKey(import_key).public_key().address() ) if 'error' in res: print json.dumps(res, indent=4, sort_keys=True) return False testlib.next_block(**kw) private_keys.append(import_key) # should fail (first key must be revealer) resp = testlib.ysi_cli_name_import("fail.test", wallets[2].addr, "Hello fail.test!", private_keys[1]) if 'error' not in resp: print json.dumps(resp, indent=4, sort_keys=True) return False # should succeed resp = testlib.ysi_cli_name_import("foo.test", wallets[2].addr, "Hello foo.test!", private_keys[0]) if 'error' in resp: print json.dumps(resp, indent=4, sort_keys=True) return False testlib.next_block(**kw) testlib.expect_snv_fail_at("fail.test", testlib.get_current_block(**kw)) # 3 in one block (zero-conf) resp = testlib.ysi_cli_name_import("bar.test", wallets[3].addr, "Hello bar.test!", private_keys[1]) if 'error' in resp: print json.dumps(resp, indent=4, sort_keys=True) return False resp = testlib.ysi_cli_name_import("baz.test", wallets[4].addr, "Hello baz.test!", private_keys[2]) if 'error' in resp: print json.dumps(resp, indent=4, sort_keys=True) return False resp = testlib.ysi_cli_name_import("goo.test", wallets[5].addr, "Hello goo.test!", private_keys[3]) if 'error' in resp: print json.dumps(resp, indent=4, sort_keys=True) return False testlib.next_block(**kw) # should fail (wrong key) resp = testlib.ysi_cli_name_import("fail.test", wallets[5].addr, "Hello fail.test!", wallets[2].privkey) if 'error' not in resp: print json.dumps(resp, indent=4, sort_keys=True) return False resp = testlib.ysi_cli_namespace_ready('test', wallets[1].privkey) if 'error' in resp: print json.dumps(resp, indent=4, sort_keys=True) return False testlib.next_block(**kw) testlib.expect_snv_fail_at("fail.test", testlib.get_current_block(**kw)) for i in xrange(0, 12): testlib.next_block(**kw) print "Waiting 10 seconds for registrar to replicate zone files" time.sleep(10)
def scenario( wallets, **kw ): res = testlib.ysi_cli_namespace_preorder('test', wallets[0].privkey, wallets[1].privkey) if 'error' in res: print res return False test_txid = res['transaction_hash'] res = testlib.ysi_cli_namespace_preorder('testm', wallets[5].privkey, wallets[2].privkey) if 'error' in res: print res return False testm_txid = res['transaction_hash'] # should fail (wrong key) res = testlib.ysi_cli_namespace_preorder('testf', wallets[3].privkey, wallets[6].privkey) if 'error' not in res: print res return False testlib.next_block(**kw) # should fail (wrong reveal key) res = testlib.ysi_cli_namespace_reveal('test', wallets[0].privkey, wallets[2].privkey, 52595, 250, 4, "6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0", 10, 10) if 'error' not in res: print res return False # should fail (wrong reveal key) res = testlib.ysi_cli_namespace_reveal('test', wallets[5].privkey, wallets[3].privkey, 52595, 250, 4, "6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0", 10, 10) if 'error' not in res: print res return False # should fail (wrong preorder key) res = testlib.ysi_cli_namespace_reveal('test', wallets[2].privkey, wallets[1].privkey, 52595, 250, 4, "6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0", 10, 10) if 'error' not in res: print res return False # should fail (wrong preorder key) res = testlib.ysi_cli_namespace_reveal('test', wallets[6].privkey, wallets[2].privkey, 52595, 250, 4, "6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0", 10, 10) if 'error' not in res: print res return False # should fail (wrong namespace) res = testlib.ysi_cli_namespace_reveal('test2', wallets[0].privkey, wallets[1].privkey, 52595, 250, 4, "6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0", 10, 10) if 'error' not in res: print res return False # should fail (wrong namespace) res = testlib.ysi_cli_namespace_reveal('test2', wallets[5].privkey, wallets[2].privkey, 52595, 250, 4, "6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0", 10, 10) if 'error' not in res: print res return False # should fail (wrong preorder txid) res = testlib.ysi_cli_namespace_reveal('test', wallets[0].privkey, wallets[1].privkey, 52595, 250, 4, "6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0", 10, 10, preorder_txid=testm_txid) if 'error' not in res: print res return False # should fail (wrong preorder txid) res = testlib.ysi_cli_namespace_reveal('test', wallets[5].privkey, wallets[2].privkey, 52595, 250, 4, "6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0", 10, 10, preorder_txid=test_txid) if 'error' not in res: print res return False # should all fail (wrong key order) for w in invalid_multisig_wallets: res = testlib.ysi_cli_namespace_reveal('testm', w.privkey, wallets[2].privkey, 52595, 250, 4, "6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0", 10, 10) if 'error' not in res: print res return False # should succeed res = testlib.ysi_cli_namespace_reveal('test', wallets[0].privkey, wallets[1].privkey, 52595, 250, 4, "6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0", 10, 10, preorder_txid=test_txid) if 'error' in res: print res return False # should succeed res = testlib.ysi_cli_namespace_reveal('testm', wallets[5].privkey, wallets[2].privkey, 52595, 250, 4, "6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0", 10, 10, preorder_txid=testm_txid) if 'error' in res: print res return False testlib.next_block(**kw) # should fail (wrong key) res = testlib.ysi_cli_namespace_ready('test', wallets[2].privkey) if 'error' not in res: print res return False # should fail (wrong key) res = testlib.ysi_cli_namespace_ready('testm', wallets[1].privkey) if 'error' not in res: print res return False # should succeed res = testlib.ysi_cli_namespace_ready('test', wallets[1].privkey) if 'error' in res: print res return False # should succeed res = testlib.ysi_cli_namespace_ready('testm', wallets[2].privkey) if 'error' in res: print res return False testlib.next_block( **kw )
def scenario(wallets, **kw): global preorder_block, reveal_block resp = testlib.ysi_cli_namespace_preorder("test", wallets[0].privkey, wallets[1].privkey) if 'error' in resp: print json.dumps(resp, indent=4, sort_keys=True) return False preorder_block = testlib.get_current_block(**kw) + 1 testlib.next_block(**kw) resp = testlib.ysi_cli_namespace_reveal('test', "abcd", wallets[1].privkey, 52595, 250, 4, '6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0', 10, 10) if 'error' not in resp: print json.dumps(resp, indent=4, sort_keys=True) return False resp = testlib.ysi_cli_namespace_reveal('test', wallets[0].privkey, "abcd", 52595, 250, 4, '6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0', 10, 10) if 'error' not in resp: print json.dumps(resp, indent=4, sort_keys=True) return False # NOTE: there's nothing bad we can put for lifetime, since < 0 or > 2**32-1 will be "infinite" resp = testlib.ysi_cli_namespace_reveal('test', wallets[0].privkey, wallets[1].privkey, 52595, 256, 4, '6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0', 10, 10) if 'error' not in resp: print json.dumps(resp, indent=4, sort_keys=True) return False resp = testlib.ysi_cli_namespace_reveal('test', wallets[0].privkey, wallets[1].privkey, 52595, -1, 4, '6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0', 10, 10) if 'error' not in resp: print json.dumps(resp, indent=4, sort_keys=True) return False resp = testlib.ysi_cli_namespace_reveal('test', wallets[0].privkey, wallets[1].privkey, 52595, 250, -1, '6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0', 10, 10) if 'error' not in resp: print json.dumps(resp, indent=4, sort_keys=True) return False resp = testlib.ysi_cli_namespace_reveal( 'test', wallets[0].privkey, wallets[1].privkey, 52595, 250, 4, '16,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0', 10, 10) if 'error' not in resp: print json.dumps(resp, indent=4, sort_keys=True) return False resp = testlib.ysi_cli_namespace_reveal( 'test', wallets[0].privkey, wallets[1].privkey, 52595, 250, 4, '-1,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0', 10, 10) if 'error' not in resp: print json.dumps(resp, indent=4, sort_keys=True) return False resp = testlib.ysi_cli_namespace_reveal('test', wallets[0].privkey, wallets[1].privkey, 52595, 250, 4, '6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0', 0, 10) if 'error' not in resp: print json.dumps(resp, indent=4, sort_keys=True) return False resp = testlib.ysi_cli_namespace_reveal('test', wallets[0].privkey, wallets[1].privkey, 52595, 250, 4, '6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0', 16, 10) if 'error' not in resp: print json.dumps(resp, indent=4, sort_keys=True) return False resp = testlib.ysi_cli_namespace_reveal('test', wallets[0].privkey, wallets[1].privkey, 52595, 250, 4, '6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0', 10, 0) if 'error' not in resp: print json.dumps(resp, indent=4, sort_keys=True) return False resp = testlib.ysi_cli_namespace_reveal('test', wallets[0].privkey, wallets[1].privkey, 52595, 250, 4, '6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0', 10, 16) if 'error' not in resp: print json.dumps(resp, indent=4, sort_keys=True) return False # should work resp = testlib.ysi_cli_namespace_reveal('test', wallets[0].privkey, wallets[1].privkey, 52595, 250, 4, '6,5,4,3,2,1,0,0,0,0,0,0,0,0,0,0', 10, 10) if 'error' in resp: print json.dumps(resp, indent=4, sort_keys=True) return False reveal_block = testlib.get_current_block(**kw) + 1 testlib.next_block(**kw)