Litecoin: Functional tests

This commit is contained in:
Adrian Gallagher 2020-12-10 18:58:37 -08:00
parent 847a5188e6
commit 86fe3c68b8
No known key found for this signature in database
GPG Key ID: FE3348877809386C
9 changed files with 34 additions and 38 deletions

View File

@ -9,7 +9,7 @@
"02ff12471208c14bd580709cb2358d98975247d8765f92bc25eab3b2763ed605f8"
],
"script": "522102fe6f0a5a297eb38c391581c4413e084773ea23954d93f7753db7dc0adc188b2f2102ff12471208c14bd580709cb2358d98975247d8765f92bc25eab3b2763ed605f852ae",
"address": "2N19tNw3Ss4L9QDERtCw7FhXb6jBsYmeXNu"
"address": "QUWeVwugtAPEYPzUWJy8LPy2F7dhU4bP2g"
},
{
"keys": [
@ -23,7 +23,7 @@
"02e2cc6bd5f45edd43bebe7cb9b675f0ce9ed3efe613b177588290ad188d11b404"
],
"script": "522102632b12f4ac5b1d1b72b2a3b508c19172de44f6f46bcee50ba33f3f9291e47ed021027735a29bae7780a9755fae7a1c4374c656ac6a69ea9f3697fda61bb99a4f3e772102e2cc6bd5f45edd43bebe7cb9b675f0ce9ed3efe613b177588290ad188d11b40453ae",
"address": "2N3sVXU7MZefmYnZhrVX2bA7LyH6vygFZZ7"
"address": "QXEFeUybakirgyKkUbZ3frYn7fYkqZKTdp"
},
{
"keys": [
@ -39,7 +39,7 @@
"030000000000000000000000000000000000004141414141414141414141414141"
],
"script": "522102000000000000000000000000000000000000414141414141414141414141414021020000000000000000000000000000000000004141414141414141414141414141210300000000000000000000000000000000000041414141414141414141414141402103000000000000000000000000000000000000414141414141414141414141414154ae",
"address": "2Mt3L9TcDUAfLpSoyB3SNYtJGLiU49DKEWJ"
"address": "QMQ6GUUTVGiRxda1o9UPdajhV6ut2DvWTq"
},
{
"keys": [
@ -53,6 +53,6 @@
"03e3818b65bcc73a7d64064106a859cc1a5a728c4345ff0b641209fba0d90de6e9"
],
"script": "5221021f2f6e1e50cb6a953935c3601284925decd3fd21bc445712576873fb8c6ebc1821022df8750480ad5b26950b25c7ba79d3e37d75f640f8e5d9bcd5b150a0f85014da2103e3818b65bcc73a7d64064106a859cc1a5a728c4345ff0b641209fba0d90de6e953ae",
"address": "2NFd5JqpwmQNz3gevZJ3rz9ofuHvqaP9Cye"
"address": "QiyqRrhBnWS5BsQyBQ5t4rF73gNfT9oGMw"
}
]

View File

@ -1338,13 +1338,12 @@ class FullBlockTest(BitcoinTestFramework):
coinbase = create_coinbase(height, self.coinbase_pubkey)
coinbase.vout[0].nValue += additional_coinbase_value
coinbase.rehash()
blockversion = 0x20000000
if spend is None:
block = create_block(base_block_hash, coinbase, block_time, version=blockversion)
block = create_block(base_block_hash, coinbase, block_time, version=version)
else:
coinbase.vout[0].nValue += spend.vout[0].nValue - 1 # all but one satoshi to fees
coinbase.rehash()
block = create_block(base_block_hash, coinbase, block_time, version=blockversion)
block = create_block(base_block_hash, coinbase, block_time, version=version)
tx = self.create_tx(spend, 0, 1, script) # spend 1 satoshi
self.sign_tx(tx, spend)
self.add_transactions_to_block(block, [tx])

View File

@ -171,7 +171,7 @@ class BIP68_112_113Test(BitcoinTestFramework):
def create_test_block(self, txs):
block = create_block(self.tip, create_coinbase(self.tipheight + 1), self.last_block_time + 600)
block.nVersion = 4
block.nVersion = 0x20000000
block.vtx.extend(txs)
block.hashMerkleRoot = block.calc_merkle_root()
block.rehash()
@ -245,7 +245,7 @@ class BIP68_112_113Test(BitcoinTestFramework):
assert_equal(len(self.nodes[0].getblock(inputblockhash, True)["tx"]), TESTING_TX_COUNT + 1)
# 2 more version 4 blocks
test_blocks = self.generate_blocks(2, 0x20000000)
test_blocks = self.generate_blocks(2)
self.send_blocks(test_blocks)
assert_equal(self.tipheight, CSV_ACTIVATION_HEIGHT - 2)
@ -354,7 +354,7 @@ class BIP68_112_113Test(BitcoinTestFramework):
self.nodes[0].invalidateblock(self.nodes[0].getbestblockhash())
# Next block height = 437 after 4 blocks of random version
test_blocks = self.generate_blocks(4, 0x20000000)
test_blocks = self.generate_blocks(4)
self.send_blocks(test_blocks)
self.log.info("BIP 68 tests")
@ -382,7 +382,7 @@ class BIP68_112_113Test(BitcoinTestFramework):
self.send_blocks([self.create_test_block([tx])], success=False, reject_reason='bad-txns-nonfinal')
# Advance one block to 438
test_blocks = self.generate_blocks(1, 0x20000000)
test_blocks = self.generate_blocks(1)
self.send_blocks(test_blocks)
# Height txs should fail and time txs should now pass 9 * 600 > 10 * 512
@ -393,7 +393,7 @@ class BIP68_112_113Test(BitcoinTestFramework):
self.send_blocks([self.create_test_block([tx])], success=False, reject_reason='bad-txns-nonfinal')
# Advance one block to 439
test_blocks = self.generate_blocks(1, 0x20000000)
test_blocks = self.generate_blocks(1)
self.send_blocks(test_blocks)
# All BIP 68 txs should pass

View File

@ -55,7 +55,7 @@ class P2PEvict(BitcoinTestFramework):
best_block = node.getbestblockhash()
tip = int(best_block, 16)
best_block_time = node.getblock(best_block)['time']
block = create_block(tip, create_coinbase(node.getblockcount() + 1), best_block_time + 1)
block = create_block(tip, create_coinbase(node.getblockcount() + 1), best_block_time + 1, version=0x20000000)
block.solve()
block_peer.send_blocks_and_test([block], node, success=True)
protected_peers.add(current_peer)

View File

@ -37,8 +37,7 @@ class InvalidBlockRequestTest(BitcoinTestFramework):
self.log.info("Create a new block with an anyone-can-spend coinbase")
height = 1
block = create_block(tip, create_coinbase(height), block_time)
block.nVersion = 0x20000000
block = create_block(tip, create_coinbase(height), block_time, version=0x20000000)
block.solve()
# Save the coinbase for later
block1 = block
@ -61,8 +60,7 @@ class InvalidBlockRequestTest(BitcoinTestFramework):
# For more information on merkle-root malleability see src/consensus/merkle.cpp.
self.log.info("Test merkle root malleability.")
block2 = create_block(tip, create_coinbase(height), block_time)
block2.nVersion = 0x20000000
block2 = create_block(tip, create_coinbase(height), block_time, version=0x20000000)
block_time += 1
# b'0x51' is OP_TRUE
@ -97,8 +95,7 @@ class InvalidBlockRequestTest(BitcoinTestFramework):
self.log.info("Test very broken block.")
block3 = create_block(tip, create_coinbase(height), block_time)
block3.nVersion = 0x20000000
block3 = create_block(tip, create_coinbase(height), block_time, version=0x20000000)
block_time += 1
block3.vtx[0].vout[0].nValue = 100 * COIN # Too high!
block3.vtx[0].sha256 = None
@ -123,7 +120,7 @@ class InvalidBlockRequestTest(BitcoinTestFramework):
# Complete testing of CVE-2018-17144, by checking for the inflation bug.
# Create a block that spends the output of a tx in a previous block.
block4 = create_block(tip, create_coinbase(height), block_time)
block4 = create_block(tip, create_coinbase(height), block_time, version=0x20000000)
tx3 = create_tx_with_script(tx2, 0, script_sig=b'\x51', amount=50 * COIN)
# Duplicates input

View File

@ -37,7 +37,7 @@ class GenerateBlockTest(BitcoinTestFramework):
self.log.info('Generate an empty block to a combo descriptor with compressed pubkey')
combo_key = '0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798'
combo_address = 'bcrt1qw508d6qejxtdg4y5r3zarvary0c5xw7kygt080'
combo_address = 'rltc1qw508d6qejxtdg4y5r3zarvary0c5xw7k693xs3'
hash = node.generateblock('combo(' + combo_key + ')', [])['hash']
block = node.getblock(hash, 2)
assert_equal(len(block['tx']), 1)

View File

@ -183,8 +183,8 @@ class ImportDescriptorsTest(BitcoinTestFramework):
# # Test ranged descriptors
xpriv = "tprv8ZgxMBicQKsPeuVhWwi6wuMQGfPKi9Li5GtX35jVNknACgqe3CY4g5xgkfDDJcmtF7o1QnxWDRYw4H5P26PXq7sbcUkEqeR4fg3Kxp2tigg"
xpub = "tpubD6NzVbkrYhZ4YNXVQbNhMK1WqguFsUXceaVJKbmno2aZ3B6QfbMeraaYvnBSGpV3vxLyTTK9DYT1yoEck4XUScMzXoQ2U2oSmE2JyMedq3H"
addresses = ["2N7yv4p8G8yEaPddJxY41kPihnWvs39qCMf", "2MsHxyb2JS3pAySeNUsJ7mNnurtpeenDzLA"] # hdkeypath=m/0'/0'/0' and 1'
addresses += ["bcrt1qrd3n235cj2czsfmsuvqqpr3lu6lg0ju7scl8gn", "bcrt1qfqeppuvj0ww98r6qghmdkj70tv8qpchehegrg8"] # wpkh subscripts corresponding to the above addresses
addresses = ["QbLgBpzWA5HfXpPMae62q6A8vuNgxHqXbU", "QLej6btYT9sG7dQR6yL8r5EM1HGUaDYa2F"] # hdkeypath=m/0'/0'/0' and 1'
addresses += ["rltc1qrd3n235cj2czsfmsuvqqpr3lu6lg0ju7w49wld", "rltc1qfqeppuvj0ww98r6qghmdkj70tv8qpchef5j2le"] # wpkh subscripts corresponding to the above addresses
desc = "sh(wpkh(" + xpub + "/0/0/*" + "))"
self.log.info("Ranged descriptors cannot have labels")
@ -256,11 +256,11 @@ class ImportDescriptorsTest(BitcoinTestFramework):
self.log.info('Key ranges should be imported in order')
xpub = "tpubDAXcJ7s7ZwicqjprRaEWdPoHKrCS215qxGYxpusRLLmJuT69ZSicuGdSfyvyKpvUNYBW1s2U3NSrT6vrCYB9e6nZUEvrqnwXPF8ArTCRXMY"
addresses = [
'bcrt1qtmp74ayg7p24uslctssvjm06q5phz4yrxucgnv', # m/0'/0'/0
'bcrt1q8vprchan07gzagd5e6v9wd7azyucksq2xc76k8', # m/0'/0'/1
'bcrt1qtuqdtha7zmqgcrr26n2rqxztv5y8rafjp9lulu', # m/0'/0'/2
'bcrt1qau64272ymawq26t90md6an0ps99qkrse58m640', # m/0'/0'/3
'bcrt1qsg97266hrh6cpmutqen8s4s962aryy77jp0fg0', # m/0'/0'/4
'rltc1qtmp74ayg7p24uslctssvjm06q5phz4yrc3zpyj', # m/0'/0'/0
'rltc1q8vprchan07gzagd5e6v9wd7azyucksq2c4ynpe', # m/0'/0'/1
'rltc1qtuqdtha7zmqgcrr26n2rqxztv5y8rafjlg94gz', # m/0'/0'/2
'rltc1qau64272ymawq26t90md6an0ps99qkrse22pnz3', # m/0'/0'/3
'rltc1qsg97266hrh6cpmutqen8s4s962aryy77vv4ql3', # m/0'/0'/4
]
self.test_importdesc({'desc': descsum_create('wpkh([80002067/0h/0h]' + xpub + '/*)'),
@ -356,9 +356,9 @@ class ImportDescriptorsTest(BitcoinTestFramework):
assert_equal(wmulti_priv.getwalletinfo()['keypoolsize'], 1001) # Range end (1000) is inclusive, so 1001 addresses generated
addr = wmulti_priv.getnewaddress('', 'bech32')
assert_equal(addr, 'bcrt1qdt0qy5p7dzhxzmegnn4ulzhard33s2809arjqgjndx87rv5vd0fq2czhy8') # Derived at m/84'/0'/0'/0
assert_equal(addr, 'rltc1qdt0qy5p7dzhxzmegnn4ulzhard33s2809arjqgjndx87rv5vd0fqzmggt2') # Derived at m/84'/0'/0'/0
change_addr = wmulti_priv.getrawchangeaddress('bech32')
assert_equal(change_addr, 'bcrt1qt9uhe3a9hnq7vajl7a094z4s3crm9ttf8zw3f5v9gr2nyd7e3lnsy44n8e')
assert_equal(change_addr, 'rltc1qt9uhe3a9hnq7vajl7a094z4s3crm9ttf8zw3f5v9gr2nyd7e3lnsvklvg5')
assert_equal(wmulti_priv.getwalletinfo()['keypoolsize'], 1000)
txid = w0.sendtoaddress(addr, 10)
self.nodes[0].generate(6)
@ -391,9 +391,9 @@ class ImportDescriptorsTest(BitcoinTestFramework):
assert_equal(wmulti_pub.getwalletinfo()['keypoolsize'], 1000) # The first one was already consumed by previous import and is detected as used
addr = wmulti_pub.getnewaddress('', 'bech32')
assert_equal(addr, 'bcrt1qp8s25ckjl7gr6x2q3dx3tn2pytwp05upkjztk6ey857tt50r5aeqn6mvr9') # Derived at m/84'/0'/0'/1
assert_equal(addr, 'rltc1qp8s25ckjl7gr6x2q3dx3tn2pytwp05upkjztk6ey857tt50r5aeqme3nvg') # Derived at m/84'/0'/0'/1
change_addr = wmulti_pub.getrawchangeaddress('bech32')
assert_equal(change_addr, 'bcrt1qt9uhe3a9hnq7vajl7a094z4s3crm9ttf8zw3f5v9gr2nyd7e3lnsy44n8e')
assert_equal(change_addr, 'rltc1qt9uhe3a9hnq7vajl7a094z4s3crm9ttf8zw3f5v9gr2nyd7e3lnsvklvg5')
assert_equal(wmulti_pub.getwalletinfo()['keypoolsize'], 999)
txid = w0.sendtoaddress(addr, 10)
vout = find_vout_for_address(self.nodes[0], txid, addr)

View File

@ -579,8 +579,8 @@ class ImportMultiTest(BitcoinTestFramework):
# Test ranged descriptor fails if range is not specified
xpriv = "tprv8ZgxMBicQKsPeuVhWwi6wuMQGfPKi9Li5GtX35jVNknACgqe3CY4g5xgkfDDJcmtF7o1QnxWDRYw4H5P26PXq7sbcUkEqeR4fg3Kxp2tigg"
addresses = ["2N7yv4p8G8yEaPddJxY41kPihnWvs39qCMf", "2MsHxyb2JS3pAySeNUsJ7mNnurtpeenDzLA"] # hdkeypath=m/0'/0'/0' and 1'
addresses += ["bcrt1qrd3n235cj2czsfmsuvqqpr3lu6lg0ju7scl8gn", "bcrt1qfqeppuvj0ww98r6qghmdkj70tv8qpchehegrg8"] # wpkh subscripts corresponding to the above addresses
addresses = ["QbLgBpzWA5HfXpPMae62q6A8vuNgxHqXbU", "QLej6btYT9sG7dQR6yL8r5EM1HGUaDYa2F"] # hdkeypath=m/0'/0'/0' and 1'
addresses += ["rltc1qrd3n235cj2czsfmsuvqqpr3lu6lg0ju7w49wld", "rltc1qfqeppuvj0ww98r6qghmdkj70tv8qpchef5j2le"] # wpkh subscripts corresponding to the above addresses
desc = "sh(wpkh(" + xpriv + "/0'/0'/*'" + "))"
self.log.info("Ranged descriptor import should fail without a specified range")
self.test_importmulti({"desc": descsum_create(desc),

View File

@ -138,9 +138,9 @@ class WalletLabelsTest(BitcoinTestFramework):
node.createwallet(wallet_name='watch_only', disable_private_keys=True)
wallet_watch_only = node.get_wallet_rpc('watch_only')
BECH32_VALID = {
'_VER15_PROG40': 'bcrt10qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqxkg7fn',
'_VER16_PROG03': 'bcrt1sqqqqq8uhdgr',
'_VER16_PROB02': 'bcrt1sqqqq4wstyw',
'_VER15_PROG40': 'rltc10qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqvs3zqy',
'_VER16_PROG03': 'rltc1sqqqqqgayys4',
'_VER16_PROB02': 'rltc1sqqqquvz2k4',
}
BECH32_INVALID = {
'❌_VER15_PROG41': 'bcrt1sqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqajlxj8',
@ -156,7 +156,7 @@ class WalletLabelsTest(BitcoinTestFramework):
ad = BECH32_INVALID[l]
assert_raises_rpc_error(
-5,
"Address is not valid" if self.options.descriptors else "Invalid Bitcoin address or script",
"Address is not valid" if self.options.descriptors else "Invalid Litecoin address or script",
lambda: wallet_watch_only.importaddress(label=l, rescan=False, address=ad),
)