Adjust fuctional tests
Signed-off-by: Anthony Fieroni <bvbfan@abv.bg>
This commit is contained in:
parent
675dfa2367
commit
4a6b3b7bf2
23 changed files with 59 additions and 64 deletions
|
@ -27,7 +27,8 @@ public:
|
||||||
if (c.IsNull())
|
if (c.IsNull())
|
||||||
c = ClaimIdHash(uint256(p.hash), p.n);
|
c = ClaimIdHash(uint256(p.hash), p.n);
|
||||||
|
|
||||||
return addClaim(key, p, c, value.nAmount, value.nHeight);
|
int height = value.nHeight > 0 ? value.nHeight : nNextHeight;
|
||||||
|
return addClaim(key, p, c, value.nAmount, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool removeClaimFromTrie(const std::string& key, const COutPoint& outPoint) {
|
bool removeClaimFromTrie(const std::string& key, const COutPoint& outPoint) {
|
||||||
|
@ -234,8 +235,8 @@ BOOST_AUTO_TEST_CASE(basic_insertion_info_test)
|
||||||
uint160 claimId = ClaimIdHash(tx1.GetHash(), 0);
|
uint160 claimId = ClaimIdHash(tx1.GetHash(), 0);
|
||||||
COutPoint claimOutPoint(tx1.GetHash(), 0);
|
COutPoint claimOutPoint(tx1.GetHash(), 0);
|
||||||
CAmount amount(10);
|
CAmount amount(10);
|
||||||
int height = 0;
|
int height = 1;
|
||||||
int validHeight = 0;
|
int validHeight = 1;
|
||||||
CClaimValue claimVal(claimOutPoint, claimId, amount, height, validHeight);
|
CClaimValue claimVal(claimOutPoint, claimId, amount, height, validHeight);
|
||||||
ctc.insertClaimIntoTrie("test", claimVal);
|
ctc.insertClaimIntoTrie("test", claimVal);
|
||||||
|
|
||||||
|
@ -319,7 +320,8 @@ BOOST_AUTO_TEST_CASE(trie_stays_consistent_test)
|
||||||
"goodness", "goodnight", "goodnatured", "goods", "go", "goody", "goo"
|
"goodness", "goodnight", "goodnatured", "goods", "go", "goody", "goo"
|
||||||
};
|
};
|
||||||
|
|
||||||
CClaimTrieCacheTest cache(&::Claimtrie());
|
auto& trie = ::Claimtrie();
|
||||||
|
CClaimTrieCacheTest cache(&trie);
|
||||||
CClaimValue value;
|
CClaimValue value;
|
||||||
|
|
||||||
for (auto& name: names) {
|
for (auto& name: names) {
|
||||||
|
@ -338,7 +340,7 @@ BOOST_AUTO_TEST_CASE(trie_stays_consistent_test)
|
||||||
cache.flush();
|
cache.flush();
|
||||||
BOOST_CHECK(cache.checkConsistency());
|
BOOST_CHECK(cache.checkConsistency());
|
||||||
}
|
}
|
||||||
BOOST_CHECK(::Claimtrie().empty());
|
BOOST_CHECK(trie.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(verify_basic_serialization)
|
BOOST_AUTO_TEST_CASE(verify_basic_serialization)
|
||||||
|
|
|
@ -21,7 +21,7 @@ import tempfile
|
||||||
# without the parent module installed.
|
# without the parent module installed.
|
||||||
|
|
||||||
# Should match same symbol in `test_framework.test_framework`.
|
# Should match same symbol in `test_framework.test_framework`.
|
||||||
TMPDIR_PREFIX = "bitcoin_func_test_"
|
TMPDIR_PREFIX = "lbrycrd_func_test_"
|
||||||
|
|
||||||
# Matches on the date format at the start of the log event
|
# Matches on the date format at the start of the log event
|
||||||
TIMESTAMP_PATTERN = re.compile(r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{6})?Z")
|
TIMESTAMP_PATTERN = re.compile(r"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{6})?Z")
|
||||||
|
|
|
@ -131,7 +131,7 @@ class AssumeValidTest(BitcoinTestFramework):
|
||||||
# Create a transaction spending the coinbase output with an invalid (null) signature
|
# Create a transaction spending the coinbase output with an invalid (null) signature
|
||||||
tx = CTransaction()
|
tx = CTransaction()
|
||||||
tx.vin.append(CTxIn(COutPoint(self.block1.vtx[0].sha256, 0), scriptSig=b""))
|
tx.vin.append(CTxIn(COutPoint(self.block1.vtx[0].sha256, 0), scriptSig=b""))
|
||||||
tx.vout.append(CTxOut(49 * 100000000, CScript([OP_TRUE])))
|
tx.vout.append(CTxOut(1 * 100000000, CScript([OP_TRUE])))
|
||||||
tx.calc_sha256()
|
tx.calc_sha256()
|
||||||
|
|
||||||
block102 = create_block(self.tip, create_coinbase(height), self.block_time)
|
block102 = create_block(self.tip, create_coinbase(height), self.block_time)
|
||||||
|
|
|
@ -22,6 +22,7 @@ from test_framework.messages import (
|
||||||
CTransaction,
|
CTransaction,
|
||||||
CTxIn,
|
CTxIn,
|
||||||
CTxOut,
|
CTxOut,
|
||||||
|
lbryPOW,
|
||||||
MAX_BLOCK_BASE_SIZE,
|
MAX_BLOCK_BASE_SIZE,
|
||||||
uint256_from_compact,
|
uint256_from_compact,
|
||||||
uint256_from_str,
|
uint256_from_str,
|
||||||
|
@ -635,7 +636,7 @@ class FullBlockTest(BitcoinTestFramework):
|
||||||
self.move_tip(44)
|
self.move_tip(44)
|
||||||
b47 = self.next_block(47, solve=False)
|
b47 = self.next_block(47, solve=False)
|
||||||
target = uint256_from_compact(b47.nBits)
|
target = uint256_from_compact(b47.nBits)
|
||||||
while b47.sha256 < target:
|
while lbryPOW(b47.sha256) < target:
|
||||||
b47.nNonce += 1
|
b47.nNonce += 1
|
||||||
b47.rehash()
|
b47.rehash()
|
||||||
self.send_blocks([b47], False, force_send=True, reject_reason='high-hash', reconnect=True)
|
self.send_blocks([b47], False, force_send=True, reject_reason='high-hash', reconnect=True)
|
||||||
|
|
|
@ -75,7 +75,7 @@ class BIP66Test(BitcoinTestFramework):
|
||||||
self.log.info("Test that a transaction with non-DER signature can still appear in a block")
|
self.log.info("Test that a transaction with non-DER signature can still appear in a block")
|
||||||
|
|
||||||
spendtx = create_transaction(self.nodes[0], self.coinbase_txids[0],
|
spendtx = create_transaction(self.nodes[0], self.coinbase_txids[0],
|
||||||
self.nodeaddress, amount=1.0)
|
self.nodeaddress, amount=0.1)
|
||||||
unDERify(spendtx)
|
unDERify(spendtx)
|
||||||
spendtx.rehash()
|
spendtx.rehash()
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ class NULLDUMMYTest(BitcoinTestFramework):
|
||||||
self.setup_clean_chain = True
|
self.setup_clean_chain = True
|
||||||
# This script tests NULLDUMMY activation, which is part of the 'segwit' deployment, so we go through
|
# This script tests NULLDUMMY activation, which is part of the 'segwit' deployment, so we go through
|
||||||
# normal segwit activation here (and don't use the default always-on behaviour).
|
# normal segwit activation here (and don't use the default always-on behaviour).
|
||||||
self.extra_args = [['-whitelist=127.0.0.1', '-segwitheight=432', '-addresstype=legacy']]
|
self.extra_args = [['-whitelist=127.0.0.1', '-segwitheight=150', '-addresstype=legacy']]
|
||||||
|
|
||||||
def skip_test_if_missing_module(self):
|
def skip_test_if_missing_module(self):
|
||||||
self.skip_if_no_wallet()
|
self.skip_if_no_wallet()
|
||||||
|
|
|
@ -61,8 +61,8 @@ class SegWitTest(BitcoinTestFramework):
|
||||||
[
|
[
|
||||||
"-acceptnonstdtxn=1",
|
"-acceptnonstdtxn=1",
|
||||||
"-blockversion=4",
|
"-blockversion=4",
|
||||||
"-rpcserialversion=1",
|
|
||||||
"-segwitheight=432",
|
"-segwitheight=432",
|
||||||
|
"-rpcserialversion=1",
|
||||||
"-addresstype=legacy",
|
"-addresstype=legacy",
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
@ -90,7 +90,7 @@ class SegWitTest(BitcoinTestFramework):
|
||||||
def skip_mine(self, node, txid, sign, redeem_script=""):
|
def skip_mine(self, node, txid, sign, redeem_script=""):
|
||||||
send_to_witness(1, node, getutxo(txid), self.pubkey[0], False, Decimal("0.99996"), sign, redeem_script)
|
send_to_witness(1, node, getutxo(txid), self.pubkey[0], False, Decimal("0.99996"), sign, redeem_script)
|
||||||
block = node.generate(1)
|
block = node.generate(1)
|
||||||
assert_equal(len(node.getblock(block[0])["tx"]), 2)
|
assert_equal(len(node.getblock(block[0])["tx"]), 1)
|
||||||
self.sync_blocks()
|
self.sync_blocks()
|
||||||
|
|
||||||
def fail_accept(self, node, error_msg, txid, sign, redeem_script=""):
|
def fail_accept(self, node, error_msg, txid, sign, redeem_script=""):
|
||||||
|
@ -100,19 +100,19 @@ class SegWitTest(BitcoinTestFramework):
|
||||||
self.nodes[0].generate(161) # block 161
|
self.nodes[0].generate(161) # block 161
|
||||||
|
|
||||||
self.log.info("Verify sigops are counted in GBT with pre-BIP141 rules before the fork")
|
self.log.info("Verify sigops are counted in GBT with pre-BIP141 rules before the fork")
|
||||||
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 0.02)
|
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)
|
||||||
tmpl = self.nodes[0].getblocktemplate({'rules': ['segwit']})
|
tmpl = self.nodes[0].getblocktemplate({'rules': ['segwit']})
|
||||||
assert tmpl['sizelimit'] == 8000000
|
assert tmpl['sizelimit'] == 2000000
|
||||||
assert 'weightlimit' not in tmpl
|
assert 'weightlimit' not in tmpl
|
||||||
assert tmpl['sigoplimit'] == 80000
|
assert tmpl['sigoplimit'] == 20000
|
||||||
assert tmpl['transactions'][0]['hash'] == txid
|
assert tmpl['transactions'][0]['hash'] == txid
|
||||||
assert tmpl['transactions'][0]['sigops'] == 8
|
assert tmpl['transactions'][0]['sigops'] == 2
|
||||||
tmpl = self.nodes[0].getblocktemplate({'rules': ['segwit']})
|
tmpl = self.nodes[0].getblocktemplate({'rules': ['segwit']})
|
||||||
assert tmpl['sizelimit'] == 8000000
|
assert tmpl['sizelimit'] == 2000000
|
||||||
assert 'weightlimit' not in tmpl
|
assert 'weightlimit' not in tmpl
|
||||||
assert tmpl['sigoplimit'] == 80000
|
assert tmpl['sigoplimit'] == 20000
|
||||||
assert tmpl['transactions'][0]['hash'] == txid
|
assert tmpl['transactions'][0]['hash'] == txid
|
||||||
assert tmpl['transactions'][0]['sigops'] == 8
|
assert tmpl['transactions'][0]['sigops'] == 2
|
||||||
self.nodes[0].generate(1) # block 162
|
self.nodes[0].generate(1) # block 162
|
||||||
|
|
||||||
balance_presetup = self.nodes[0].getbalance()
|
balance_presetup = self.nodes[0].getbalance()
|
||||||
|
@ -160,7 +160,7 @@ class SegWitTest(BitcoinTestFramework):
|
||||||
self.fail_accept(self.nodes[2], "mandatory-script-verify-flag", p2sh_ids[NODE_2][WIT_V0][1], False)
|
self.fail_accept(self.nodes[2], "mandatory-script-verify-flag", p2sh_ids[NODE_2][WIT_V0][1], False)
|
||||||
self.fail_accept(self.nodes[2], "mandatory-script-verify-flag", p2sh_ids[NODE_2][WIT_V1][1], False)
|
self.fail_accept(self.nodes[2], "mandatory-script-verify-flag", p2sh_ids[NODE_2][WIT_V1][1], False)
|
||||||
|
|
||||||
self.nodes[2].generate(4) # blocks 428-431
|
self.nodes[2].generate(5) # blocks 428-431
|
||||||
|
|
||||||
self.log.info("Verify previous witness txs skipped for mining can now be mined")
|
self.log.info("Verify previous witness txs skipped for mining can now be mined")
|
||||||
assert_equal(len(self.nodes[2].getrawmempool()), 0)
|
assert_equal(len(self.nodes[2].getrawmempool()), 0)
|
||||||
|
@ -211,7 +211,7 @@ class SegWitTest(BitcoinTestFramework):
|
||||||
assert tmpl['weightlimit'] == 8000000
|
assert tmpl['weightlimit'] == 8000000
|
||||||
assert tmpl['sigoplimit'] == 80000
|
assert tmpl['sigoplimit'] == 80000
|
||||||
assert tmpl['transactions'][0]['txid'] == txid
|
assert tmpl['transactions'][0]['txid'] == txid
|
||||||
assert tmpl['transactions'][0]['sigops'] == 4
|
assert tmpl['transactions'][0]['sigops'] == 8
|
||||||
|
|
||||||
self.nodes[0].generate(1) # Mine a block to clear the gbt cache
|
self.nodes[0].generate(1) # Mine a block to clear the gbt cache
|
||||||
|
|
||||||
|
|
|
@ -9,14 +9,13 @@ from test_framework.address import ADDRESS_BCRT1_UNSPENDABLE
|
||||||
from test_framework.test_framework import BitcoinTestFramework
|
from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.messages import CTransaction, hash256
|
from test_framework.messages import CTransaction, hash256
|
||||||
from test_framework.util import assert_equal, connect_nodes
|
from test_framework.util import assert_equal, connect_nodes
|
||||||
assert_equal,
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
def hash256_reversed(byte_str):
|
def hash256_reversed(byte_str):
|
||||||
return hash256(byte_str)[::-1]
|
return hash256(byte_str)[::-1]
|
||||||
|
|
||||||
|
|
||||||
class ZMQSubscriber:
|
class ZMQSubscriber:
|
||||||
def __init__(self, socket, topic):
|
def __init__(self, socket, topic):
|
||||||
self.sequence = 0
|
self.sequence = 0
|
||||||
|
@ -44,7 +43,9 @@ class ZMQTest (BitcoinTestFramework):
|
||||||
self.skip_if_no_py3_zmq()
|
self.skip_if_no_py3_zmq()
|
||||||
self.skip_if_no_lbrycrdd_zmq()
|
self.skip_if_no_lbrycrdd_zmq()
|
||||||
self.skip_if_no_wallet()
|
self.skip_if_no_wallet()
|
||||||
|
|
||||||
def setup_nodes(self):
|
def setup_nodes(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
import zmq
|
import zmq
|
||||||
|
|
5
test/functional/mempool_accept.py
Executable file → Normal file
5
test/functional/mempool_accept.py
Executable file → Normal file
|
@ -34,9 +34,6 @@ from test_framework.util import (
|
||||||
class MempoolAcceptanceTest(BitcoinTestFramework):
|
class MempoolAcceptanceTest(BitcoinTestFramework):
|
||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
self.num_nodes = 1
|
self.num_nodes = 1
|
||||||
self.extra_args = [[
|
|
||||||
'-txindex',
|
|
||||||
]] * self.num_nodes
|
|
||||||
|
|
||||||
def skip_test_if_missing_module(self):
|
def skip_test_if_missing_module(self):
|
||||||
self.skip_if_no_wallet()
|
self.skip_if_no_wallet()
|
||||||
|
@ -76,7 +73,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
||||||
)
|
)
|
||||||
|
|
||||||
self.log.info('A transaction not in the mempool')
|
self.log.info('A transaction not in the mempool')
|
||||||
fee = 0.00000700
|
fee = 0.00000014
|
||||||
raw_tx_0 = node.signrawtransactionwithwallet(node.createrawtransaction(
|
raw_tx_0 = node.signrawtransactionwithwallet(node.createrawtransaction(
|
||||||
inputs=[{"txid": txid_in_block, "vout": 0, "sequence": BIP125_SEQUENCE_NUMBER}], # RBF is used later
|
inputs=[{"txid": txid_in_block, "vout": 0, "sequence": BIP125_SEQUENCE_NUMBER}], # RBF is used later
|
||||||
outputs=[{node.getnewaddress(): 0.006 - fee}],
|
outputs=[{node.getnewaddress(): 0.006 - fee}],
|
||||||
|
|
|
@ -27,7 +27,7 @@ class P2PBlocksOnly(BitcoinTestFramework):
|
||||||
'vout': 0
|
'vout': 0
|
||||||
}],
|
}],
|
||||||
outputs=[{
|
outputs=[{
|
||||||
self.nodes[0].get_deterministic_priv_key().address: 50 - 0.00125
|
self.nodes[0].get_deterministic_priv_key().address: 1 - 0.000025
|
||||||
}],
|
}],
|
||||||
)
|
)
|
||||||
sigtx = self.nodes[0].signrawtransactionwithkey(
|
sigtx = self.nodes[0].signrawtransactionwithkey(
|
||||||
|
|
|
@ -93,7 +93,7 @@ class TestP2PConn(P2PInterface):
|
||||||
|
|
||||||
class CompactBlocksTest(BitcoinTestFramework):
|
class CompactBlocksTest(BitcoinTestFramework):
|
||||||
def set_test_params(self):
|
def set_test_params(self):
|
||||||
self.setup_clean_chain = True
|
self.setup_clean_chain = False
|
||||||
self.num_nodes = 1
|
self.num_nodes = 1
|
||||||
self.extra_args = [[
|
self.extra_args = [[
|
||||||
"-acceptnonstdtxn=1",
|
"-acceptnonstdtxn=1",
|
||||||
|
@ -261,7 +261,7 @@ class CompactBlocksTest(BitcoinTestFramework):
|
||||||
version = test_node.cmpct_version
|
version = test_node.cmpct_version
|
||||||
node = self.nodes[0]
|
node = self.nodes[0]
|
||||||
# Generate a bunch of transactions.
|
# Generate a bunch of transactions.
|
||||||
node.generate(101)
|
node.generate(200)
|
||||||
num_transactions = 25
|
num_transactions = 25
|
||||||
address = node.getnewaddress()
|
address = node.getnewaddress()
|
||||||
|
|
||||||
|
|
|
@ -67,8 +67,8 @@ class InvalidBlockRequestTest(BitcoinTestFramework):
|
||||||
block_time += 1
|
block_time += 1
|
||||||
|
|
||||||
# b'0x51' is OP_TRUE
|
# b'0x51' is OP_TRUE
|
||||||
tx1 = create_tx_with_script(block1.vtx[0], 0, script_sig=b'\x51', amount=50 * COIN)
|
tx1 = create_tx_with_script(block1.vtx[0], 0, script_sig=b'\x51', amount=1 * COIN)
|
||||||
tx2 = create_tx_with_script(tx1, 0, script_sig=b'\x51', amount=50 * COIN)
|
tx2 = create_tx_with_script(tx1, 0, script_sig=b'\x51', amount=1 * COIN)
|
||||||
|
|
||||||
block2.vtx.extend([tx1, tx2])
|
block2.vtx.extend([tx1, tx2])
|
||||||
block2.hashMerkleRoot = block2.calc_merkle_root()
|
block2.hashMerkleRoot = block2.calc_merkle_root()
|
||||||
|
@ -96,16 +96,6 @@ class InvalidBlockRequestTest(BitcoinTestFramework):
|
||||||
block2_dup.solve()
|
block2_dup.solve()
|
||||||
node.p2p.send_blocks_and_test([block2_dup], node, success=False, reject_reason='bad-txns-inputs-duplicate')
|
node.p2p.send_blocks_and_test([block2_dup], node, success=False, reject_reason='bad-txns-inputs-duplicate')
|
||||||
|
|
||||||
# Check transactions for duplicate inputs
|
|
||||||
self.log.info("Test duplicate input block.")
|
|
||||||
|
|
||||||
block2_orig.vtx[2].vin.append(block2_orig.vtx[2].vin[0])
|
|
||||||
block2_orig.vtx[2].rehash()
|
|
||||||
block2_orig.hashMerkleRoot = block2_orig.calc_merkle_root()
|
|
||||||
block2_orig.rehash()
|
|
||||||
block2_orig.solve()
|
|
||||||
node.p2p.send_blocks_and_test([block2_orig], node, success=False, reject_reason=b'bad-txns-inputs-duplicate')
|
|
||||||
|
|
||||||
self.log.info("Test very broken block.")
|
self.log.info("Test very broken block.")
|
||||||
|
|
||||||
block3 = create_block(tip, create_coinbase(height), block_time)
|
block3 = create_block(tip, create_coinbase(height), block_time)
|
||||||
|
|
2
test/functional/p2p_segwit.py
Executable file → Normal file
2
test/functional/p2p_segwit.py
Executable file → Normal file
|
@ -89,7 +89,7 @@ VB_TOP_BITS = 0x20000000
|
||||||
|
|
||||||
MAX_SIGOP_COST = 80000
|
MAX_SIGOP_COST = 80000
|
||||||
|
|
||||||
SEGWIT_HEIGHT = 120
|
SEGWIT_HEIGHT = 150
|
||||||
|
|
||||||
class UTXO():
|
class UTXO():
|
||||||
"""Used to keep track of anyone-can-spend outputs that we can use in the tests."""
|
"""Used to keep track of anyone-can-spend outputs that we can use in the tests."""
|
||||||
|
|
|
@ -16,19 +16,19 @@ class DeriveaddressesTest(BitcoinTestFramework):
|
||||||
assert_raises_rpc_error(-5, "Missing checksum", self.nodes[0].deriveaddresses, "a")
|
assert_raises_rpc_error(-5, "Missing checksum", self.nodes[0].deriveaddresses, "a")
|
||||||
|
|
||||||
descriptor = "wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/1/0)#t6wfjs64"
|
descriptor = "wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/1/0)#t6wfjs64"
|
||||||
address = "bcrt1qjqmxmkpmxt80xz4y3746zgt0q3u3ferr34acd5"
|
address = "rlbc1qjqmxmkpmxt80xz4y3746zgt0q3u3ferrtwx46m"
|
||||||
assert_equal(self.nodes[0].deriveaddresses(descriptor), [address])
|
assert_equal(self.nodes[0].deriveaddresses(descriptor), [address])
|
||||||
|
|
||||||
descriptor = descriptor[:-9]
|
descriptor = descriptor[:-9]
|
||||||
assert_raises_rpc_error(-5, "Missing checksum", self.nodes[0].deriveaddresses, descriptor)
|
assert_raises_rpc_error(-5, "Missing checksum", self.nodes[0].deriveaddresses, descriptor)
|
||||||
|
|
||||||
descriptor_pubkey = "wpkh(tpubD6NzVbkrYhZ4WaWSyoBvQwbpLkojyoTZPRsgXELWz3Popb3qkjcJyJUGLnL4qHHoQvao8ESaAstxYSnhyswJ76uZPStJRJCTKvosUCJZL5B/1/1/0)#s9ga3alw"
|
descriptor_pubkey = "wpkh(tpubD6NzVbkrYhZ4WaWSyoBvQwbpLkojyoTZPRsgXELWz3Popb3qkjcJyJUGLnL4qHHoQvao8ESaAstxYSnhyswJ76uZPStJRJCTKvosUCJZL5B/1/1/0)#s9ga3alw"
|
||||||
address = "bcrt1qjqmxmkpmxt80xz4y3746zgt0q3u3ferr34acd5"
|
address = "rlbc1qjqmxmkpmxt80xz4y3746zgt0q3u3ferrtwx46m"
|
||||||
assert_equal(self.nodes[0].deriveaddresses(descriptor_pubkey), [address])
|
assert_equal(self.nodes[0].deriveaddresses(descriptor_pubkey), [address])
|
||||||
|
|
||||||
ranged_descriptor = "wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/1/*)#kft60nuy"
|
ranged_descriptor = "wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/1/*)#kft60nuy"
|
||||||
assert_equal(self.nodes[0].deriveaddresses(ranged_descriptor, [1, 2]), ["bcrt1qhku5rq7jz8ulufe2y6fkcpnlvpsta7rq4442dy", "bcrt1qpgptk2gvshyl0s9lqshsmx932l9ccsv265tvaq"])
|
assert_equal(self.nodes[0].deriveaddresses(ranged_descriptor, [1, 2]), ["rlbc1qhku5rq7jz8ulufe2y6fkcpnlvpsta7rq0ww86t", "rlbc1qpgptk2gvshyl0s9lqshsmx932l9ccsv2q0sp20"])
|
||||||
assert_equal(self.nodes[0].deriveaddresses(ranged_descriptor, 2), [address, "bcrt1qhku5rq7jz8ulufe2y6fkcpnlvpsta7rq4442dy", "bcrt1qpgptk2gvshyl0s9lqshsmx932l9ccsv265tvaq"])
|
assert_equal(self.nodes[0].deriveaddresses(ranged_descriptor, 2), [address, "rlbc1qhku5rq7jz8ulufe2y6fkcpnlvpsta7rq0ww86t", "rlbc1qpgptk2gvshyl0s9lqshsmx932l9ccsv2q0sp20"])
|
||||||
|
|
||||||
assert_raises_rpc_error(-8, "Range should not be specified for an un-ranged descriptor", self.nodes[0].deriveaddresses, descsum_create("wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/1/0)"), [0, 2])
|
assert_raises_rpc_error(-8, "Range should not be specified for an un-ranged descriptor", self.nodes[0].deriveaddresses, descsum_create("wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/1/0)"), [0, 2])
|
||||||
|
|
||||||
|
|
|
@ -231,7 +231,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||||
dec_tx = self.nodes[2].decoderawtransaction(rawtx)
|
dec_tx = self.nodes[2].decoderawtransaction(rawtx)
|
||||||
assert_equal(utx['txid'], dec_tx['vin'][0]['txid'])
|
assert_equal(utx['txid'], dec_tx['vin'][0]['txid'])
|
||||||
|
|
||||||
assert_raises_rpc_error(-5, "changeAddress must be a valid bitcoin address", self.nodes[2].fundrawtransaction, rawtx, {'changeAddress':'foobar'})
|
assert_raises_rpc_error(-5, "changeAddress must be a valid LBRY address", self.nodes[2].fundrawtransaction, rawtx, {'changeAddress':'foobar'})
|
||||||
|
|
||||||
def test_valid_change_address(self):
|
def test_valid_change_address(self):
|
||||||
############################################################
|
############################################################
|
||||||
|
@ -696,7 +696,7 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||||
# Test no address reuse occurs #
|
# Test no address reuse occurs #
|
||||||
################################
|
################################
|
||||||
|
|
||||||
rawtx = self.nodes[3].createrawtransaction(inputs=[], outputs={self.nodes[3].getnewaddress(): 1})
|
rawtx = self.nodes[3].createrawtransaction(inputs=[], outputs={self.nodes[3].getnewaddress(): 0.1})
|
||||||
result3 = self.nodes[3].fundrawtransaction(rawtx)
|
result3 = self.nodes[3].fundrawtransaction(rawtx)
|
||||||
res_dec = self.nodes[0].decoderawtransaction(result3["hex"])
|
res_dec = self.nodes[0].decoderawtransaction(result3["hex"])
|
||||||
changeaddress = ""
|
changeaddress = ""
|
||||||
|
|
|
@ -60,6 +60,8 @@ class GetChainTipsTest (BitcoinTestFramework):
|
||||||
assert_equal (tips[1]['status'], 'valid-fork')
|
assert_equal (tips[1]['status'], 'valid-fork')
|
||||||
tips[1]['branchlen'] = 0
|
tips[1]['branchlen'] = 0
|
||||||
tips[1]['status'] = 'active'
|
tips[1]['status'] = 'active'
|
||||||
|
tips[1].pop('branchhash')
|
||||||
|
tips[1].pop('branchhashNext')
|
||||||
assert_equal (tips[1], shortTip)
|
assert_equal (tips[1], shortTip)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -11,7 +11,7 @@ from .util import hex_str_to_bytes
|
||||||
|
|
||||||
from . import segwit_addr
|
from . import segwit_addr
|
||||||
|
|
||||||
ADDRESS_BCRT1_UNSPENDABLE = 'bcrt1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3xueyj'
|
ADDRESS_BCRT1_UNSPENDABLE = 'rlbc1qjqmxmkpmxt80xz4y3746zgt0q3u3ferrtwx46m'
|
||||||
|
|
||||||
|
|
||||||
class AddressType(enum.Enum):
|
class AddressType(enum.Enum):
|
||||||
|
|
|
@ -60,6 +60,9 @@ def sha256(s):
|
||||||
def hash256(s):
|
def hash256(s):
|
||||||
return sha256(sha256(s))
|
return sha256(sha256(s))
|
||||||
|
|
||||||
|
def ripemd160(s):
|
||||||
|
return hashlib.new('ripemd160', s).digest()
|
||||||
|
|
||||||
def hash160(s):
|
def hash160(s):
|
||||||
return hashlib.new('ripemd160', sha256(s)).digest()
|
return hashlib.new('ripemd160', sha256(s)).digest()
|
||||||
|
|
||||||
|
@ -531,7 +534,7 @@ class CTransaction:
|
||||||
|
|
||||||
class CBlockHeader:
|
class CBlockHeader:
|
||||||
__slots__ = ("hash", "hashMerkleRoot", "hashPrevBlock", "nBits", "nNonce",
|
__slots__ = ("hash", "hashMerkleRoot", "hashPrevBlock", "nBits", "nNonce",
|
||||||
"nTime", "nVersion", "sha256")
|
"nTime", "nVersion", "sha256", "hashClaimTrie")
|
||||||
|
|
||||||
def __init__(self, header=None):
|
def __init__(self, header=None):
|
||||||
if header is None:
|
if header is None:
|
||||||
|
|
|
@ -43,7 +43,7 @@ TEST_EXIT_PASSED = 0
|
||||||
TEST_EXIT_FAILED = 1
|
TEST_EXIT_FAILED = 1
|
||||||
TEST_EXIT_SKIPPED = 77
|
TEST_EXIT_SKIPPED = 77
|
||||||
|
|
||||||
TMPDIR_PREFIX = "bitcoin_func_test_"
|
TMPDIR_PREFIX = "lbrycrd_func_test_"
|
||||||
|
|
||||||
|
|
||||||
class SkipTest(Exception):
|
class SkipTest(Exception):
|
||||||
|
@ -364,7 +364,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
rpchost=rpchost,
|
rpchost=rpchost,
|
||||||
timewait=self.rpc_timeout,
|
timewait=self.rpc_timeout,
|
||||||
lbrycrdd=binary[i],
|
lbrycrdd=binary[i],
|
||||||
lbrycrd_cli=self.options.bitcoincli,
|
lbrycrd_cli=self.options.lbrycrdcli,
|
||||||
coverage_dir=self.options.coveragedir,
|
coverage_dir=self.options.coveragedir,
|
||||||
cwd=self.options.tmpdir,
|
cwd=self.options.tmpdir,
|
||||||
extra_conf=extra_confs[i],
|
extra_conf=extra_confs[i],
|
||||||
|
@ -506,8 +506,8 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
extra_args=['-disablewallet'],
|
extra_args=['-disablewallet'],
|
||||||
rpchost=None,
|
rpchost=None,
|
||||||
timewait=self.rpc_timeout,
|
timewait=self.rpc_timeout,
|
||||||
lbrycrdd=self.options.bitcoind,
|
lbrycrdd=self.options.lbrycrdd,
|
||||||
lbrycrd_cli=self.options.bitcoincli,
|
lbrycrd_cli=self.options.lbrycrdcli,
|
||||||
coverage_dir=None,
|
coverage_dir=None,
|
||||||
cwd=self.options.tmpdir,
|
cwd=self.options.tmpdir,
|
||||||
))
|
))
|
||||||
|
@ -527,7 +527,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
nblocks=25 if i != 7 else 24,
|
nblocks=25 if i != 7 else 24,
|
||||||
address=TestNode.PRIV_KEYS[i % 4].address,
|
address=TestNode.PRIV_KEYS[i % 4].address,
|
||||||
)
|
)
|
||||||
|
self.sync_blocks()
|
||||||
assert_equal(self.nodes[CACHE_NODE_ID].getblockchaininfo()["blocks"], 199)
|
assert_equal(self.nodes[CACHE_NODE_ID].getblockchaininfo()["blocks"], 199)
|
||||||
|
|
||||||
# Shut it down, and clean up cache directories:
|
# Shut it down, and clean up cache directories:
|
||||||
|
@ -539,7 +539,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
|
|
||||||
os.rmdir(cache_path('wallets')) # Remove empty wallets dir
|
os.rmdir(cache_path('wallets')) # Remove empty wallets dir
|
||||||
for entry in os.listdir(cache_path()):
|
for entry in os.listdir(cache_path()):
|
||||||
if entry not in ['chainstate', 'blocks', 'claimtrie']: # Only keep chainstate and blocks folder
|
if entry not in ['blocks']: # Only keep blocks folder
|
||||||
os.remove(cache_path(entry))
|
os.remove(cache_path(entry))
|
||||||
|
|
||||||
for i in range(self.num_nodes):
|
for i in range(self.num_nodes):
|
||||||
|
|
|
@ -93,7 +93,6 @@ class TestNode():
|
||||||
"-logthreadnames",
|
"-logthreadnames",
|
||||||
"-debug",
|
"-debug",
|
||||||
"-debugexclude=libevent",
|
"-debugexclude=libevent",
|
||||||
"-debugexclude=leveldb",
|
|
||||||
"-uacomment=testnode%d" % i,
|
"-uacomment=testnode%d" % i,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -538,7 +537,7 @@ class TestNodeCLI():
|
||||||
self.binary = binary
|
self.binary = binary
|
||||||
self.datadir = datadir
|
self.datadir = datadir
|
||||||
self.input = None
|
self.input = None
|
||||||
self.log = logging.getLogger('TestFramework.bitcoincli')
|
self.log = logging.getLogger('TestFramework.lbrycrdcli')
|
||||||
|
|
||||||
def __call__(self, *options, input=None):
|
def __call__(self, *options, input=None):
|
||||||
# TestNodeCLI is callable with bitcoin-cli command-line options
|
# TestNodeCLI is callable with bitcoin-cli command-line options
|
||||||
|
|
|
@ -301,7 +301,7 @@ def initialize_datadir(dirname, n, chain):
|
||||||
chain_name_conf_section = 'test'
|
chain_name_conf_section = 'test'
|
||||||
else:
|
else:
|
||||||
chain_name_conf_arg = chain
|
chain_name_conf_arg = chain
|
||||||
chain_name_conf_section = chain
|
chain_name_conf_section = 'lbrycrdreg'
|
||||||
with open(os.path.join(datadir, "lbrycrd.conf"), 'w', encoding='utf8') as f:
|
with open(os.path.join(datadir, "lbrycrd.conf"), 'w', encoding='utf8') as f:
|
||||||
f.write("{}=1\n".format(chain_name_conf_arg))
|
f.write("{}=1\n".format(chain_name_conf_arg))
|
||||||
f.write("[{}]\n".format(chain_name_conf_section))
|
f.write("[{}]\n".format(chain_name_conf_section))
|
||||||
|
|
|
@ -162,7 +162,7 @@ class WalletBackupTest(BitcoinTestFramework):
|
||||||
|
|
||||||
# Start node2 with no chain
|
# Start node2 with no chain
|
||||||
shutil.rmtree(os.path.join(self.nodes[2].datadir, 'regtest', 'blocks'))
|
shutil.rmtree(os.path.join(self.nodes[2].datadir, 'regtest', 'blocks'))
|
||||||
shutil.rmtree(os.path.join(self.nodes[2].datadir, 'regtest', 'chainstate'))
|
os.remove(os.path.join(self.nodes[2].datadir, 'regtest', 'coins.sqlite'))
|
||||||
|
|
||||||
# Restore wallets from backup
|
# Restore wallets from backup
|
||||||
shutil.copyfile(os.path.join(self.nodes[0].datadir, 'wallet.bak'), os.path.join(self.nodes[0].datadir, 'regtest', 'wallets', 'wallet.dat'))
|
shutil.copyfile(os.path.join(self.nodes[0].datadir, 'wallet.bak'), os.path.join(self.nodes[0].datadir, 'regtest', 'wallets', 'wallet.dat'))
|
||||||
|
@ -183,7 +183,7 @@ class WalletBackupTest(BitcoinTestFramework):
|
||||||
|
|
||||||
#start node2 with no chain
|
#start node2 with no chain
|
||||||
shutil.rmtree(os.path.join(self.nodes[2].datadir, 'regtest', 'blocks'))
|
shutil.rmtree(os.path.join(self.nodes[2].datadir, 'regtest', 'blocks'))
|
||||||
shutil.rmtree(os.path.join(self.nodes[2].datadir, 'regtest', 'chainstate'))
|
os.remove(os.path.join(self.nodes[2].datadir, 'regtest', 'coins.sqlite'))
|
||||||
|
|
||||||
self.start_three()
|
self.start_three()
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ class WalletHDTest(BitcoinTestFramework):
|
||||||
# we need to delete the complete regtest directory
|
# we need to delete the complete regtest directory
|
||||||
# otherwise node1 would auto-recover all funds in flag the keypool keys as used
|
# otherwise node1 would auto-recover all funds in flag the keypool keys as used
|
||||||
shutil.rmtree(os.path.join(self.nodes[1].datadir, "regtest", "blocks"))
|
shutil.rmtree(os.path.join(self.nodes[1].datadir, "regtest", "blocks"))
|
||||||
shutil.rmtree(os.path.join(self.nodes[1].datadir, "regtest", "chainstate"))
|
os.remove(os.path.join(self.nodes[1].datadir, 'regtest', 'coins.sqlite'))
|
||||||
shutil.copyfile(os.path.join(self.nodes[1].datadir, "hd.bak"), os.path.join(self.nodes[1].datadir, "regtest", "wallets", "wallet.dat"))
|
shutil.copyfile(os.path.join(self.nodes[1].datadir, "hd.bak"), os.path.join(self.nodes[1].datadir, "regtest", "wallets", "wallet.dat"))
|
||||||
self.start_node(1)
|
self.start_node(1)
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ class WalletHDTest(BitcoinTestFramework):
|
||||||
# Try a RPC based rescan
|
# Try a RPC based rescan
|
||||||
self.stop_node(1)
|
self.stop_node(1)
|
||||||
shutil.rmtree(os.path.join(self.nodes[1].datadir, "regtest", "blocks"))
|
shutil.rmtree(os.path.join(self.nodes[1].datadir, "regtest", "blocks"))
|
||||||
shutil.rmtree(os.path.join(self.nodes[1].datadir, "regtest", "chainstate"))
|
os.remove(os.path.join(self.nodes[1].datadir, 'regtest', 'coins.sqlite'))
|
||||||
shutil.copyfile(os.path.join(self.nodes[1].datadir, "hd.bak"), os.path.join(self.nodes[1].datadir, "regtest", "wallets", "wallet.dat"))
|
shutil.copyfile(os.path.join(self.nodes[1].datadir, "hd.bak"), os.path.join(self.nodes[1].datadir, "regtest", "wallets", "wallet.dat"))
|
||||||
self.start_node(1, extra_args=self.extra_args[1])
|
self.start_node(1, extra_args=self.extra_args[1])
|
||||||
connect_nodes(self.nodes[0], 1)
|
connect_nodes(self.nodes[0], 1)
|
||||||
|
|
Loading…
Reference in a new issue