Partial fix, still need investigation in wallet and block generator tests

Signed-off-by: Anthony Fieroni <bvbfan@abv.bg>
This commit is contained in:
Anthony Fieroni 2019-09-13 18:01:29 +03:00
parent 92a3df1571
commit 6697207ac1
9 changed files with 22 additions and 17 deletions

View file

@ -19,14 +19,14 @@ class TestBitcoinCli(BitcoinTestFramework):
"""Main test logic""" """Main test logic"""
cli_response = self.nodes[0].cli("-version").send_cli() cli_response = self.nodes[0].cli("-version").send_cli()
assert("Bitcoin Core RPC client version" in cli_response) assert("LBRYcrd Core RPC client version" in cli_response)
self.log.info("Compare responses from gewalletinfo RPC and `bitcoin-cli getwalletinfo`") self.log.info("Compare responses from gewalletinfo RPC and `lbrycrd-cli getwalletinfo`")
cli_response = self.nodes[0].cli.getwalletinfo() cli_response = self.nodes[0].cli.getwalletinfo()
rpc_response = self.nodes[0].getwalletinfo() rpc_response = self.nodes[0].getwalletinfo()
assert_equal(cli_response, rpc_response) assert_equal(cli_response, rpc_response)
self.log.info("Compare responses from getblockchaininfo RPC and `bitcoin-cli getblockchaininfo`") self.log.info("Compare responses from getblockchaininfo RPC and `lbrycrd-cli getblockchaininfo`")
cli_response = self.nodes[0].cli.getblockchaininfo() cli_response = self.nodes[0].cli.getblockchaininfo()
rpc_response = self.nodes[0].getblockchaininfo() rpc_response = self.nodes[0].getblockchaininfo()
assert_equal(cli_response, rpc_response) assert_equal(cli_response, rpc_response)

View file

@ -61,7 +61,7 @@ class RpcCreateMultiSigTest(BitcoinTestFramework):
madd = msig["address"] madd = msig["address"]
mredeem = msig["redeemScript"] mredeem = msig["redeemScript"]
if self.output_type == 'bech32': if self.output_type == 'bech32':
assert madd[0:4] == "bcrt" # actually a bech32 address assert madd[0:4] == "rlbc" # actually a bech32 address
# compare against addmultisigaddress # compare against addmultisigaddress
msigw = node1.addmultisigaddress(self.nsigs, self.pub, None, self.output_type) msigw = node1.addmultisigaddress(self.nsigs, self.pub, None, self.output_type)

View file

@ -22,7 +22,7 @@ class SignMessagesTest(BitcoinTestFramework):
self.log.info('test signing with priv_key') self.log.info('test signing with priv_key')
priv_key = 'cUeKHd5orzT3mz8P9pxyREHfsWtVfgsfDjiZZBcjUBAaGk1BTj7N' priv_key = 'cUeKHd5orzT3mz8P9pxyREHfsWtVfgsfDjiZZBcjUBAaGk1BTj7N'
address = 'mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB' address = 'mpLQjfK79b7CCV4VMJWEWAj5Mpx8Up5zxB'
expected_signature = 'INbVnW4e6PeRmsv2Qgu8NuopvrVjkcxob+sX8OcZG0SALhWybUjzMLPdAsXI46YZGb0KQTRii+wWIQzRpG/U+S0=' expected_signature = 'H4fEJyZBIV1i3E/oVyaf11SyA2Qufqe7WcyYQpaTW6xWZ7K0CWZX3Qx63cDxuM5kYXjg0vzzbkPWgAj5dONEDTc='
signature = self.nodes[0].signmessagewithprivkey(priv_key, message) signature = self.nodes[0].signmessagewithprivkey(priv_key, message)
assert_equal(expected_signature, signature) assert_equal(expected_signature, signature)
assert(self.nodes[0].verifymessage(address, signature, message)) assert(self.nodes[0].verifymessage(address, signature, message))

View file

