mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-15 12:51:00 +02:00
MERGE-FIX: Fix functional tests
This commit is contained in:
parent
473e1e9ca1
commit
efe4e8ff04
23 changed files with 97 additions and 92 deletions
|
|
@ -888,11 +888,6 @@ void InitParameterInteraction()
|
||||||
for (const auto& arg : gArgs.GetUnsuitableSectionOnlyArgs()) {
|
for (const auto& arg : gArgs.GetUnsuitableSectionOnlyArgs()) {
|
||||||
InitWarning(strprintf(_("Config setting for %s only applied on %s network when in [%s] section."), arg, network, network));
|
InitWarning(strprintf(_("Config setting for %s only applied on %s network when in [%s] section."), arg, network, network));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warn if unrecognized section name are present in the config file.
|
|
||||||
for (const auto& section : gArgs.GetUnrecognizedSections()) {
|
|
||||||
InitWarning(strprintf(_("Section [%s] is not recognized."), section));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string ResolveErrMsg(const char * const optname, const std::string& strBind)
|
static std::string ResolveErrMsg(const char * const optname, const std::string& strBind)
|
||||||
|
|
|
||||||
|
|
@ -2371,6 +2371,7 @@ UniValue scantxoutset(const JSONRPCRequest& request)
|
||||||
unspent.pushKV("txid", outpoint.hash.GetHex());
|
unspent.pushKV("txid", outpoint.hash.GetHex());
|
||||||
unspent.pushKV("vout", (int32_t)outpoint.n);
|
unspent.pushKV("vout", (int32_t)outpoint.n);
|
||||||
unspent.pushKV("scriptPubKey", HexStr(txo.scriptPubKey.begin(), txo.scriptPubKey.end()));
|
unspent.pushKV("scriptPubKey", HexStr(txo.scriptPubKey.begin(), txo.scriptPubKey.end()));
|
||||||
|
unspent.pushKV("desc", descriptors[txo.scriptPubKey]);
|
||||||
if (txo.nValue.IsExplicit()) {
|
if (txo.nValue.IsExplicit()) {
|
||||||
unspent.pushKV("amount", ValueFromAmount(txo.nValue.GetAmount()));
|
unspent.pushKV("amount", ValueFromAmount(txo.nValue.GetAmount()));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class BadTxTemplate:
|
||||||
|
|
||||||
def __init__(self, *, spend_tx=None, spend_block=None):
|
def __init__(self, *, spend_tx=None, spend_block=None):
|
||||||
self.spend_tx = spend_block.vtx[0] if spend_block else spend_tx
|
self.spend_tx = spend_block.vtx[0] if spend_block else spend_tx
|
||||||
self.spend_avail = sum(o.nValue for o in self.spend_tx.vout)
|
self.spend_avail = sum(o.nValue.getAmount() for o in self.spend_tx.vout)
|
||||||
self.valid_txin = CTxIn(COutPoint(self.spend_tx.sha256, 0), b"", 0xffffffff)
|
self.valid_txin = CTxIn(COutPoint(self.spend_tx.sha256, 0), b"", 0xffffffff)
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
|
|
@ -78,17 +78,19 @@ class InputMissing(BadTxTemplate):
|
||||||
return tx
|
return tx
|
||||||
|
|
||||||
|
|
||||||
class SizeTooSmall(BadTxTemplate):
|
# ELEMENTS: disabled because we don't want to increase the minimal tx size and
|
||||||
reject_reason = "tx-size-small"
|
# the value and asset size crosses the minimum value
|
||||||
expect_disconnect = False
|
#class SizeTooSmall(BadTxTemplate):
|
||||||
valid_in_block = True
|
# reject_reason = "tx-size-small"
|
||||||
|
# expect_disconnect = False
|
||||||
def get_tx(self):
|
# valid_in_block = True
|
||||||
tx = CTransaction()
|
#
|
||||||
tx.vin.append(self.valid_txin)
|
# def get_tx(self):
|
||||||
tx.vout.append(CTxOut(0, sc.CScript([sc.OP_TRUE])))
|
# tx = CTransaction()
|
||||||
tx.calc_sha256()
|
# tx.vin.append(self.valid_txin)
|
||||||
return tx
|
# tx.vout.append(CTxOut(0, sc.CScript([sc.OP_TRUE])))
|
||||||
|
# tx.calc_sha256()
|
||||||
|
# return tx
|
||||||
|
|
||||||
|
|
||||||
class BadInputOutpointIndex(BadTxTemplate):
|
class BadInputOutpointIndex(BadTxTemplate):
|
||||||
|
|
@ -135,7 +137,8 @@ class NonexistentInput(BadTxTemplate):
|
||||||
|
|
||||||
|
|
||||||
class SpendTooMuch(BadTxTemplate):
|
class SpendTooMuch(BadTxTemplate):
|
||||||
reject_reason = 'bad-txns-in-belowout'
|
reject_reason = 'bad-txns-in-ne-out'
|
||||||
|
block_reject_reason = 'block-validation-failed'
|
||||||
expect_disconnect = True
|
expect_disconnect = True
|
||||||
|
|
||||||
def get_tx(self):
|
def get_tx(self):
|
||||||
|
|
@ -159,7 +162,7 @@ class InvalidOPIFConstruction(BadTxTemplate):
|
||||||
def get_tx(self):
|
def get_tx(self):
|
||||||
return create_tx_with_script(
|
return create_tx_with_script(
|
||||||
self.spend_tx, 0, script_sig=b'\x64' * 35,
|
self.spend_tx, 0, script_sig=b'\x64' * 35,
|
||||||
amount=(self.spend_avail // 2))
|
amount=self.spend_avail)
|
||||||
|
|
||||||
|
|
||||||
class TooManySigops(BadTxTemplate):
|
class TooManySigops(BadTxTemplate):
|
||||||
|
|
@ -172,7 +175,7 @@ class TooManySigops(BadTxTemplate):
|
||||||
return create_tx_with_script(
|
return create_tx_with_script(
|
||||||
self.spend_tx, 0,
|
self.spend_tx, 0,
|
||||||
script_pub_key=lotsa_checksigs,
|
script_pub_key=lotsa_checksigs,
|
||||||
amount=1)
|
amount=self.spend_avail)
|
||||||
|
|
||||||
|
|
||||||
def iter_all_templates():
|
def iter_all_templates():
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ class BlockSubsidyTest(BitcoinTestFramework):
|
||||||
# Block will have 10 satoshi output, node 1 will ban
|
# Block will have 10 satoshi output, node 1 will ban
|
||||||
addr = self.nodes[0].getnewaddress()
|
addr = self.nodes[0].getnewaddress()
|
||||||
sub_block = self.nodes[0].generatetoaddress(1, addr)
|
sub_block = self.nodes[0].generatetoaddress(1, addr)
|
||||||
raw_coinbase = self.nodes[0].getrawtransaction(self.nodes[0].getblock(sub_block[0])["tx"][0])
|
raw_coinbase = self.nodes[0].getrawtransaction(self.nodes[0].getblock(sub_block[0])["tx"][0], False, sub_block[0])
|
||||||
decoded_coinbase = self.nodes[0].decoderawtransaction(raw_coinbase)
|
decoded_coinbase = self.nodes[0].decoderawtransaction(raw_coinbase)
|
||||||
|
|
||||||
found_ten = False
|
found_ten = False
|
||||||
|
|
@ -53,13 +53,13 @@ class BlockSubsidyTest(BitcoinTestFramework):
|
||||||
|
|
||||||
# Block will have 0 satoshis outputs only at height 1
|
# Block will have 0 satoshis outputs only at height 1
|
||||||
no_sub_block = self.nodes[1].generatetoaddress(1, addr)
|
no_sub_block = self.nodes[1].generatetoaddress(1, addr)
|
||||||
raw_coinbase = self.nodes[1].getrawtransaction(self.nodes[1].getblock(no_sub_block[0])["tx"][0])
|
raw_coinbase = self.nodes[1].getrawtransaction(self.nodes[1].getblock(no_sub_block[0])["tx"][0], False, no_sub_block[0])
|
||||||
decoded_coinbase = self.nodes[1].decoderawtransaction(raw_coinbase)
|
decoded_coinbase = self.nodes[1].decoderawtransaction(raw_coinbase)
|
||||||
for vout in decoded_coinbase["vout"]:
|
for vout in decoded_coinbase["vout"]:
|
||||||
if vout["value"] != 0:
|
if vout["value"] != 0:
|
||||||
raise Exception("Invalid output amount in coinbase")
|
raise Exception("Invalid output amount in coinbase")
|
||||||
|
|
||||||
tmpl = self.nodes[0].getblocktemplate()
|
tmpl = self.nodes[0].getblocktemplate({"rules": ["segwit"]})
|
||||||
|
|
||||||
# Template with invalid amount(50*COIN) will be invalid in both
|
# Template with invalid amount(50*COIN) will be invalid in both
|
||||||
coinbase_tx = create_coinbase(height=int(tmpl["height"]))
|
coinbase_tx = create_coinbase(height=int(tmpl["height"]))
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ class BlocksdirTest(BitcoinTestFramework):
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
self.stop_node(0)
|
self.stop_node(0)
|
||||||
assert os.path.isdir(os.path.join(self.nodes[0].datadir, "regtest", "blocks"))
|
assert os.path.isdir(os.path.join(self.nodes[0].datadir, "elementsregtest", "blocks"))
|
||||||
assert not os.path.isdir(os.path.join(self.nodes[0].datadir, "blocks"))
|
assert not os.path.isdir(os.path.join(self.nodes[0].datadir, "blocks"))
|
||||||
shutil.rmtree(self.nodes[0].datadir)
|
shutil.rmtree(self.nodes[0].datadir)
|
||||||
initialize_datadir(self.options.tmpdir, 0, self.chain)
|
initialize_datadir(self.options.tmpdir, 0, self.chain)
|
||||||
|
|
|
||||||
|
|
@ -567,7 +567,7 @@ class CTTest (BitcoinTestFramework):
|
||||||
stx = self.nodes[0].signrawtransactionwithwallet(stx2['hex'])
|
stx = self.nodes[0].signrawtransactionwithwallet(stx2['hex'])
|
||||||
txid = self.nodes[2].sendrawtransaction(stx['hex'])
|
txid = self.nodes[2].sendrawtransaction(stx['hex'])
|
||||||
self.nodes[2].generate(1)
|
self.nodes[2].generate(1)
|
||||||
assert self.nodes[2].getrawtransaction(txid, 1)['confirmations'] == 1
|
assert self.nodes[2].gettransaction(txid)['confirmations'] == 1
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
# Check that the sent asset has reached its destination
|
# Check that the sent asset has reached its destination
|
||||||
|
|
|
||||||
|
|
@ -41,10 +41,11 @@ class ConfArgsTest(BitcoinTestFramework):
|
||||||
conf.write('server=1\nrpcuser=someuser\n[main]\nrpcpassword=some#pass')
|
conf.write('server=1\nrpcuser=someuser\n[main]\nrpcpassword=some#pass')
|
||||||
self.nodes[0].assert_start_raises_init_error(expected_msg='Error reading configuration file: parse error on line 4, using # in rpcpassword can be ambiguous and should be avoided')
|
self.nodes[0].assert_start_raises_init_error(expected_msg='Error reading configuration file: parse error on line 4, using # in rpcpassword can be ambiguous and should be avoided')
|
||||||
|
|
||||||
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
|
# ELEMENTS: allows custom chains
|
||||||
conf.write('testnot.datadir=1\n[testnet]\n')
|
#with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
|
||||||
self.restart_node(0)
|
# conf.write('testnot.datadir=1\n[testnet]\n')
|
||||||
self.nodes[0].stop_node(expected_stderr='Warning: Section [testnet] is not recognized.' + os.linesep + 'Warning: Section [testnot] is not recognized.')
|
#self.restart_node(0)
|
||||||
|
#self.nodes[0].stop_node(expected_stderr='Warning: Section [testnet] is not recognized.' + os.linesep + 'Warning: Section [testnot] is not recognized.')
|
||||||
|
|
||||||
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
|
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
|
||||||
conf.write('') # clear
|
conf.write('') # clear
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ class ConnectGenesisTest(BitcoinTestFramework):
|
||||||
|
|
||||||
# Issuance transaction is an OP_TRUE, so will be available to second node
|
# Issuance transaction is an OP_TRUE, so will be available to second node
|
||||||
assert_raises_rpc_error(-5, "No such mempool transaction. Use -txindex to enable blockchain transaction queries. Use gettransaction for wallet transactions.", self.nodes[0].getrawtransaction, issuance_tx)
|
assert_raises_rpc_error(-5, "No such mempool transaction. Use -txindex to enable blockchain transaction queries. Use gettransaction for wallet transactions.", self.nodes[0].getrawtransaction, issuance_tx)
|
||||||
self.nodes[1].getrawtransaction(issuance_tx)
|
self.nodes[1].getrawtransaction(issuance_tx, False, self.nodes[0].getblockhash(0))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
ConnectGenesisTest().main()
|
ConnectGenesisTest().main()
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ class FedPegTest(BitcoinTestFramework):
|
||||||
|
|
||||||
self.nodes = []
|
self.nodes = []
|
||||||
# Setup parent nodes
|
# Setup parent nodes
|
||||||
parent_chain = "parent" if not self.options.parent_bitcoin else "regtest"
|
parent_chain = "elementsregtest" if not self.options.parent_bitcoin else "regtest"
|
||||||
parent_binary = [self.options.parent_binpath] if self.options.parent_binpath != "" else None
|
parent_binary = [self.options.parent_binpath] if self.options.parent_binpath != "" else None
|
||||||
for n in range(2):
|
for n in range(2):
|
||||||
extra_args = [
|
extra_args = [
|
||||||
|
|
@ -76,9 +76,8 @@ class FedPegTest(BitcoinTestFramework):
|
||||||
extra_args.extend([
|
extra_args.extend([
|
||||||
"-validatepegin=0",
|
"-validatepegin=0",
|
||||||
"-initialfreecoins=0",
|
"-initialfreecoins=0",
|
||||||
"-anyonecanspendaremine",
|
"-anyonecanspendaremine=1",
|
||||||
"-signblockscript=51", # OP_TRUE
|
"-signblockscript=51", # OP_TRUE
|
||||||
'-con_blocksubsidy=5000000000',
|
|
||||||
])
|
])
|
||||||
|
|
||||||
self.add_nodes(1, [extra_args], chain=[parent_chain], binary=parent_binary, chain_in_args=[not self.options.parent_bitcoin])
|
self.add_nodes(1, [extra_args], chain=[parent_chain], binary=parent_binary, chain_in_args=[not self.options.parent_bitcoin])
|
||||||
|
|
@ -101,10 +100,8 @@ class FedPegTest(BitcoinTestFramework):
|
||||||
"-printtoconsole=0",
|
"-printtoconsole=0",
|
||||||
"-port="+str(p2p_port(2+n)),
|
"-port="+str(p2p_port(2+n)),
|
||||||
"-rpcport="+str(rpc_port(2+n)),
|
"-rpcport="+str(rpc_port(2+n)),
|
||||||
'-parentgenesisblockhash=%s' % self.parentgenesisblockhash,
|
|
||||||
'-validatepegin=1',
|
'-validatepegin=1',
|
||||||
'-fedpegscript=%s' % self.fedpeg_script,
|
'-fedpegscript=%s' % self.fedpeg_script,
|
||||||
'-anyonecanspendaremine=0',
|
|
||||||
'-minrelaytxfee=0',
|
'-minrelaytxfee=0',
|
||||||
'-blockmintxfee=0',
|
'-blockmintxfee=0',
|
||||||
'-initialfreecoins=0',
|
'-initialfreecoins=0',
|
||||||
|
|
@ -112,6 +109,7 @@ class FedPegTest(BitcoinTestFramework):
|
||||||
'-mainchainrpchost=127.0.0.1',
|
'-mainchainrpchost=127.0.0.1',
|
||||||
'-mainchainrpcport=%s' % rpc_port(n),
|
'-mainchainrpcport=%s' % rpc_port(n),
|
||||||
'-recheckpeginblockinterval=15', # Long enough to allow failure and repair before timeout
|
'-recheckpeginblockinterval=15', # Long enough to allow failure and repair before timeout
|
||||||
|
'-parentgenesisblockhash=%s' % self.parentgenesisblockhash,
|
||||||
'-parentpubkeyprefix=111',
|
'-parentpubkeyprefix=111',
|
||||||
'-parentscriptprefix=196',
|
'-parentscriptprefix=196',
|
||||||
'-parent_bech32_hrp=bcrt',
|
'-parent_bech32_hrp=bcrt',
|
||||||
|
|
@ -142,7 +140,7 @@ class FedPegTest(BitcoinTestFramework):
|
||||||
datadir = get_datadir_path(self.options.tmpdir, n)
|
datadir = get_datadir_path(self.options.tmpdir, n)
|
||||||
extra_args.append('-mainchainrpccookiefile='+datadir+"/" + parent_chain + "/.cookie")
|
extra_args.append('-mainchainrpccookiefile='+datadir+"/" + parent_chain + "/.cookie")
|
||||||
|
|
||||||
self.add_nodes(1, [extra_args], chain=["sidechain"])
|
self.add_nodes(1, [extra_args], chain=["elementsregtest"])
|
||||||
self.start_node(2+n)
|
self.start_node(2+n)
|
||||||
print("Node {} started".format(2+n))
|
print("Node {} started".format(2+n))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ def b2x(b):
|
||||||
def assert_template(node, block, expect, rehash=True):
|
def assert_template(node, block, expect, rehash=True):
|
||||||
if rehash:
|
if rehash:
|
||||||
block.hashMerkleRoot = block.calc_merkle_root()
|
block.hashMerkleRoot = block.calc_merkle_root()
|
||||||
rsp = node.getblocktemplate({'data': b2x(block.serialize()), 'mode': 'proposal'})
|
rsp = node.getblocktemplate({'data': b2x(block.serialize()), 'mode': 'proposal', 'rules': 'segwit'})
|
||||||
assert_equal(rsp, expect)
|
assert_equal(rsp, expect)
|
||||||
|
|
||||||
class MandatoryCoinbaseTest(BitcoinTestFramework):
|
class MandatoryCoinbaseTest(BitcoinTestFramework):
|
||||||
|
|
@ -51,7 +51,7 @@ class MandatoryCoinbaseTest(BitcoinTestFramework):
|
||||||
|
|
||||||
# Have non-mandatory node make a template
|
# Have non-mandatory node make a template
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
tmpl = node1.getblocktemplate()
|
tmpl = node1.getblocktemplate({'rules': ['segwit']})
|
||||||
|
|
||||||
# We make a block with OP_TRUE coinbase output that will fail on node0
|
# We make a block with OP_TRUE coinbase output that will fail on node0
|
||||||
coinbase_tx = create_coinbase(height=int(tmpl["height"]))
|
coinbase_tx = create_coinbase(height=int(tmpl["height"]))
|
||||||
|
|
@ -86,7 +86,7 @@ class MandatoryCoinbaseTest(BitcoinTestFramework):
|
||||||
#
|
#
|
||||||
# Also test that coinbases can't have fees.
|
# Also test that coinbases can't have fees.
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
tmpl = node1.getblocktemplate()
|
tmpl = node1.getblocktemplate({'rules': ['segwit']})
|
||||||
coinbase_tx = create_coinbase(height=int(tmpl["height"]))
|
coinbase_tx = create_coinbase(height=int(tmpl["height"]))
|
||||||
# sequence numbers must not be max for nLockTime to have effect
|
# sequence numbers must not be max for nLockTime to have effect
|
||||||
coinbase_tx.vin[0].nSequence = 2 ** 32 - 2
|
coinbase_tx.vin[0].nSequence = 2 ** 32 - 2
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,6 @@ class RESTTest (BitcoinTestFramework):
|
||||||
txid = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1)
|
txid = self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
assert_equal(self.nodes[1].getbalance()['bitcoin'], Decimal("0.1"))
|
|
||||||
|
|
||||||
self.log.info("Test the /tx URI")
|
self.log.info("Test the /tx URI")
|
||||||
|
|
||||||
json_obj = self.test_rest_request("/tx/{}".format(txid))
|
json_obj = self.test_rest_request("/tx/{}".format(txid))
|
||||||
|
|
@ -114,7 +112,7 @@ class RESTTest (BitcoinTestFramework):
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
bb_hash = self.nodes[0].getbestblockhash()
|
bb_hash = self.nodes[0].getbestblockhash()
|
||||||
|
|
||||||
assert_equal(self.nodes[1].getbalance(), Decimal("0.1"))
|
assert_equal(self.nodes[1].getbalance()['bitcoin'], Decimal("0.1"))
|
||||||
|
|
||||||
# Check chainTip response
|
# Check chainTip response
|
||||||
json_obj = self.test_rest_request("/getutxos/{}-{}".format(*spending))
|
json_obj = self.test_rest_request("/getutxos/{}-{}".format(*spending))
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
|
||||||
coin = coins.pop() # Pick a random coin(base) to spend
|
coin = coins.pop() # Pick a random coin(base) to spend
|
||||||
raw_tx_final = node.signrawtransactionwithwallet(node.createrawtransaction(
|
raw_tx_final = node.signrawtransactionwithwallet(node.createrawtransaction(
|
||||||
inputs=[{'txid': coin['txid'], 'vout': coin['vout'], "sequence": 0xffffffff}], # SEQUENCE_FINAL
|
inputs=[{'txid': coin['txid'], 'vout': coin['vout'], "sequence": 0xffffffff}], # SEQUENCE_FINAL
|
||||||
outputs=[{node.getnewaddress(): 0.025}],
|
outputs=[{node.getnewaddress(): 0.025}, {"fee": coin["amount"]-Decimal("0.025")}],
|
||||||
locktime=node.getblockcount() + 2000, # Can be anything
|
locktime=node.getblockcount() + 2000, # Can be anything
|
||||||
))['hex']
|
))['hex']
|
||||||
tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_final)))
|
tx.deserialize(BytesIO(hex_str_to_bytes(raw_tx_final)))
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ class MiningTest(BitcoinTestFramework):
|
||||||
mining_info = self.nodes[0].getmininginfo()
|
mining_info = self.nodes[0].getmininginfo()
|
||||||
assert_equal(mining_info['blocks'], 200)
|
assert_equal(mining_info['blocks'], 200)
|
||||||
assert_equal(mining_info['currentblocktx'], 0)
|
assert_equal(mining_info['currentblocktx'], 0)
|
||||||
assert_equal(mining_info['currentblockweight'], 4000)
|
assert_equal(mining_info['currentblockweight'], 4300)
|
||||||
self.restart_node(0)
|
self.restart_node(0)
|
||||||
connect_nodes_bi(self.nodes, 0, 1)
|
connect_nodes_bi(self.nodes, 0, 1)
|
||||||
|
|
||||||
|
|
@ -70,11 +70,8 @@ class MiningTest(BitcoinTestFramework):
|
||||||
mining_info = node.getmininginfo()
|
mining_info = node.getmininginfo()
|
||||||
assert_equal(mining_info['blocks'], 200)
|
assert_equal(mining_info['blocks'], 200)
|
||||||
assert_equal(mining_info['chain'], self.chain)
|
assert_equal(mining_info['chain'], self.chain)
|
||||||
//TODO(stevenroose) this changed, should it be 0 or not included?
|
assert 'currentblocktx' not in mining_info
|
||||||
assert_equal(mining_info['currentblocktx'], 0)
|
assert 'currentblockweight' not in mining_info
|
||||||
assert_equal(mining_info['currentblockweight'], 0)
|
|
||||||
#assert 'currentblocktx' not in mining_info
|
|
||||||
#assert 'currentblockweight' not in mining_info
|
|
||||||
assert_equal(mining_info['pooledtx'], 0)
|
assert_equal(mining_info['pooledtx'], 0)
|
||||||
|
|
||||||
# Mine a block to leave initial block download
|
# Mine a block to leave initial block download
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ class InvalidBlockRequestTest(BitcoinTestFramework):
|
||||||
block2_orig.hashMerkleRoot = block2_orig.calc_merkle_root()
|
block2_orig.hashMerkleRoot = block2_orig.calc_merkle_root()
|
||||||
block2_orig.rehash()
|
block2_orig.rehash()
|
||||||
block2_orig.solve()
|
block2_orig.solve()
|
||||||
node.p2p.send_blocks_and_test([block2_orig], node, success=False, request_block=False, reject_reason='bad-txns-inputs-duplicate')
|
node.p2p.send_blocks_and_test([block2_orig], node, success=False, reject_reason='bad-txns-inputs-duplicate')
|
||||||
|
|
||||||
self.log.info("Test very broken block.")
|
self.log.info("Test very broken block.")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,18 +16,18 @@ class DeriveaddressesTest(BitcoinTestFramework):
|
||||||
assert_raises_rpc_error(-5, "Invalid descriptor", self.nodes[0].deriveaddresses, "a")
|
assert_raises_rpc_error(-5, "Invalid descriptor", self.nodes[0].deriveaddresses, "a")
|
||||||
|
|
||||||
descriptor = "wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/1/0)#t6wfjs64"
|
descriptor = "wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/1/0)#t6wfjs64"
|
||||||
address = "bcrt1qjqmxmkpmxt80xz4y3746zgt0q3u3ferr34acd5"
|
address = "ert1qjqmxmkpmxt80xz4y3746zgt0q3u3ferrfpgxn5"
|
||||||
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, "Invalid descriptor", self.nodes[0].deriveaddresses, descriptor)
|
assert_raises_rpc_error(-5, "Invalid descriptor", self.nodes[0].deriveaddresses, descriptor)
|
||||||
|
|
||||||
descriptor_pubkey = "wpkh(tpubD6NzVbkrYhZ4WaWSyoBvQwbpLkojyoTZPRsgXELWz3Popb3qkjcJyJUGLnL4qHHoQvao8ESaAstxYSnhyswJ76uZPStJRJCTKvosUCJZL5B/1/1/0)#s9ga3alw"
|
descriptor_pubkey = "wpkh(tpubD6NzVbkrYhZ4WaWSyoBvQwbpLkojyoTZPRsgXELWz3Popb3qkjcJyJUGLnL4qHHoQvao8ESaAstxYSnhyswJ76uZPStJRJCTKvosUCJZL5B/1/1/0)#s9ga3alw"
|
||||||
address = "bcrt1qjqmxmkpmxt80xz4y3746zgt0q3u3ferr34acd5"
|
address = "ert1qjqmxmkpmxt80xz4y3746zgt0q3u3ferrfpgxn5"
|
||||||
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, 0, 2), [address, "bcrt1qhku5rq7jz8ulufe2y6fkcpnlvpsta7rq4442dy", "bcrt1qpgptk2gvshyl0s9lqshsmx932l9ccsv265tvaq"])
|
assert_equal(self.nodes[0].deriveaddresses(ranged_descriptor, 0, 2), [address, "ert1qhku5rq7jz8ulufe2y6fkcpnlvpsta7rqdpq5ny", "ert1qpgptk2gvshyl0s9lqshsmx932l9ccsv2zq7jrq"])
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
|
@ -40,7 +40,7 @@ class DeriveaddressesTest(BitcoinTestFramework):
|
||||||
assert_raises_rpc_error(-8, "Range should be greater or equal than 0", self.nodes[0].deriveaddresses, descsum_create("wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/1/*)"), -1, 0)
|
assert_raises_rpc_error(-8, "Range should be greater or equal than 0", self.nodes[0].deriveaddresses, descsum_create("wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/1/*)"), -1, 0)
|
||||||
|
|
||||||
combo_descriptor = descsum_create("combo(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/1/0)")
|
combo_descriptor = descsum_create("combo(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/1/0)")
|
||||||
assert_equal(self.nodes[0].deriveaddresses(combo_descriptor), ["mtfUoUax9L4tzXARpw1oTGxWyoogp52KhJ", "mtfUoUax9L4tzXARpw1oTGxWyoogp52KhJ", address, "2NDvEwGfpEqJWfybzpKPHF2XH3jwoQV3D7x"])
|
assert_equal(self.nodes[0].deriveaddresses(combo_descriptor), ["2dnaGtwYgBhXYQGTArxKKapi52Mkf3KTQhb", "2dnaGtwYgBhXYQGTArxKKapi52Mkf3KTQhb", address, "XY2Fo8bxL1EViXjWrZ5iZrb5thmfPvWJxw"])
|
||||||
|
|
||||||
hardened_without_privkey_descriptor = descsum_create("wpkh(tpubD6NzVbkrYhZ4WaWSyoBvQwbpLkojyoTZPRsgXELWz3Popb3qkjcJyJUGLnL4qHHoQvao8ESaAstxYSnhyswJ76uZPStJRJCTKvosUCJZL5B/1'/1/0)")
|
hardened_without_privkey_descriptor = descsum_create("wpkh(tpubD6NzVbkrYhZ4WaWSyoBvQwbpLkojyoTZPRsgXELWz3Popb3qkjcJyJUGLnL4qHHoQvao8ESaAstxYSnhyswJ76uZPStJRJCTKvosUCJZL5B/1'/1/0)")
|
||||||
assert_raises_rpc_error(-5, "Cannot derive script without private keys", self.nodes[0].deriveaddresses, hardened_without_privkey_descriptor)
|
assert_raises_rpc_error(-5, "Cannot derive script without private keys", self.nodes[0].deriveaddresses, hardened_without_privkey_descriptor)
|
||||||
|
|
|
||||||
|
|
@ -171,6 +171,9 @@ class SignRawTransactionsTest(BitcoinTestFramework):
|
||||||
assert_equal(spending_tx_signed['complete'], True)
|
assert_equal(spending_tx_signed['complete'], True)
|
||||||
|
|
||||||
def run_test(self):
|
def run_test(self):
|
||||||
|
self.nodes[0].set_deterministic_priv_key('2Mysp7FKKe52eoC2JmU46irt1dt58TpCvhQ', 'cTNbtVJmhx75RXomhYWSZAafuNNNKPd1cr2ZiUcAeukLNGrHWjvJ')
|
||||||
|
self.nodes[0].importprivkey("cTNbtVJmhx75RXomhYWSZAafuNNNKPd1cr2ZiUcAeukLNGrHWjvJ")
|
||||||
|
|
||||||
self.successful_signing_test()
|
self.successful_signing_test()
|
||||||
self.script_verification_error_test()
|
self.script_verification_error_test()
|
||||||
self.witness_script_test()
|
self.witness_script_test()
|
||||||
|
|
|
||||||
|
|
@ -716,7 +716,6 @@ class CTransaction:
|
||||||
self.wit = CTxWitness()
|
self.wit = CTxWitness()
|
||||||
if flags > 1:
|
if flags > 1:
|
||||||
raise TypeError('Extra witness flags:' + str(flags))
|
raise TypeError('Extra witness flags:' + str(flags))
|
||||||
self.nLockTime = struct.unpack("<I", f.read(4))[0]
|
|
||||||
self.sha256 = None
|
self.sha256 = None
|
||||||
self.hash = None
|
self.hash = None
|
||||||
|
|
||||||
|
|
@ -907,7 +906,7 @@ class CBlockHeader:
|
||||||
time.ctime(self.nTime), self.block_height)
|
time.ctime(self.nTime), self.block_height)
|
||||||
|
|
||||||
BLOCK_HEADER_SIZE = len(CBlockHeader().serialize())
|
BLOCK_HEADER_SIZE = len(CBlockHeader().serialize())
|
||||||
assert_equal(BLOCK_HEADER_SIZE, 80)
|
assert_equal(BLOCK_HEADER_SIZE, 79)
|
||||||
|
|
||||||
class CBlock(CBlockHeader):
|
class CBlock(CBlockHeader):
|
||||||
__slots__ = ("vtx",)
|
__slots__ = ("vtx",)
|
||||||
|
|
|
||||||
|
|
@ -318,7 +318,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
||||||
numnode = len(self.nodes)
|
numnode = len(self.nodes)
|
||||||
self.nodes.append(TestNode(
|
self.nodes.append(TestNode(
|
||||||
numnode,
|
numnode,
|
||||||
get_datadir_path(self.options.tmpdir, i),
|
get_datadir_path(self.options.tmpdir, numnode),
|
||||||
chain[i],
|
chain[i],
|
||||||
rpchost=rpchost,
|
rpchost=rpchost,
|
||||||
timewait=self.rpc_timeout,
|
timewait=self.rpc_timeout,
|
||||||
|
|
|
||||||
|
|
@ -325,7 +325,7 @@ def initialize_datadir(dirname, n, chain):
|
||||||
f.write("con_connect_coinbase=0\n")
|
f.write("con_connect_coinbase=0\n")
|
||||||
f.write("anyonecanspendaremine=0\n")
|
f.write("anyonecanspendaremine=0\n")
|
||||||
f.write("walletrbf=0\n") # Default is 1 in Elements
|
f.write("walletrbf=0\n") # Default is 1 in Elements
|
||||||
f.write("con_bip34height=100000000\n")
|
f.write("con_bip34height=500\n")
|
||||||
f.write("con_bip65height=1351\n")
|
f.write("con_bip65height=1351\n")
|
||||||
f.write("con_bip66height=1251\n")
|
f.write("con_bip66height=1251\n")
|
||||||
f.write("con_csv_deploy_start=0\n") # Enhance tests if removing this line
|
f.write("con_csv_deploy_start=0\n") # Enhance tests if removing this line
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ class ToolWalletTest(BitcoinTestFramework):
|
||||||
self.skip_if_no_wallet()
|
self.skip_if_no_wallet()
|
||||||
|
|
||||||
def bitcoin_wallet_process(self, *args):
|
def bitcoin_wallet_process(self, *args):
|
||||||
binary = self.config["environment"]["BUILDDIR"] + '/src/bitcoin-wallet' + self.config["environment"]["EXEEXT"]
|
binary = self.config["environment"]["BUILDDIR"] + '/src/elements-wallet' + self.config["environment"]["EXEEXT"]
|
||||||
args = ['-datadir={}'.format(self.nodes[0].datadir), '-regtest'] + list(args)
|
args = ['-datadir={}'.format(self.nodes[0].datadir), '-chain=elementsregtest'] + list(args)
|
||||||
return subprocess.Popen([binary] + args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
return subprocess.Popen([binary] + args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
||||||
|
|
||||||
def assert_raises_tool_error(self, error, *args):
|
def assert_raises_tool_error(self, error, *args):
|
||||||
|
|
|
||||||
|
|
@ -308,7 +308,8 @@ class AddressTypeTest(BitcoinTestFramework):
|
||||||
for utxo in self.nodes[to_node].listunspent():
|
for utxo in self.nodes[to_node].listunspent():
|
||||||
if utxo['address'] == addresses[to_node][0]:
|
if utxo['address'] == addresses[to_node][0]:
|
||||||
found = True
|
found = True
|
||||||
self.test_desc(to_node, addresses[to_node][0], multisig, addresses[to_node][1], utxo)
|
#TODO(gwillen) turn back on after PSBT
|
||||||
|
#self.test_desc(to_node, addresses[to_node][0], multisig, addresses[to_node][1], utxo)
|
||||||
break
|
break
|
||||||
assert found
|
assert found
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,10 @@ from test_framework.test_framework import BitcoinTestFramework
|
||||||
from test_framework.util import (
|
from test_framework.util import (
|
||||||
assert_equal,
|
assert_equal,
|
||||||
assert_raises_rpc_error,
|
assert_raises_rpc_error,
|
||||||
|
BITCOIN_ASSET,
|
||||||
)
|
)
|
||||||
|
|
||||||
RANDOM_COINBASE_ADDRESS = 'mneYUmWYsuk7kySiURxCi3AGxrAqZxLgPZ'
|
RANDOM_COINBASE_ADDRESS = 'XSUuFy4upmMmBo75Gpw3RPXsKJp81FpVVi'
|
||||||
|
|
||||||
def create_transactions(node, address, amt, fees):
|
def create_transactions(node, address, amt, fees):
|
||||||
# Create and sign raw transactions from node to address for amt.
|
# Create and sign raw transactions from node to address for amt.
|
||||||
|
|
@ -23,14 +24,22 @@ def create_transactions(node, address, amt, fees):
|
||||||
inputs = []
|
inputs = []
|
||||||
ins_total = 0
|
ins_total = 0
|
||||||
for utxo in utxos:
|
for utxo in utxos:
|
||||||
|
assert utxo['asset'] == BITCOIN_ASSET
|
||||||
inputs.append({"txid": utxo["txid"], "vout": utxo["vout"]})
|
inputs.append({"txid": utxo["txid"], "vout": utxo["vout"]})
|
||||||
ins_total += utxo['amount']
|
ins_total += utxo['amount']
|
||||||
if ins_total > amt:
|
if ins_total + max(fees) > amt:
|
||||||
break
|
break
|
||||||
|
# make sure there was enough utxos
|
||||||
|
assert ins_total >= amt + max(fees)
|
||||||
|
|
||||||
txs = []
|
txs = []
|
||||||
for fee in fees:
|
for fee in fees:
|
||||||
outputs = {address: amt, node.getrawchangeaddress(): ins_total - amt - fee}
|
outputs = {address: amt}
|
||||||
|
# prevent 0 change output
|
||||||
|
if ins_total > amt + fee:
|
||||||
|
outputs[node.getrawchangeaddress()] = ins_total - amt - fee
|
||||||
|
if fee > 0:
|
||||||
|
outputs["fee"] = fee
|
||||||
raw_tx = node.createrawtransaction(inputs, outputs, 0, True)
|
raw_tx = node.createrawtransaction(inputs, outputs, 0, True)
|
||||||
raw_tx = node.signrawtransactionwithwallet(raw_tx)
|
raw_tx = node.signrawtransactionwithwallet(raw_tx)
|
||||||
txs.append(raw_tx)
|
txs.append(raw_tx)
|
||||||
|
|
@ -58,14 +67,14 @@ class WalletTest(BitcoinTestFramework):
|
||||||
self.nodes[1].generatetoaddress(100, RANDOM_COINBASE_ADDRESS)
|
self.nodes[1].generatetoaddress(100, RANDOM_COINBASE_ADDRESS)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
assert_equal(self.nodes[0].getbalance(), 50)
|
assert_equal(self.nodes[0].getbalance()['bitcoin'], 50)
|
||||||
assert_equal(self.nodes[1].getbalance(), 50)
|
assert_equal(self.nodes[1].getbalance()['bitcoin'], 50)
|
||||||
|
|
||||||
self.log.info("Test getbalance with different arguments")
|
self.log.info("Test getbalance with different arguments")
|
||||||
assert_equal(self.nodes[0].getbalance("*"), 50)
|
assert_equal(self.nodes[0].getbalance("*")['bitcoin'], 50)
|
||||||
assert_equal(self.nodes[0].getbalance("*", 1), 50)
|
assert_equal(self.nodes[0].getbalance("*", 1)['bitcoin'], 50)
|
||||||
assert_equal(self.nodes[0].getbalance("*", 1, True), 50)
|
assert_equal(self.nodes[0].getbalance("*", 1, True)['bitcoin'], 50)
|
||||||
assert_equal(self.nodes[0].getbalance(minconf=1), 50)
|
assert_equal(self.nodes[0].getbalance(minconf=1)['bitcoin'], 50)
|
||||||
|
|
||||||
# Send 40 BTC from 0 to 1 and 60 BTC from 1 to 0.
|
# Send 40 BTC from 0 to 1 and 60 BTC from 1 to 0.
|
||||||
txs = create_transactions(self.nodes[0], self.nodes[1].getnewaddress(), 40, [Decimal('0.01')])
|
txs = create_transactions(self.nodes[0], self.nodes[1].getnewaddress(), 40, [Decimal('0.01')])
|
||||||
|
|
@ -84,18 +93,18 @@ class WalletTest(BitcoinTestFramework):
|
||||||
self.log.info("Test getbalance and getunconfirmedbalance with unconfirmed inputs")
|
self.log.info("Test getbalance and getunconfirmedbalance with unconfirmed inputs")
|
||||||
|
|
||||||
# getbalance without any arguments includes unconfirmed transactions, but not untrusted transactions
|
# getbalance without any arguments includes unconfirmed transactions, but not untrusted transactions
|
||||||
assert_equal(self.nodes[0].getbalance(), Decimal('9.99')) # change from node 0's send
|
assert_equal(self.nodes[0].getbalance()['bitcoin'], Decimal('9.99')) # change from node 0's send
|
||||||
assert_equal(self.nodes[1].getbalance(), Decimal('29.99')) # change from node 1's send
|
assert_equal(self.nodes[1].getbalance()['bitcoin'], Decimal('29.99')) # change from node 1's send
|
||||||
# Same with minconf=0
|
# Same with minconf=0
|
||||||
assert_equal(self.nodes[0].getbalance(minconf=0), Decimal('9.99'))
|
assert_equal(self.nodes[0].getbalance(minconf=0)['bitcoin'], Decimal('9.99'))
|
||||||
assert_equal(self.nodes[1].getbalance(minconf=0), Decimal('29.99'))
|
assert_equal(self.nodes[1].getbalance(minconf=0)['bitcoin'], Decimal('29.99'))
|
||||||
# getbalance with a minconf incorrectly excludes coins that have been spent more recently than the minconf blocks ago
|
# getbalance with a minconf incorrectly excludes coins that have been spent more recently than the minconf blocks ago
|
||||||
# TODO: fix getbalance tracking of coin spentness depth
|
# TODO: fix getbalance tracking of coin spentness depth
|
||||||
assert_equal(self.nodes[0].getbalance(minconf=1), Decimal('0'))
|
assert_equal(self.nodes[0].getbalance(minconf=1)['bitcoin'], Decimal('0'))
|
||||||
assert_equal(self.nodes[1].getbalance(minconf=1), Decimal('0'))
|
assert_equal(self.nodes[1].getbalance(minconf=1)['bitcoin'], Decimal('0'))
|
||||||
# getunconfirmedbalance
|
# getunconfirmedbalance
|
||||||
assert_equal(self.nodes[0].getunconfirmedbalance(), Decimal('60')) # output of node 1's spend
|
assert_equal(self.nodes[0].getunconfirmedbalance()['bitcoin'], Decimal('60')) # output of node 1's spend
|
||||||
assert_equal(self.nodes[1].getunconfirmedbalance(), Decimal('0')) # Doesn't include output of node 0's send since it was spent
|
assert_equal(self.nodes[1].getunconfirmedbalance()['bitcoin'], Decimal('0')) # Doesn't include output of node 0's send since it was spent
|
||||||
|
|
||||||
# Node 1 bumps the transaction fee and resends
|
# Node 1 bumps the transaction fee and resends
|
||||||
self.nodes[1].sendrawtransaction(txs[1]['hex'])
|
self.nodes[1].sendrawtransaction(txs[1]['hex'])
|
||||||
|
|
@ -103,17 +112,17 @@ class WalletTest(BitcoinTestFramework):
|
||||||
|
|
||||||
self.log.info("Test getbalance and getunconfirmedbalance with conflicted unconfirmed inputs")
|
self.log.info("Test getbalance and getunconfirmedbalance with conflicted unconfirmed inputs")
|
||||||
|
|
||||||
assert_equal(self.nodes[0].getwalletinfo()["unconfirmed_balance"], Decimal('60')) # output of node 1's send
|
assert_equal(self.nodes[0].getwalletinfo()["unconfirmed_balance"]['bitcoin'], Decimal('60')) # output of node 1's send
|
||||||
assert_equal(self.nodes[0].getunconfirmedbalance(), Decimal('60'))
|
assert_equal(self.nodes[0].getunconfirmedbalance()['bitcoin'], Decimal('60'))
|
||||||
assert_equal(self.nodes[1].getwalletinfo()["unconfirmed_balance"], Decimal('0')) # Doesn't include output of node 0's send since it was spent
|
assert_equal(self.nodes[1].getwalletinfo()["unconfirmed_balance"]['bitcoin'], Decimal('0')) # Doesn't include output of node 0's send since it was spent
|
||||||
assert_equal(self.nodes[1].getunconfirmedbalance(), Decimal('0'))
|
assert_equal(self.nodes[1].getunconfirmedbalance()['bitcoin'], Decimal('0'))
|
||||||
|
|
||||||
self.nodes[1].generatetoaddress(1, RANDOM_COINBASE_ADDRESS)
|
self.nodes[1].generatetoaddress(1, RANDOM_COINBASE_ADDRESS)
|
||||||
self.sync_all()
|
self.sync_all()
|
||||||
|
|
||||||
# balances are correct after the transactions are confirmed
|
# balances are correct after the transactions are confirmed
|
||||||
assert_equal(self.nodes[0].getbalance(), Decimal('69.99')) # node 1's send plus change from node 0's send
|
assert_equal(self.nodes[0].getbalance()['bitcoin'], Decimal('69.99')) # node 1's send plus change from node 0's send
|
||||||
assert_equal(self.nodes[1].getbalance(), Decimal('29.98')) # change from node 0's send
|
assert_equal(self.nodes[1].getbalance()['bitcoin'], Decimal('29.98')) # change from node 0's send
|
||||||
|
|
||||||
# Send total balance away from node 1
|
# Send total balance away from node 1
|
||||||
txs = create_transactions(self.nodes[1], self.nodes[0].getnewaddress(), Decimal('29.97'), [Decimal('0.01')])
|
txs = create_transactions(self.nodes[1], self.nodes[0].getnewaddress(), Decimal('29.97'), [Decimal('0.01')])
|
||||||
|
|
@ -124,10 +133,10 @@ class WalletTest(BitcoinTestFramework):
|
||||||
# getbalance with a minconf incorrectly excludes coins that have been spent more recently than the minconf blocks ago
|
# getbalance with a minconf incorrectly excludes coins that have been spent more recently than the minconf blocks ago
|
||||||
# TODO: fix getbalance tracking of coin spentness depth
|
# TODO: fix getbalance tracking of coin spentness depth
|
||||||
# getbalance with minconf=3 should still show the old balance
|
# getbalance with minconf=3 should still show the old balance
|
||||||
assert_equal(self.nodes[1].getbalance(minconf=3), Decimal('0'))
|
assert_equal(self.nodes[1].getbalance(minconf=3)['bitcoin'], Decimal('0'))
|
||||||
|
|
||||||
# getbalance with minconf=2 will show the new balance.
|
# getbalance with minconf=2 will show the new balance.
|
||||||
assert_equal(self.nodes[1].getbalance(minconf=2), Decimal('0'))
|
assert_equal(self.nodes[1].getbalance(minconf=2)['bitcoin'], Decimal('0'))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
WalletTest().main()
|
WalletTest().main()
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ class ImportMultiTest(BitcoinTestFramework):
|
||||||
self.log.info("Should import an address")
|
self.log.info("Should import an address")
|
||||||
key = get_key(self.nodes[0])
|
key = get_key(self.nodes[0])
|
||||||
self.test_importmulti({"scriptPubKey": {"address": key.p2pkh_addr},
|
self.test_importmulti({"scriptPubKey": {"address": key.p2pkh_addr},
|
||||||
"timestamp": "now"
|
"timestamp": "now",
|
||||||
# ELEMENTS: Also import blinding key
|
# ELEMENTS: Also import blinding key
|
||||||
"blinding_privkey": key.blinding_privkey,
|
"blinding_privkey": key.blinding_privkey,
|
||||||
},
|
},
|
||||||
|
|
@ -816,11 +816,11 @@ class ImportMultiTest(BitcoinTestFramework):
|
||||||
assert_equal(wrpc.getwalletinfo()["private_keys_enabled"], False)
|
assert_equal(wrpc.getwalletinfo()["private_keys_enabled"], False)
|
||||||
xpub = "tpubDAXcJ7s7ZwicqjprRaEWdPoHKrCS215qxGYxpusRLLmJuT69ZSicuGdSfyvyKpvUNYBW1s2U3NSrT6vrCYB9e6nZUEvrqnwXPF8ArTCRXMY"
|
xpub = "tpubDAXcJ7s7ZwicqjprRaEWdPoHKrCS215qxGYxpusRLLmJuT69ZSicuGdSfyvyKpvUNYBW1s2U3NSrT6vrCYB9e6nZUEvrqnwXPF8ArTCRXMY"
|
||||||
addresses = [
|
addresses = [
|
||||||
'bcrt1qtmp74ayg7p24uslctssvjm06q5phz4yrxucgnv', # m/0'/0'/0
|
'ert1qtmp74ayg7p24uslctssvjm06q5phz4yr7gdkdv', # m/0'/0'/0
|
||||||
'bcrt1q8vprchan07gzagd5e6v9wd7azyucksq2xc76k8', # m/0'/0'/1
|
'ert1q8vprchan07gzagd5e6v9wd7azyucksq27vtyg8', # m/0'/0'/1
|
||||||
'bcrt1qtuqdtha7zmqgcrr26n2rqxztv5y8rafjp9lulu', # m/0'/0'/2
|
'ert1qtuqdtha7zmqgcrr26n2rqxztv5y8rafje32zpu', # m/0'/0'/2
|
||||||
'bcrt1qau64272ymawq26t90md6an0ps99qkrse58m640', # m/0'/0'/3
|
'ert1qau64272ymawq26t90md6an0ps99qkrsevnwyt0', # m/0'/0'/3
|
||||||
'bcrt1qsg97266hrh6cpmutqen8s4s962aryy77jp0fg0', # m/0'/0'/4
|
'ert1qsg97266hrh6cpmutqen8s4s962aryy77246hk0', # m/0'/0'/4
|
||||||
]
|
]
|
||||||
result = wrpc.importmulti(
|
result = wrpc.importmulti(
|
||||||
[{
|
[{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue