20 print(
"Initializing test directory "+self.options.tmpdir)
27 self.
nodes.append(
start_node(1, self.options.tmpdir, [
"-debug",
"-spentindex"]))
29 self.
nodes.append(
start_node(2, self.options.tmpdir, [
"-debug",
"-spentindex"]))
30 self.
nodes.append(
start_node(3, self.options.tmpdir, [
"-debug",
"-spentindex",
"-txindex"]))
39 print "Mining blocks..." 47 print "Testing spent index..." 49 privkey =
"cU4zhap7nPJAWeMFu4j6jLrfPmqakDAzy8zn8Fhb3oEevdm4e5Lc" 50 address =
"yeMpGzMj3rhtnz48XsfpB8itPHhHtgxLc3" 51 addressHash =
"C5E4FB9171C22409809A3E8047A29C83886E325D".decode(
"hex")
52 scriptPubKey =
CScript([OP_DUP, OP_HASH160, addressHash, OP_EQUALVERIFY, OP_CHECKSIG])
55 amount = unspent[0][
"amount"] * 100000000
56 tx.vin = [
CTxIn(
COutPoint(int(unspent[0][
"txid"], 16), unspent[0][
"vout"]))]
57 tx.vout = [
CTxOut(amount, scriptPubKey)]
65 print "Testing getspentinfo method..." 68 info = self.
nodes[1].
getspentinfo({
"txid": unspent[0][
"txid"],
"index": unspent[0][
"vout"]})
73 print "Testing getrawtransaction method..." 77 assert_equal(txVerbose[
"vout"][unspent[0][
"vout"]][
"spentTxId"], txid)
78 assert_equal(txVerbose[
"vout"][unspent[0][
"vout"]][
"spentIndex"], 0)
79 assert_equal(txVerbose[
"vout"][unspent[0][
"vout"]][
"spentHeight"], 106)
83 assert_equal(txVerbose2[
"vin"][0][
"value"], Decimal(unspent[0][
"amount"]))
87 privkey2 =
"cU4zhap7nPJAWeMFu4j6jLrfPmqakDAzy8zn8Fhb3oEevdm4e5Lc" 88 address2 =
"yeMpGzMj3rhtnz48XsfpB8itPHhHtgxLc3" 89 addressHash2 =
"C5E4FB9171C22409809A3E8047A29C83886E325D".decode(
"hex")
90 scriptPubKey2 =
CScript([OP_DUP, OP_HASH160, addressHash2, OP_EQUALVERIFY, OP_CHECKSIG])
93 tx2.vout = [
CTxOut(amount, scriptPubKey2)]
103 assert_equal(txVerbose3[
"vin"][0][
"value"], Decimal(unspent[0][
"amount"]))
112 assert_equal(txVerbose4[
"vin"][0][
"value"], Decimal(unspent[0][
"amount"]))
118 if __name__ ==
'__main__':
UniValue importprivkey(const UniValue ¶ms, bool fHelp)
UniValue getspentinfo(const UniValue ¶ms, bool fHelp)
UniValue getrawtransaction(const UniValue ¶ms, bool fHelp)
UniValue listunspent(const UniValue ¶ms, bool fHelp)
def connect_nodes(from_connection, node_num)
UniValue getblockcount(const UniValue ¶ms, bool fHelp)
def initialize_chain_clean(test_dir, num_nodes)
UniValue signrawtransaction(const UniValue ¶ms, bool fHelp)
def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=None)
UniValue generate(const UniValue ¶ms, bool fHelp)
UniValue sendrawtransaction(const UniValue ¶ms, bool fHelp)
def assert_equal(thing1, thing2)