@ -504,6 +504,7 @@ class CBlockHeader():
self.nVersion = header.nVersion self.nVersion = header.nVersion
self.hashPrevBlock = header.hashPrevBlock self.hashPrevBlock = header.hashPrevBlock
self.hashMerkleRoot = header.hashMerkleRoot self.hashMerkleRoot = header.hashMerkleRoot
self.hashClaimTrie = header.hashClaimTrie
self.nTime = header.nTime self.nTime = header.nTime
self.nBits = header.nBits self.nBits = header.nBits
self.nNonce = header.nNonce self.nNonce = header.nNonce
@ -515,6 +516,7 @@ class CBlockHeader():
self.nVersion = 1 self.nVersion = 1
self.hashPrevBlock = 0 self.hashPrevBlock = 0
self.hashMerkleRoot = 0 self.hashMerkleRoot = 0
self.hashClaimTrie = 1
self.nTime = 0 self.nTime = 0
self.nBits = 0 self.nBits = 0
self.nNonce = 0 self.nNonce = 0
@ -525,6 +527,7 @@ class CBlockHeader():
self.nVersion = struct.unpack("<i", f.read(4))[0] self.nVersion = struct.unpack("<i", f.read(4))[0]
self.hashPrevBlock = deser_uint256(f) self.hashPrevBlock = deser_uint256(f)
self.hashMerkleRoot = deser_uint256(f) self.hashMerkleRoot = deser_uint256(f)
self.hashClaimTrie = deser_uint256(f)
self.nTime = struct.unpack("<I", f.read(4))[0] self.nTime = struct.unpack("<I", f.read(4))[0]
self.nBits = struct.unpack("<I", f.read(4))[0] self.nBits = struct.unpack("<I", f.read(4))[0]
self.nNonce = struct.unpack("<I", f.read(4))[0] self.nNonce = struct.unpack("<I", f.read(4))[0]
@ -536,6 +539,7 @@ class CBlockHeader():
r += struct.pack("<i", self.nVersion) r += struct.pack("<i", self.nVersion)
r += ser_uint256(self.hashPrevBlock) r += ser_uint256(self.hashPrevBlock)
r += ser_uint256(self.hashMerkleRoot) r += ser_uint256(self.hashMerkleRoot)
r += ser_uint256(self.hashClaimTrie)
r += struct.pack("<I", self.nTime) r += struct.pack("<I", self.nTime)
r += struct.pack("<I", self.nBits) r += struct.pack("<I", self.nBits)
r += struct.pack("<I", self.nNonce) r += struct.pack("<I", self.nNonce)
@ -547,6 +551,7 @@ class CBlockHeader():
r += struct.pack("<i", self.nVersion) r += struct.pack("<i", self.nVersion)
r += ser_uint256(self.hashPrevBlock) r += ser_uint256(self.hashPrevBlock)
r += ser_uint256(self.hashMerkleRoot) r += ser_uint256(self.hashMerkleRoot)
r += ser_uint256(self.hashClaimTrie)
r += struct.pack("<I", self.nTime) r += struct.pack("<I", self.nTime)
r += struct.pack("<I", self.nBits) r += struct.pack("<I", self.nBits)
r += struct.pack("<I", self.nNonce) r += struct.pack("<I", self.nNonce)
@ -559,8 +564,8 @@ class CBlockHeader():
return self.sha256 return self.sha256
def __repr__(self): def __repr__(self):
return "CBlockHeader(nVersion=%i hashPrevBlock=%064x hashMerkleRoot=%064x nTime=%s nBits=%08x nNonce=%08x)" \ return "CBlockHeader(nVersion=%i hashPrevBlock=%064x hashMerkleRoot=%064x hashClaimTrie=%064x nTime=%s nBits=%08x nNonce=%08x)" \
% (self.nVersion, self.hashPrevBlock, self.hashMerkleRoot, % (self.nVersion, self.hashPrevBlock, self.hashMerkleRoot, self.hashClaimTrie,
time.ctime(self.nTime), self.nBits, self.nNonce) time.ctime(self.nTime), self.nBits, self.nNonce)

View file

@ -51,9 +51,9 @@ MESSAGEMAP = {
} }
MAGIC_BYTES = { MAGIC_BYTES = {
"mainnet": b"\xf9\xbe\xb4\xd9", # mainnet "mainnet": b"\xfa\xe4\xaa\xf1", # mainnet
"testnet3": b"\x0b\x11\x09\x07", # testnet3 "testnet3": b"\xfa\xe4\xaa\xe1", # testnet3
"regtest": b"\xfa\xbf\xb5\xda", # regtest "regtest": b"\xfa\xe4\xaa\xd1", # regtest
} }

View file

