Skip to content

Commit efe4e8f

Browse files
committed
MERGE-FIX: Fix functional tests
1 parent 473e1e9 commit efe4e8f

23 files changed

+97
-92
lines changed

src/init.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -888,11 +888,6 @@ void InitParameterInteraction()
888888
for (const auto& arg : gArgs.GetUnsuitableSectionOnlyArgs()) {
889889
InitWarning(strprintf(_("Config setting for %s only applied on %s network when in [%s] section."), arg, network, network));
890890
}
891-
892-
// Warn if unrecognized section name are present in the config file.
893-
for (const auto& section : gArgs.GetUnrecognizedSections()) {
894-
InitWarning(strprintf(_("Section [%s] is not recognized."), section));
895-
}
896891
}
897892

898893
static std::string ResolveErrMsg(const char * const optname, const std::string& strBind)

src/rpc/blockchain.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2371,6 +2371,7 @@ UniValue scantxoutset(const JSONRPCRequest& request)
23712371
unspent.pushKV("txid", outpoint.hash.GetHex());
23722372
unspent.pushKV("vout", (int32_t)outpoint.n);
23732373
unspent.pushKV("scriptPubKey", HexStr(txo.scriptPubKey.begin(), txo.scriptPubKey.end()));
2374+
unspent.pushKV("desc", descriptors[txo.scriptPubKey]);
23742375
if (txo.nValue.IsExplicit()) {
23752376
unspent.pushKV("amount", ValueFromAmount(txo.nValue.GetAmount()));
23762377
} else {

test/functional/data/invalid_txs.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class BadTxTemplate:
4747

4848
def __init__(self, *, spend_tx=None, spend_block=None):
4949
self.spend_tx = spend_block.vtx[0] if spend_block else spend_tx
50-
self.spend_avail = sum(o.nValue for o in self.spend_tx.vout)
50+
self.spend_avail = sum(o.nValue.getAmount() for o in self.spend_tx.vout)
5151
self.valid_txin = CTxIn(COutPoint(self.spend_tx.sha256, 0), b"", 0xffffffff)
5252

5353
@abc.abstractmethod
@@ -78,17 +78,19 @@ def get_tx(self):
7878
return tx
7979

8080

81-
class SizeTooSmall(BadTxTemplate):
82-
reject_reason = "tx-size-small"
83-
expect_disconnect = False
84-
valid_in_block = True
85-
86-
def get_tx(self):
87-
tx = CTransaction()
88-
tx.vin.append(self.valid_txin)
89-
tx.vout.append(CTxOut(0, sc.CScript([sc.OP_TRUE])))
90-
tx.calc_sha256()
91-
return tx
81+
# ELEMENTS: disabled because we don't want to increase the minimal tx size and
82+
# the value and asset size crosses the minimum value
83+
#class SizeTooSmall(BadTxTemplate):
84+
# reject_reason = "tx-size-small"
85+
# expect_disconnect = False
86+
# valid_in_block = True
87+
#
88+
# def get_tx(self):
89+
# tx = CTransaction()
90+
# tx.vin.append(self.valid_txin)
91+
# tx.vout.append(CTxOut(0, sc.CScript([sc.OP_TRUE])))
92+
# tx.calc_sha256()
93+
# return tx
9294

9395

9496
class BadInputOutpointIndex(BadTxTemplate):
@@ -135,7 +137,8 @@ def get_tx(self):
135137

136138

137139
class SpendTooMuch(BadTxTemplate):
138-
reject_reason = 'bad-txns-in-belowout'
140+
reject_reason = 'bad-txns-in-ne-out'
141+
block_reject_reason = 'block-validation-failed'
139142
expect_disconnect = True
140143

141144
def get_tx(self):
@@ -159,7 +162,7 @@ class InvalidOPIFConstruction(BadTxTemplate):
159162
def get_tx(self):
160163
return create_tx_with_script(
161164
self.spend_tx, 0, script_sig=b'\x64' * 35,
162-
amount=(self.spend_avail // 2))
165+
amount=self.spend_avail)
163166

164167

165168
class TooManySigops(BadTxTemplate):
@@ -172,7 +175,7 @@ def get_tx(self):
172175
return create_tx_with_script(
173176
self.spend_tx, 0,
174177
script_pub_key=lotsa_checksigs,
175-
amount=1)
178+
amount=self.spend_avail)
176179

177180

178181
def iter_all_templates():

test/functional/feature_block_subsidy.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def run_test(self):
3737
# Block will have 10 satoshi output, node 1 will ban
3838
addr = self.nodes[0].getnewaddress()
3939
sub_block = self.nodes[0].generatetoaddress(1, addr)
40-
raw_coinbase = self.nodes[0].getrawtransaction(self.nodes[0].getblock(sub_block[0])["tx"][0])
40+
raw_coinbase = self.nodes[0].getrawtransaction(self.nodes[0].getblock(sub_block[0])["tx"][0], False, sub_block[0])
4141
decoded_coinbase = self.nodes[0].decoderawtransaction(raw_coinbase)
4242

4343
found_ten = False
@@ -53,13 +53,13 @@ def run_test(self):
5353

5454
# Block will have 0 satoshis outputs only at height 1
5555
no_sub_block = self.nodes[1].generatetoaddress(1, addr)
56-
raw_coinbase = self.nodes[1].getrawtransaction(self.nodes[1].getblock(no_sub_block[0])["tx"][0])
56+
raw_coinbase = self.nodes[1].getrawtransaction(self.nodes[1].getblock(no_sub_block[0])["tx"][0], False, no_sub_block[0])
5757
decoded_coinbase = self.nodes[1].decoderawtransaction(raw_coinbase)
5858
for vout in decoded_coinbase["vout"]:
5959
if vout["value"] != 0:
6060
raise Exception("Invalid output amount in coinbase")
6161

62-
tmpl = self.nodes[0].getblocktemplate()
62+
tmpl = self.nodes[0].getblocktemplate({"rules": ["segwit"]})
6363

6464
# Template with invalid amount(50*COIN) will be invalid in both
6565
coinbase_tx = create_coinbase(height=int(tmpl["height"]))

test/functional/feature_blocksdir.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def set_test_params(self):
1818

1919
def run_test(self):
2020
self.stop_node(0)
21-
assert os.path.isdir(os.path.join(self.nodes[0].datadir, "regtest", "blocks"))
21+
assert os.path.isdir(os.path.join(self.nodes[0].datadir, "elementsregtest", "blocks"))
2222
assert not os.path.isdir(os.path.join(self.nodes[0].datadir, "blocks"))
2323
shutil.rmtree(self.nodes[0].datadir)
2424
initialize_datadir(self.options.tmpdir, 0, self.chain)

test/functional/feature_confidential_transactions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ def run_test(self):
567567
stx = self.nodes[0].signrawtransactionwithwallet(stx2['hex'])
568568
txid = self.nodes[2].sendrawtransaction(stx['hex'])
569569
self.nodes[2].generate(1)
570-
assert self.nodes[2].getrawtransaction(txid, 1)['confirmations'] == 1
570+
assert self.nodes[2].gettransaction(txid)['confirmations'] == 1
571571
self.sync_all()
572572

573573
# Check that the sent asset has reached its destination

test/functional/feature_config_args.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ def test_config_file_parser(self):
4141
conf.write('server=1\nrpcuser=someuser\n[main]\nrpcpassword=some#pass')
4242
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')
4343

44-
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
45-
conf.write('testnot.datadir=1\n[testnet]\n')
46-
self.restart_node(0)
47-
self.nodes[0].stop_node(expected_stderr='Warning: Section [testnet] is not recognized.' + os.linesep + 'Warning: Section [testnot] is not recognized.')
44+
# ELEMENTS: allows custom chains
45+
#with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
46+
# conf.write('testnot.datadir=1\n[testnet]\n')
47+
#self.restart_node(0)
48+
#self.nodes[0].stop_node(expected_stderr='Warning: Section [testnet] is not recognized.' + os.linesep + 'Warning: Section [testnot] is not recognized.')
4849

4950
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
5051
conf.write('') # clear

test/functional/feature_connect_coinbase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def run_test(self):
5757

5858
# Issuance transaction is an OP_TRUE, so will be available to second node
5959
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)
60-
self.nodes[1].getrawtransaction(issuance_tx)
60+
self.nodes[1].getrawtransaction(issuance_tx, False, self.nodes[0].getblockhash(0))
6161

