fix tests
This commit is contained in:
parent
48d0edcbdf
commit
1e1a02be36
@ -46,39 +46,39 @@ class AddressIndexTest(BitcoinTestFramework):
|
||||
assert_equal(self.nodes[2].getbalance(), 0)
|
||||
|
||||
# Check that balances are correct
|
||||
balance0 = self.nodes[1].getaddressbalance("2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br")
|
||||
balance0 = self.nodes[1].getaddressbalance("93bVhahvUKmQu8gu9g3QnPPa2cxFK98pMB")
|
||||
assert_equal(balance0["balance"], 0)
|
||||
|
||||
# Check p2pkh and p2sh address indexes
|
||||
print "Testing p2pkh and p2sh address index..."
|
||||
|
||||
txid0 = self.nodes[0].sendtoaddress("mo9ncXisMeAoXwqcV5EWuyncbmCcQN4rVs", 10)
|
||||
txid0 = self.nodes[0].sendtoaddress("yMNJePdcKvXtWWQnFYHNeJ5u8TF2v1dfK4", 10)
|
||||
self.nodes[0].generate(1)
|
||||
|
||||
txidb0 = self.nodes[0].sendtoaddress("2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br", 10)
|
||||
txidb0 = self.nodes[0].sendtoaddress("93bVhahvUKmQu8gu9g3QnPPa2cxFK98pMB", 10)
|
||||
self.nodes[0].generate(1)
|
||||
|
||||
txid1 = self.nodes[0].sendtoaddress("mo9ncXisMeAoXwqcV5EWuyncbmCcQN4rVs", 15)
|
||||
txid1 = self.nodes[0].sendtoaddress("yMNJePdcKvXtWWQnFYHNeJ5u8TF2v1dfK4", 15)
|
||||
self.nodes[0].generate(1)
|
||||
|
||||
txidb1 = self.nodes[0].sendtoaddress("2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br", 15)
|
||||
txidb1 = self.nodes[0].sendtoaddress("93bVhahvUKmQu8gu9g3QnPPa2cxFK98pMB", 15)
|
||||
self.nodes[0].generate(1)
|
||||
|
||||
txid2 = self.nodes[0].sendtoaddress("mo9ncXisMeAoXwqcV5EWuyncbmCcQN4rVs", 20)
|
||||
txid2 = self.nodes[0].sendtoaddress("yMNJePdcKvXtWWQnFYHNeJ5u8TF2v1dfK4", 20)
|
||||
self.nodes[0].generate(1)
|
||||
|
||||
txidb2 = self.nodes[0].sendtoaddress("2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br", 20)
|
||||
txidb2 = self.nodes[0].sendtoaddress("93bVhahvUKmQu8gu9g3QnPPa2cxFK98pMB", 20)
|
||||
self.nodes[0].generate(1)
|
||||
|
||||
self.sync_all()
|
||||
|
||||
txids = self.nodes[1].getaddresstxids("mo9ncXisMeAoXwqcV5EWuyncbmCcQN4rVs")
|
||||
txids = self.nodes[1].getaddresstxids("yMNJePdcKvXtWWQnFYHNeJ5u8TF2v1dfK4")
|
||||
assert_equal(len(txids), 3)
|
||||
assert_equal(txids[0], txid0)
|
||||
assert_equal(txids[1], txid1)
|
||||
assert_equal(txids[2], txid2)
|
||||
|
||||
txidsb = self.nodes[1].getaddresstxids("2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br")
|
||||
txidsb = self.nodes[1].getaddresstxids("93bVhahvUKmQu8gu9g3QnPPa2cxFK98pMB")
|
||||
assert_equal(len(txidsb), 3)
|
||||
assert_equal(txidsb[0], txidb0)
|
||||
assert_equal(txidsb[1], txidb1)
|
||||
@ -87,7 +87,7 @@ class AddressIndexTest(BitcoinTestFramework):
|
||||
# Check that limiting by height works
|
||||
print "Testing querying txids by range of block heights.."
|
||||
height_txids = self.nodes[1].getaddresstxids({
|
||||
"addresses": ["2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br"],
|
||||
"addresses": ["93bVhahvUKmQu8gu9g3QnPPa2cxFK98pMB"],
|
||||
"start": 105,
|
||||
"end": 110
|
||||
})
|
||||
@ -96,7 +96,7 @@ class AddressIndexTest(BitcoinTestFramework):
|
||||
assert_equal(height_txids[1], txidb1)
|
||||
|
||||
# Check that multiple addresses works
|
||||
multitxids = self.nodes[1].getaddresstxids({"addresses": ["2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br", "mo9ncXisMeAoXwqcV5EWuyncbmCcQN4rVs"]})
|
||||
multitxids = self.nodes[1].getaddresstxids({"addresses": ["93bVhahvUKmQu8gu9g3QnPPa2cxFK98pMB", "yMNJePdcKvXtWWQnFYHNeJ5u8TF2v1dfK4"]})
|
||||
assert_equal(len(multitxids), 6)
|
||||
assert_equal(multitxids[0], txid0)
|
||||
assert_equal(multitxids[1], txidb0)
|
||||
@ -106,12 +106,12 @@ class AddressIndexTest(BitcoinTestFramework):
|
||||
assert_equal(multitxids[5], txidb2)
|
||||
|
||||
# Check that balances are correct
|
||||
balance0 = self.nodes[1].getaddressbalance("2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br")
|
||||
balance0 = self.nodes[1].getaddressbalance("93bVhahvUKmQu8gu9g3QnPPa2cxFK98pMB")
|
||||
assert_equal(balance0["balance"], 45 * 100000000)
|
||||
|
||||
# Check that outputs with the same address will only return one txid
|
||||
print "Testing for txid uniqueness..."
|
||||
addressHash = "6349a418fc4578d10a372b54b45c280cc8c4382f".decode("hex")
|
||||
addressHash = "FE30B718DCF0BF8A2A686BF1820C073F8B2C3B37".decode("hex")
|
||||
scriptPubKey = CScript([OP_HASH160, addressHash, OP_EQUAL])
|
||||
unspent = self.nodes[0].listunspent()
|
||||
tx = CTransaction()
|
||||
@ -125,20 +125,20 @@ class AddressIndexTest(BitcoinTestFramework):
|
||||
self.nodes[0].generate(1)
|
||||
self.sync_all()
|
||||
|
||||
txidsmany = self.nodes[1].getaddresstxids("2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br")
|
||||
txidsmany = self.nodes[1].getaddresstxids("93bVhahvUKmQu8gu9g3QnPPa2cxFK98pMB")
|
||||
assert_equal(len(txidsmany), 4)
|
||||
assert_equal(txidsmany[3], sent_txid)
|
||||
|
||||
# Check that balances are correct
|
||||
print "Testing balances..."
|
||||
balance0 = self.nodes[1].getaddressbalance("2N2JD6wb56AfK4tfmM6PwdVmoYk2dCKf4Br")
|
||||
balance0 = self.nodes[1].getaddressbalance("93bVhahvUKmQu8gu9g3QnPPa2cxFK98pMB")
|
||||
assert_equal(balance0["balance"], 45 * 100000000 + 21)
|
||||
|
||||
# Check that balances are correct after spending
|
||||
print "Testing balances after spending..."
|
||||
privkey2 = "cSdkPxkAjA4HDr5VHgsebAPDEh9Gyub4HK8UJr2DFGGqKKy4K5sG"
|
||||
address2 = "mgY65WSfEmsyYaYPQaXhmXMeBhwp4EcsQW"
|
||||
addressHash2 = "0b2f0a0c31bfe0406b0ccc1381fdbe311946dadc".decode("hex")
|
||||
privkey2 = "cU4zhap7nPJAWeMFu4j6jLrfPmqakDAzy8zn8Fhb3oEevdm4e5Lc"
|
||||
address2 = "yeMpGzMj3rhtnz48XsfpB8itPHhHtgxLc3"
|
||||
addressHash2 = "C5E4FB9171C22409809A3E8047A29C83886E325D".decode("hex")
|
||||
scriptPubKey2 = CScript([OP_DUP, OP_HASH160, addressHash2, OP_EQUALVERIFY, OP_CHECKSIG])
|
||||
self.nodes[0].importprivkey(privkey2)
|
||||
|
||||
@ -208,7 +208,7 @@ class AddressIndexTest(BitcoinTestFramework):
|
||||
|
||||
utxos2 = self.nodes[1].getaddressutxos({"addresses": [address2]})
|
||||
assert_equal(len(utxos2), 1)
|
||||
assert_equal(utxos2[0]["satoshis"], 5000000000)
|
||||
assert_equal(utxos2[0]["satoshis"], 50000000000)
|
||||
|
||||
# Check sorting of utxos
|
||||
self.nodes[2].generate(150)
|
||||
@ -228,11 +228,11 @@ class AddressIndexTest(BitcoinTestFramework):
|
||||
# Check mempool indexing
|
||||
print "Testing mempool indexing..."
|
||||
|
||||
privKey3 = "cVfUn53hAbRrDEuMexyfgDpZPhF7KqXpS8UZevsyTDaugB7HZ3CD"
|
||||
address3 = "mw4ynwhS7MmrQ27hr82kgqu7zryNDK26JB"
|
||||
addressHash3 = "aa9872b5bbcdb511d89e0e11aa27da73fd2c3f50".decode("hex")
|
||||
privKey3 = "cRyrMvvqi1dmpiCmjmmATqjAwo6Wu7QTjKu1ABMYW5aFG4VXW99K"
|
||||
address3 = "yWB15aAdpeKuSaQHFVJpBDPbNSLZJSnDLA"
|
||||
addressHash3 = "6C186B3A308A77C779A9BB71C3B5A7EC28232A13".decode("hex")
|
||||
scriptPubKey3 = CScript([OP_DUP, OP_HASH160, addressHash3, OP_EQUALVERIFY, OP_CHECKSIG])
|
||||
address4 = "2N8oFVB2vThAKury4vnLquW2zVjsYjjAkYQ"
|
||||
# address4 = "2N8oFVB2vThAKury4vnLquW2zVjsYjjAkYQ"
|
||||
scriptPubKey4 = CScript([OP_HASH160, addressHash3, OP_EQUAL])
|
||||
unspent = self.nodes[2].listunspent()
|
||||
|
||||
@ -294,9 +294,9 @@ class AddressIndexTest(BitcoinTestFramework):
|
||||
assert_equal(mempool3[1]["prevout"], 1)
|
||||
|
||||
# sending and receiving to the same address
|
||||
privkey1 = "cQY2s58LhzUCmEXN8jtAp1Etnijx78YRZ466w4ikX1V4UpTpbsf8"
|
||||
address1 = "myAUWSHnwsQrhuMWv4Br6QsCnpB41vFwHn"
|
||||
address1hash = "c192bff751af8efec15135d42bfeedf91a6f3e34".decode("hex")
|
||||
privkey1 = "cMvZn1pVWntTEcsK36ZteGQXRAcZ8CoTbMXF1QasxBLdnTwyVQCc"
|
||||
address1 = "yM9Eed1bxjy7tYxD3yZDHxjcVT48WdRoB1"
|
||||
address1hash = "0909C84A817651502E020AAD0FBCAE5F656E7D8A".decode("hex")
|
||||
address1script = CScript([OP_DUP, OP_HASH160, address1hash, OP_EQUALVERIFY, OP_CHECKSIG])
|
||||
|
||||
self.nodes[0].sendtoaddress(address1, 10)
|
||||
@ -310,7 +310,7 @@ class AddressIndexTest(BitcoinTestFramework):
|
||||
tx.vin = [
|
||||
CTxIn(COutPoint(int(utxos[0]["txid"], 16), utxos[0]["outputIndex"]))
|
||||
]
|
||||
amount = utxos[0]["satoshis"] - 1000
|
||||
amount = utxos[0]["satoshis"] - 10000
|
||||
tx.vout = [CTxOut(amount, address1script)]
|
||||
tx.rehash()
|
||||
self.nodes[0].importprivkey(privkey1)
|
||||
|
@ -46,9 +46,9 @@ class SpentIndexTest(BitcoinTestFramework):
|
||||
# Check that
|
||||
print "Testing spent index..."
|
||||
|
||||
privkey = "cSdkPxkAjA4HDr5VHgsebAPDEh9Gyub4HK8UJr2DFGGqKKy4K5sG"
|
||||
address = "mgY65WSfEmsyYaYPQaXhmXMeBhwp4EcsQW"
|
||||
addressHash = "0b2f0a0c31bfe0406b0ccc1381fdbe311946dadc".decode("hex")
|
||||
privkey = "cU4zhap7nPJAWeMFu4j6jLrfPmqakDAzy8zn8Fhb3oEevdm4e5Lc"
|
||||
address = "yeMpGzMj3rhtnz48XsfpB8itPHhHtgxLc3"
|
||||
addressHash = "C5E4FB9171C22409809A3E8047A29C83886E325D".decode("hex")
|
||||
scriptPubKey = CScript([OP_DUP, OP_HASH160, addressHash, OP_EQUALVERIFY, OP_CHECKSIG])
|
||||
unspent = self.nodes[0].listunspent()
|
||||
tx = CTransaction()
|
||||
@ -84,9 +84,9 @@ class SpentIndexTest(BitcoinTestFramework):
|
||||
assert_equal(txVerbose2["vin"][0]["valueSat"], amount)
|
||||
|
||||
# Check that verbose raw transaction includes address values and input values
|
||||
privkey2 = "cSdkPxkAjA4HDr5VHgsebAPDEh9Gyub4HK8UJr2DFGGqKKy4K5sG"
|
||||
address2 = "mgY65WSfEmsyYaYPQaXhmXMeBhwp4EcsQW"
|
||||
addressHash2 = "0b2f0a0c31bfe0406b0ccc1381fdbe311946dadc".decode("hex")
|
||||
privkey2 = "cU4zhap7nPJAWeMFu4j6jLrfPmqakDAzy8zn8Fhb3oEevdm4e5Lc"
|
||||
address2 = "yeMpGzMj3rhtnz48XsfpB8itPHhHtgxLc3"
|
||||
addressHash2 = "C5E4FB9171C22409809A3E8047A29C83886E325D".decode("hex")
|
||||
scriptPubKey2 = CScript([OP_DUP, OP_HASH160, addressHash2, OP_EQUALVERIFY, OP_CHECKSIG])
|
||||
tx2 = CTransaction()
|
||||
tx2.vin = [CTxIn(COutPoint(int(txid, 16), 0))]
|
||||
|
@ -45,9 +45,9 @@ class TxIndexTest(BitcoinTestFramework):
|
||||
|
||||
print "Testing transaction index..."
|
||||
|
||||
privkey = "cSdkPxkAjA4HDr5VHgsebAPDEh9Gyub4HK8UJr2DFGGqKKy4K5sG"
|
||||
address = "mgY65WSfEmsyYaYPQaXhmXMeBhwp4EcsQW"
|
||||
addressHash = "0b2f0a0c31bfe0406b0ccc1381fdbe311946dadc".decode("hex")
|
||||
privkey = "cU4zhap7nPJAWeMFu4j6jLrfPmqakDAzy8zn8Fhb3oEevdm4e5Lc"
|
||||
address = "yeMpGzMj3rhtnz48XsfpB8itPHhHtgxLc3"
|
||||
addressHash = "C5E4FB9171C22409809A3E8047A29C83886E325D".decode("hex")
|
||||
scriptPubKey = CScript([OP_DUP, OP_HASH160, addressHash, OP_EQUALVERIFY, OP_CHECKSIG])
|
||||
unspent = self.nodes[0].listunspent()
|
||||
tx = CTransaction()
|
||||
|
@ -3,7 +3,7 @@
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "script/script.h"
|
||||
#include "test/test_bitcoin.h"
|
||||
#include "test/test_dash.h"
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user