@ -138,7 +138,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read_file(open(self.options.configfile)) config.read_file(open(self.options.configfile))
self.options.lbrycrdd = os.getenv("LBRYCRDD", default=config["environment"]["BUILDDIR"] + '/src/lbrycrdd' + config["environment"]["EXEEXT"]) self.options.lbrycrdd = os.getenv("LBRYCRDD", default=config["environment"]["BUILDDIR"] + '/src/lbrycrdd' + config["environment"]["EXEEXT"])
self.options.bitcoincli = os.getenv("LBRYCRDCLI", default=config["environment"]["BUILDDIR"] + '/src/lbrycrd-cli' + config["environment"]["EXEEXT"]) self.options.lbrycrdcli = os.getenv("LBRYCRDCLI", default=config["environment"]["BUILDDIR"] + '/src/lbrycrd-cli' + config["environment"]["EXEEXT"])
os.environ['PATH'] = os.pathsep.join([ os.environ['PATH'] = os.pathsep.join([
os.path.join(config['environment']['BUILDDIR'], 'src'), os.path.join(config['environment']['BUILDDIR'], 'src'),
@ -293,7 +293,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
assert_equal(len(extra_args), num_nodes) assert_equal(len(extra_args), num_nodes)
assert_equal(len(binary), num_nodes) assert_equal(len(binary), num_nodes)
for i in range(num_nodes): for i in range(num_nodes):
self.nodes.append(TestNode(i, get_datadir_path(self.options.tmpdir, i), rpchost=rpchost, timewait=self.rpc_timewait, lbrycrdd=binary[i], bitcoin_cli=self.options.bitcoincli, mocktime=self.mocktime, coverage_dir=self.options.coveragedir, extra_conf=extra_confs[i], extra_args=extra_args[i], use_cli=self.options.usecli)) self.nodes.append(TestNode(i, get_datadir_path(self.options.tmpdir, i), rpchost=rpchost, timewait=self.rpc_timewait, lbrycrdd=binary[i], lbrycrd_cli=self.options.lbrycrdcli, mocktime=self.mocktime, coverage_dir=self.options.coveragedir, extra_conf=extra_confs[i], extra_args=extra_args[i], use_cli=self.options.usecli))
def start_node(self, i, *args, **kwargs): def start_node(self, i, *args, **kwargs):
"""Start a lbrycrdd""" """Start a lbrycrdd"""
@ -382,7 +382,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
For backward compatibility of the python scripts with previous For backward compatibility of the python scripts with previous
versions of the cache, this helper function sets mocktime to Jan 1, versions of the cache, this helper function sets mocktime to Jan 1,
2014 + (201 * 10 * 60)""" 2014 + (201 * 10 * 60)"""
self.mocktime = 1388534400 + (201 * 10 * 60) + 86400 * 365 * 7 self.mocktime = 1451606400 + (201 * 10 * 60)
def disable_mocktime(self): def disable_mocktime(self):
self.mocktime = 0 self.mocktime = 0
@ -444,7 +444,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
args = [self.options.lbrycrdd, "-datadir=" + datadir, '-disablewallet'] args = [self.options.lbrycrdd, "-datadir=" + datadir, '-disablewallet']
if i > 0: if i > 0:
args.append("-connect=127.0.0.1:" + str(p2p_port(0))) args.append("-connect=127.0.0.1:" + str(p2p_port(0)))
self.nodes.append(TestNode(i, get_datadir_path(self.options.cachedir, i), extra_conf=["bind=127.0.0.1"], extra_args=[], rpchost=None, timewait=self.rpc_timewait, lbrycrdd=self.options.lbrycrdd, bitcoin_cli=self.options.bitcoincli, mocktime=self.mocktime, coverage_dir=None)) self.nodes.append(TestNode(i, get_datadir_path(self.options.cachedir, i), extra_conf=["bind=127.0.0.1"], extra_args=[], rpchost=None, timewait=self.rpc_timewait, lbrycrdd=self.options.lbrycrdd, lbrycrd_cli=self.options.lbrycrdcli, mocktime=self.mocktime, coverage_dir=None))
self.nodes[i].args = args self.nodes[i].args = args
self.start_node(i) self.start_node(i)
@ -481,7 +481,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
for i in range(MAX_NODES): for i in range(MAX_NODES):
os.rmdir(cache_path(i, 'wallets')) # Remove empty wallets dir os.rmdir(cache_path(i, 'wallets')) # Remove empty wallets dir
for entry in os.listdir(cache_path(i)): for entry in os.listdir(cache_path(i)):
if entry not in ['chainstate', 'blocks']: if entry not in ['chainstate', 'blocks', 'claimtrie']:
os.remove(cache_path(i, entry)) os.remove(cache_path(i, entry))
for i in range(self.num_nodes): for i in range(self.num_nodes):

4
test/functional/test_framework/test_node.py Executable file → Normal file
View file

@ -58,7 +58,7 @@ class TestNode():
To make things easier for the test writer, any unrecognised messages will To make things easier for the test writer, any unrecognised messages will
be dispatched to the RPC connection.""" be dispatched to the RPC connection."""
def __init__(self, i, datadir, *, rpchost, timewait, lbrycrdd, bitcoin_cli, mocktime, coverage_dir, extra_conf=None, extra_args=None, use_cli=False): def __init__(self, i, datadir, *, rpchost, timewait, lbrycrdd, lbrycrd_cli, mocktime, coverage_dir, extra_conf=None, extra_args=None, use_cli=False):
self.index = i self.index = i
self.datadir = datadir self.datadir = datadir
self.stdout_dir = os.path.join(self.datadir, "stdout") self.stdout_dir = os.path.join(self.datadir, "stdout")
@ -84,7 +84,7 @@ class TestNode():
"-uacomment=testnode%d" % i "-uacomment=testnode%d" % i
] ]
self.cli = TestNodeCLI(bitcoin_cli, self.datadir) self.cli = TestNodeCLI(lbrycrd_cli, self.datadir)
self.use_cli = use_cli self.use_cli = use_cli
self.running = False self.running = False

0
test/functional/wallet_backup.py Executable file → Normal file
View file

0
test/functional/wallet_hd.py Executable file → Normal file
View file