6262
if __name__ == '__main__':
6363
ConnectGenesisTest().main()

test/functional/feature_fedpeg.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def setup_network(self, split=False):
5454

5555
self.nodes = []
5656
# Setup parent nodes
57-
parent_chain = "parent" if not self.options.parent_bitcoin else "regtest"
57+
parent_chain = "elementsregtest" if not self.options.parent_bitcoin else "regtest"
5858
parent_binary = [self.options.parent_binpath] if self.options.parent_binpath != "" else None
5959
for n in range(2):
6060
extra_args = [
@@ -76,9 +76,8 @@ def setup_network(self, split=False):
7676
extra_args.extend([
7777
"-validatepegin=0",
7878
"-initialfreecoins=0",
79-
"-anyonecanspendaremine",
79+
"-anyonecanspendaremine=1",
8080
"-signblockscript=51", # OP_TRUE
81-
'-con_blocksubsidy=5000000000',
8281
])
8382

8483
self.add_nodes(1, [extra_args], chain=[parent_chain], binary=parent_binary, chain_in_args=[not self.options.parent_bitcoin])
@@ -101,17 +100,16 @@ def setup_network(self, split=False):
101100
"-printtoconsole=0",
102101
"-port="+str(p2p_port(2+n)),
103102
"-rpcport="+str(rpc_port(2+n)),
104-
'-parentgenesisblockhash=%s' % self.parentgenesisblockhash,
105103
'-validatepegin=1',
106104
'-fedpegscript=%s' % self.fedpeg_script,
107-
'-anyonecanspendaremine=0',
108105
'-minrelaytxfee=0',
109106
'-blockmintxfee=0',
110107
'-initialfreecoins=0',
111108
'-peginconfirmationdepth=10',
112109
'-mainchainrpchost=127.0.0.1',
113110
'-mainchainrpcport=%s' % rpc_port(n),
114111
'-recheckpeginblockinterval=15', # Long enough to allow failure and repair before timeout
112+
'-parentgenesisblockhash=%s' % self.parentgenesisblockhash,
115113
'-parentpubkeyprefix=111',
116114
'-parentscriptprefix=196',
117115
'-parent_bech32_hrp=bcrt',
@@ -142,7 +140,7 @@ def setup_network(self, split=False):
142140
datadir = get_datadir_path(self.options.tmpdir, n)
143141
extra_args.append('-mainchainrpccookiefile='+datadir+"/" + parent_chain + "/.cookie")
144142

145-
self.add_nodes(1, [extra_args], chain=["sidechain"])
143+
self.add_nodes(1, [extra_args], chain=["elementsregtest"])
146144
self.start_node(2+n)
147145
print("Node {} started".format(2+n))
148146

test/functional/feature_mandatory_coinbase.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def b2x(b):
2323
def assert_template(node, block, expect, rehash=True):
2424
if rehash:
2525
block.hashMerkleRoot = block.calc_merkle_root()
26-
rsp = node.getblocktemplate({'data': b2x(block.serialize()), 'mode': 'proposal'})
26+
rsp = node.getblocktemplate({'data': b2x(block.serialize()), 'mode': 'proposal', 'rules': 'segwit'})
2727
assert_equal(rsp, expect)
2828

2929
class MandatoryCoinbaseTest(BitcoinTestFramework):
@@ -51,7 +51,7 @@ def run_test(self):
5151

5252
# Have non-mandatory node make a template
5353
self.sync_all()
54-
tmpl = node1.getblocktemplate()
54+
tmpl = node1.getblocktemplate({'rules': ['segwit']})
5555

5656
# We make a block with OP_TRUE coinbase output that will fail on node0
5757
coinbase_tx = create_coinbase(height=int(tmpl["height"]))
@@ -86,7 +86,7 @@ def run_test(self):
8686
#
8787
# Also test that coinbases can't have fees.
8888
self.sync_all()
89-
tmpl = node1.getblocktemplate()
89+
tmpl = node1.getblocktemplate({'rules': ['segwit']})
9090
coinbase_tx = create_coinbase(height=int(tmpl["height"]))
9191
# sequence numbers must not be max for nLockTime to have effect
9292
coinbase_tx.vin[0].nSequence = 2 ** 32 - 2

0 commit comments

Comments
 (0)