mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-13 12:33:42 +02:00
Merge pull request #1421 from psgreco/master-fixlock
Fix tests and build warnings
This commit is contained in:
commit
7ed2768dca
7 changed files with 59 additions and 40 deletions
|
|
@ -57,9 +57,9 @@
|
|||
<Target Name="AfterBuild">
|
||||
<Copy SourceFiles="$(ConfigIniIn)" DestinationFiles="$(ConfigIniOut)" ></Copy>
|
||||
<ReplaceInFile FilePath="$(ConfigIniOut)"
|
||||
Replace="@PACKAGE_NAME@" By="Bitcoin Core"></ReplaceInFile>
|
||||
Replace="@PACKAGE_NAME@" By="Elements Core"></ReplaceInFile>
|
||||
<ReplaceInFile FilePath="$(ConfigIniOut)"
|
||||
Replace="@PACKAGE_BUGREPORT@" By="https://github.com/bitcoin/bitcoin/issues"></ReplaceInFile>
|
||||
Replace="@PACKAGE_BUGREPORT@" By="https://github.com/ElementsProject/elements/issues"></ReplaceInFile>
|
||||
<ReplaceInFile FilePath="$(ConfigIniOut)"
|
||||
Replace="@abs_top_srcdir@" By="..\.." ToFullPath="true"></ReplaceInFile>
|
||||
<ReplaceInFile FilePath="$(ConfigIniOut)"
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ static bool CheckProofGeneric(const CBlockHeader& block, const uint32_t max_bloc
|
|||
| SCRIPT_VERIFY_SIGPUSHONLY // Witness is push-only
|
||||
| SCRIPT_VERIFY_LOW_S // Stop easiest signature fiddling
|
||||
| SCRIPT_VERIFY_WITNESS // Witness and to enforce cleanstack
|
||||
| (is_dyna ? 0 : SCRIPT_NO_SIGHASH_BYTE); // Non-dynafed blocks do not have sighash byte
|
||||
| (is_dyna ? SCRIPT_VERIFY_NONE : SCRIPT_NO_SIGHASH_BYTE); // Non-dynafed blocks do not have sighash byte
|
||||
return GenericVerifyScript(scriptSig, witness, challenge, proof_flags, block);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2122,29 +2122,30 @@ void PeerManagerImpl::ProcessHeadersMessage(CNode& pfrom, const Peer& peer,
|
|||
// If we are already too far ahead of where we want to be on headers, discard
|
||||
// the received headers. We can still get ahead by up to a single maximum-sized
|
||||
// headers message here, but never further, so that's fine.
|
||||
if (pindexBestHeader) {
|
||||
int64_t headers_ahead = pindexBestHeader->nHeight - m_chainman.ActiveHeight();
|
||||
bool too_far_ahead = node::fTrimHeaders && (headers_ahead >= node::nHeaderDownloadBuffer);
|
||||
if (too_far_ahead) {
|
||||
LOCK(cs_main);
|
||||
CNodeState *nodestate = State(pfrom.GetId());
|
||||
if ((nodestate->pindexBestKnownBlock == nullptr) ||
|
||||
if (node::fTrimHeaders) {
|
||||
LOCK(cs_main);
|
||||
if (pindexBestHeader) {
|
||||
int64_t headers_ahead = pindexBestHeader->nHeight - m_chainman.ActiveHeight();
|
||||
if (headers_ahead >= node::nHeaderDownloadBuffer) {
|
||||
CNodeState *nodestate = State(pfrom.GetId());
|
||||
if ((nodestate->pindexBestKnownBlock == nullptr) ||
|
||||
(nodestate->pindexBestKnownBlock->nHeight < m_chainman.ActiveHeight())) {
|
||||
// Our notion of what blocks a peer has available is based on its pindexBestKnownBlock,
|
||||
// which is based on headers received from it. If we don't have one, or it's too old,
|
||||
// then we can never get blocks from this peer until we accept headers from it first.
|
||||
LogPrint(BCLog::NET, "NOT discarding headers from peer=%d, to update its block availability. (current best header %d, active chain height %d)\n", pfrom.GetId(), pindexBestHeader->nHeight, m_chainman.ActiveHeight());
|
||||
} else {
|
||||
LogPrint(BCLog::NET, "Discarding received headers and pausing header sync from peer=%d, because we are too far ahead of block sync. (%d > %d)\n", pfrom.GetId(), pindexBestHeader->nHeight, m_chainman.ActiveHeight());
|
||||
if (nodestate->fSyncStarted) {
|
||||
// Cancel sync from this node, so we don't penalize it later.
|
||||
// This will cause us to automatically start syncing from a different node (or restart syncing from the same node) later,
|
||||
// if we still need to sync headers.
|
||||
nSyncStarted--;
|
||||
nodestate->fSyncStarted = false;
|
||||
nodestate->m_headers_sync_timeout = 0us;
|
||||
// Our notion of what blocks a peer has available is based on its pindexBestKnownBlock,
|
||||
// which is based on headers received from it. If we don't have one, or it's too old,
|
||||
// then we can never get blocks from this peer until we accept headers from it first.
|
||||
LogPrint(BCLog::NET, "NOT discarding headers from peer=%d, to update its block availability. (current best header %d, active chain height %d)\n", pfrom.GetId(), pindexBestHeader->nHeight, m_chainman.ActiveHeight());
|
||||
} else {
|
||||
LogPrint(BCLog::NET, "Discarding received headers and pausing header sync from peer=%d, because we are too far ahead of block sync. (%d > %d)\n", pfrom.GetId(), pindexBestHeader->nHeight, m_chainman.ActiveHeight());
|
||||
if (nodestate->fSyncStarted) {
|
||||
// Cancel sync from this node, so we don't penalize it later.
|
||||
// This will cause us to automatically start syncing from a different node (or restart syncing from the same node) later,
|
||||
// if we still need to sync headers.
|
||||
nSyncStarted--;
|
||||
nodestate->fSyncStarted = false;
|
||||
nodestate->m_headers_sync_timeout = 0us;
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,7 +139,10 @@ static fs::path GetMainchainAuthCookieFile()
|
|||
if (gArgs.GetChainName() == "liquidv1") {
|
||||
cookie_file = ".cookie";
|
||||
}
|
||||
return fsbridge::AbsPathJoin(GetMainchainDefaultDataDir(), fs::PathFromString(gArgs.GetArg("-mainchainrpccookiefile", cookie_file)));
|
||||
fs::path cookie_path = fs::PathFromString(gArgs.GetArg("-mainchainrpccookiefile", cookie_file));
|
||||
if (cookie_path.is_absolute())
|
||||
return cookie_path;
|
||||
return fsbridge::AbsPathJoin(GetMainchainDefaultDataDir(), cookie_path);
|
||||
}
|
||||
|
||||
bool GetMainchainAuthCookie(std::string *cookie_out)
|
||||
|
|
@ -148,7 +151,7 @@ bool GetMainchainAuthCookie(std::string *cookie_out)
|
|||
std::string cookie;
|
||||
|
||||
std::filesystem::path filepath = GetMainchainAuthCookieFile();
|
||||
file.open(filepath.string().c_str());
|
||||
file.open(filepath);
|
||||
if (!file.is_open())
|
||||
return false;
|
||||
std::getline(file, cookie);
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ from test_framework.util import (
|
|||
)
|
||||
import os
|
||||
import re
|
||||
import tempfile
|
||||
|
||||
from test_framework.liquid_addr import (
|
||||
encode,
|
||||
|
|
@ -51,7 +52,7 @@ class CTTest (BitcoinTestFramework):
|
|||
self.skip_if_no_wallet()
|
||||
|
||||
def test_wallet_recovery(self):
|
||||
file_path = "/tmp/blind_details"
|
||||
file_path = os.path.join(tempfile.gettempdir(), "blind_details")
|
||||
try:
|
||||
os.remove(file_path)
|
||||
except OSError:
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
from decimal import Decimal
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
assert_approx,
|
||||
assert_equal,
|
||||
)
|
||||
|
||||
|
|
@ -80,10 +81,12 @@ class CTTest(BitcoinTestFramework):
|
|||
assert_equal(len(vout), 3)
|
||||
assert_equal(tx['fee']['bitcoin'], Decimal('-0.00000326'))
|
||||
assert_equal(decoded['vsize'], 326)
|
||||
assert_equal(decoded['weight'], 1302)
|
||||
# tx weight can be 1301 or 1302, accept both
|
||||
assert_approx(decoded['weight'], 1301.5, 0.5)
|
||||
self.generate(node0, 1)
|
||||
tx = node1.getrawtransaction(txid, True)
|
||||
assert_equal(tx['discountweight'], 1302)
|
||||
# tx discountweight can be 1301 or 1302, accept both
|
||||
assert_approx(tx['discountweight'], 1301.5, 0.5)
|
||||
assert_equal(tx['discountvsize'], 326)
|
||||
|
||||
self.log.info("Send confidential tx to node 0")
|
||||
|
|
@ -98,10 +101,12 @@ class CTTest(BitcoinTestFramework):
|
|||
assert_equal(len(vout), 3)
|
||||
assert_equal(tx['fee']['bitcoin'], Decimal('-0.00002575'))
|
||||
assert_equal(decoded['vsize'], 2575)
|
||||
assert_equal(decoded['weight'], 10300)
|
||||
# tx weight can be 10299 or 10300, accept both
|
||||
assert_approx(decoded['weight'], 10299.5, 0.5)
|
||||
self.generate(node0, 1)
|
||||
tx = node1.getrawtransaction(txid, True)
|
||||
assert_equal(tx['discountweight'], 1302)
|
||||
# tx discountweight can be 1301 or 1302, accept both
|
||||
assert_approx(tx['discountweight'], 1301.5, 0.5)
|
||||
assert_equal(tx['discountvsize'], 326) # node1 has discountvsize
|
||||
|
||||
self.log.info("Send explicit tx to node 1")
|
||||
|
|
@ -116,10 +121,12 @@ class CTTest(BitcoinTestFramework):
|
|||
assert_equal(len(vout), 3)
|
||||
assert_equal(tx['fee']['bitcoin'], Decimal('-0.00000326'))
|
||||
assert_equal(decoded['vsize'], 326)
|
||||
assert_equal(decoded['weight'], 1302)
|
||||
# tx weight can be 1301 or 1302, accept both
|
||||
assert_approx(decoded['weight'], 1301.5, 0.5)
|
||||
self.generate(node0, 1)
|
||||
tx = node1.getrawtransaction(txid, True)
|
||||
assert_equal(tx['discountweight'], 1302)
|
||||
# tx weight can be 1301 or 1302, accept both
|
||||
assert_approx(tx['discountweight'], 1301.5, 0.5)
|
||||
assert_equal(tx['discountvsize'], 326)
|
||||
|
||||
self.log.info("Send confidential (undiscounted) tx to node 1")
|
||||
|
|
@ -134,10 +141,12 @@ class CTTest(BitcoinTestFramework):
|
|||
assert_equal(len(vout), 3)
|
||||
assert_equal(tx['fee']['bitcoin'], Decimal('-0.00002575'))
|
||||
assert_equal(decoded['vsize'], 2575)
|
||||
assert_equal(decoded['weight'], 10300)
|
||||
# tx weight can be 10299 or 10300, accept both
|
||||
assert_approx(decoded['weight'], 10299.5, 0.5)
|
||||
self.generate(node0, 1)
|
||||
tx = node1.getrawtransaction(txid, True)
|
||||
assert_equal(tx['discountweight'], 1302)
|
||||
# tx discountweight can be 1301 or 1302, accept both
|
||||
assert_approx(tx['discountweight'], 1301.5, 0.5)
|
||||
assert_equal(tx['discountvsize'], 326) # node1 has discountvsize
|
||||
|
||||
self.log.info("Send confidential (discounted) tx to node 1")
|
||||
|
|
@ -161,8 +170,10 @@ class CTTest(BitcoinTestFramework):
|
|||
else:
|
||||
assert_equal(decoded['fee'][bitcoin], Decimal('0.00000326'))
|
||||
assert_equal(decoded['vsize'], 2575)
|
||||
assert_equal(decoded['weight'], 10300)
|
||||
assert_equal(decoded['discountweight'], 1302)
|
||||
# tx weight can be 10299 or 10300, accept both
|
||||
assert_approx(decoded['weight'], 10299.5, 0.5)
|
||||
# tx discountweight can be 1301 or 1302, accept both
|
||||
assert_approx(decoded['discountweight'], 1301.5, 0.5)
|
||||
assert_equal(decoded['discountvsize'], 326)
|
||||
|
||||
# node0 only has vsize
|
||||
|
|
@ -191,8 +202,10 @@ class CTTest(BitcoinTestFramework):
|
|||
else:
|
||||
assert_equal(decoded['fee'][bitcoin], Decimal('0.00000033'))
|
||||
assert_equal(decoded['vsize'], 2575)
|
||||
assert_equal(decoded['weight'], 10300)
|
||||
assert_equal(decoded['discountweight'], 1302)
|
||||
# tx weight can be 10299 or 10300, accept both
|
||||
assert_approx(decoded['weight'], 10299.5, 0.5)
|
||||
# tx discountweight can be 1301 or 1302, accept both
|
||||
assert_approx(decoded['discountweight'], 1301.5, 0.5)
|
||||
assert_equal(decoded['discountvsize'], 326)
|
||||
# node0 only has vsize
|
||||
tx = node0.getrawtransaction(txid, True)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import time
|
||||
import os
|
||||
|
||||
from test_framework.authproxy import JSONRPCException
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
|
|
@ -152,7 +153,7 @@ class FedPegTest(BitcoinTestFramework):
|
|||
else:
|
||||
# Need to specify where to find parent cookie file
|
||||
datadir = get_datadir_path(self.options.tmpdir, n)
|
||||
extra_args.append('-mainchainrpccookiefile='+datadir+"/" + parent_chain + "/.cookie")
|
||||
extra_args.append('-mainchainrpccookiefile='+os.path.join(datadir, parent_chain, ".cookie"))
|
||||
|
||||
self.add_nodes(1, [extra_args], chain=["elementsregtest"])
|
||||
self.start_node(2+n)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue