From 971f615695cebd656e46b9563143d855f1956b61 Mon Sep 17 00:00:00 2001 From: niftynei Date: Tue, 26 May 2020 15:43:21 -0500 Subject: [PATCH] psbt: affirm database upgrade works for last_tx -> psbt We use a database snapshot with 3 channels -- two of which have HTLCs dangling and one is an initial open channel tx in the 'old' tx hex format in last_tx and confirm that they are successfully updated to PSBT format on start. --- tests/data/last_tx_upgrade.sqlite3.xz | Bin 0 -> 14833 bytes tests/test_db.py | 28 +++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/data/last_tx_upgrade.sqlite3.xz diff --git a/tests/data/last_tx_upgrade.sqlite3.xz b/tests/data/last_tx_upgrade.sqlite3.xz new file mode 100644 index 0000000000000000000000000000000000000000..765e244587747a14cd78925fff4bd96e89b39e10 GIT binary patch literal 14833 zcmV0F4>(Km zHPFGt<*|Ng-W;D=$sEkiUonoH6A$o@rLLtAoH&@=AfA3I@a z!;SO!57sxZQ+Xblp~+NiF1BvUus8kwui)ym?;f}FO%TJ+LvJj*;qsRYU0?#c^A<)Q zYVid->G4sw*ygANRYj0E&DoBIy1jj)fs02#QKQ4l%GMhU{*0q`fldg!LHdszrIXa_ zOa~VM%6*6m;x+Jj9vO0`g`%H)eZ#J@G|CNqg4O(D3GCN3UKrK$zGYcxE2Lwgf|_#m z6uwW2e4t5t!20n;$Soir54w`GkJ`y>AzB@*Vw9*UYPY1i@uF;i%Pt09yQ-yVZ!~Z% zd3qDs01Z4OQt@;Dq|qTNYf(oeCEqlGz6p%Bu2h3qc?AI=!pd}olz(U?Z7+Z?#Od5P zNQ!p{8ss%9G3XTy)m-~p7=Fd4=fBitpEaR&SHq7D@C8M#A-)_|s%$P1O4}Fi-2^NZ=V)%jXlkIu#88g7Ced(j|X(KdNfj62{!s zu=5hR$KXs!mvew0AvWRE7`1lq$_@THSmCT|5Lw<`M?15~Q14&>rkEBXvU6+w`s;Sd zOC%{-=HvsFN1geOL#@F8!(PV1%FG18@nW?p-g_uq0`;2Pa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rZ{0{t8gCjLbtFn+DU zR65p%GJg1znuG|}P4(&T6}suTJLE7f^Eo;5+_nab@RxUJgdnZ5t14nPL XGm{90A1H%IJb_0A$J6Kk=?)=L5m4?a literal 0 HcmV?d00001 diff --git a/tests/test_db.py b/tests/test_db.py index 8379dd348..e4e3a6199 100644 --- a/tests/test_db.py +++ b/tests/test_db.py @@ -1,7 +1,10 @@ +from decimal import Decimal from fixtures import * # noqa: F401,F403 from fixtures import TEST_NETWORK from pyln.client import RpcError -from utils import wait_for, sync_blockheight, COMPAT, VALGRIND, DEVELOPER +from utils import wait_for, sync_blockheight, COMPAT, VALGRIND, DEVELOPER, only_one + +import base64 import os import pytest import time @@ -140,6 +143,29 @@ def test_scid_upgrade(node_factory, bitcoind): assert l1.db_query('SELECT failchannel from payments;') == [{'failchannel': '103x1x1'}] +@unittest.skipIf(not COMPAT, "needs COMPAT to convert obsolete db") +@unittest.skipIf(os.getenv('TEST_DB_PROVIDER', 'sqlite3') != 'sqlite3', "This test is based on a sqlite3 snapshot") +@unittest.skipIf(TEST_NETWORK != 'regtest', "The network must match the DB snapshot") +def test_last_tx_psbt_upgrade(node_factory, bitcoind): + bitcoind.generate_block(12) + + prior_txs = ['02000000018DD699861B00061E50937A233DB584BF8ED4C0BF50B44C0411F71B031A06455000000000000EF7A9800350C300000000000022002073356CFF7E1588F14935EF138E142ABEFB5F7E3D51DE942758DCD5A179449B6250A90600000000002200202DF545EA882889846C52FC5E111AC07CE07E0C09418AC15743A6F6284C2A4FA720A1070000000000160014E89954FAC8F7A2DCE51E095D7BEB5271C3F7DA56EF81DC20', '02000000018A0AE4C63BCDF9D78B07EB4501BB23404FDDBC73973C592793F047BE1495074B010000000074D99980010A2D0F00000000002200203B8CB644781CBECA96BE8B2BF1827AFD908B3CFB5569AC74DAB9395E8DDA39E4C9555420', '020000000135DAB2996E57762E3EC158C0D57D39F43CA657E882D93FC24F5FEBAA8F36ED9A0100000000566D1D800350C30000000000002200205679A7D06E1BD276AA25F56E9E4DF7E07D9837EFB0C5F63604F10CD9F766A03ED4DD0600000000001600147E5B5C8F4FC1A9484E259F92CA4CBB7FA2814EA49A6C070000000000220020AB6226DEBFFEFF4A741C01367FA3C875172483CFB3E327D0F8C7AA4C51EDECAA27AA4720'] + + l1 = node_factory.get_node(dbfile='last_tx_upgrade.sqlite3.xz') + + b64_last_txs = [base64.b64encode(x['last_tx']).decode('utf-8') for x in l1.db_query('SELECT last_tx FROM channels ORDER BY id;')] + for i in range(len(b64_last_txs)): + bpsbt = b64_last_txs[i] + psbt = bitcoind.rpc.decodepsbt(bpsbt) + tx = prior_txs[i] + assert psbt['tx']['txid'] == bitcoind.rpc.decoderawtransaction(tx)['txid'] + funding_input = only_one(psbt['inputs']) + # Every opened channel was funded with the same amount: 1M sats + assert funding_input['witness_utxo']['amount'] == Decimal('0.01') + assert funding_input['witness_utxo']['scriptPubKey']['type'] == 'witness_v0_scripthash' + assert funding_input['witness_script']['type'] == 'multisig' + + @unittest.skipIf(VALGRIND and not DEVELOPER, "Without developer valgrind will complain about debug symbols missing") def test_optimistic_locking(node_factory, bitcoind): """Have a node run against a DB, then change it under its feet, crashing it.