diff options
| -rw-r--r-- | tests/fixtures/chain-tools/explorer-blocks.json | 1 | ||||
| -rw-r--r-- | tests/fixtures/chain-tools/fair-launch-report.json | 1 | ||||
| -rw-r--r-- | tests/fixtures/chain-tools/utxo-proof-verification.json | 1 | ||||
| -rw-r--r-- | tests/fixtures/chain-tools/utxo-proof.json | 1 | ||||
| -rw-r--r-- | tests/fixtures/chain-tools/utxo-report.json | 1 | ||||
| -rw-r--r-- | tests/scripts/test_bitflash_tools.py | 178 |
6 files changed, 182 insertions, 1 deletions
diff --git a/tests/fixtures/chain-tools/explorer-blocks.json b/tests/fixtures/chain-tools/explorer-blocks.json new file mode 100644 index 0000000..795d6e4 --- /dev/null +++ b/tests/fixtures/chain-tools/explorer-blocks.json | |||
| @@ -0,0 +1 @@ | |||
| {"blocks":[{"cbAddr":"BDnXDAAvEameyQk12FrtvBiPBp9MsfRmUA","cbValue":5000000000,"hash":"7c0e819cec25ebe29452049f1b35479526ba679bc2c1b00407417109384dea76","height":2,"nTx":2,"size":331,"time":1753315440},{"cbAddr":"B61KYnjpfXHN2w2e1nR869HneK4P1Gz4va","cbValue":5000000000,"hash":"17bdb455d41592adbff4aa97b7fca2091fef69600e67306baca829ab5a588b30","height":1,"nTx":2,"size":331,"time":1753315320},{"cbAddr":"BDU4zj6apurZ7YWNxsndaTt75PMgzvwbN4","cbValue":5000000000,"hash":"5bd7cb255d814e48cebcdfb72da4dc87b34bd774227f8ceb546c5640f4bdc169","height":0,"nTx":1,"size":278,"time":1753315200}],"count":3,"network":"bitflash","tipHeight":2} | |||
diff --git a/tests/fixtures/chain-tools/fair-launch-report.json b/tests/fixtures/chain-tools/fair-launch-report.json new file mode 100644 index 0000000..d35f30b --- /dev/null +++ b/tests/fixtures/chain-tools/fair-launch-report.json | |||
| @@ -0,0 +1 @@ | |||
| {"attestation_payload_sha256":"bf192bdbbb84c69d15bb68cf133abd474d0e1021600febc68e9f1a9de844b2af","chain":{"coin":100000000,"message_start_hex":"bf205cfd","name":"Bitflash","ticker":"BTF"},"checks":{"computed_merkle_matches_header":true,"genesis_has_single_transaction":true,"genesis_hash_matches_source":true,"genesis_merkle_matches_source":true,"genesis_supply_is_50_btf":true,"genesis_transaction_is_coinbase":true},"coinbase_outputs":[{"block_hash":"5bd7cb255d814e48cebcdfb72da4dc87b34bd774227f8ceb546c5640f4bdc169","coinbase_txid":"1a45b4482532abb29b10e234d3f13132230525a339ecea91658ffa675a5b1325","height":0,"outputs":[{"script_pub_key_hex":"4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac","value_btf":"50.00000000","value_satoshis":5000000000}],"value_btf":"50.00000000","value_satoshis":5000000000},{"block_hash":"17bdb455d41592adbff4aa97b7fca2091fef69600e67306baca829ab5a588b30","coinbase_txid":"d6967c16013f1da136183f962aefd2f15e59b6836043f8ef49aadb92f38dca05","height":1,"outputs":[{"script_pub_key_hex":"76a914111111111111111111111111111111111111111188ac","value_btf":"50.00000000","value_satoshis":5000000000}],"value_btf":"50.00000000","value_satoshis":5000000000},{"block_hash":"7c0e819cec25ebe29452049f1b35479526ba679bc2c1b00407417109384dea76","coinbase_txid":"d55af2c80e8b70a9ae8f362a8aac5448e7925267c7f737d1fa0d227fd472a657","height":2,"outputs":[{"script_pub_key_hex":"76a914666666666666666666666666666666666666666688ac","value_btf":"50.00000000","value_satoshis":5000000000}],"value_btf":"50.00000000","value_satoshis":5000000000}],"deterministic":true,"external_timestamping":{"instructions":["Save the canonical JSON report.","Run: ots stamp bitflash-fair-launch-report.json","Later verify with: ots verify bitflash-fair-launch-report.json.ots"],"recommended":"OpenTimestamps","status":"not_embedded"},"genesis":{"bits":"0x1f0fffff","coinbase_txid":"1a45b4482532abb29b10e234d3f13132230525a339ecea91658ffa675a5b1325","computed_merkle_root":"1a45b4482532abb29b10e234d3f13132230525a339ecea91658ffa675a5b1325","hash":"5bd7cb255d814e48cebcdfb72da4dc87b34bd774227f8ceb546c5640f4bdc169","merkle_root":"1a45b4482532abb29b10e234d3f13132230525a339ecea91658ffa675a5b1325","nonce":3141,"outputs":[{"script_pub_key_hex":"4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac","value_btf":"50.00000000","value_satoshis":5000000000}],"time":1753315200,"time_utc":"2025-07-24T00:00:00Z","tx_count":1},"scanned":{"block_count":3,"first_height":0,"last_height":2,"non_coinbase_transactions":2,"total_coinbase_btf":"150.00000000","total_coinbase_satoshis":15000000000},"schema":"bitflash-fair-launch-report-1","source_constants":{"genesis_bits":"0x1f0fffff","genesis_hash":"5bd7cb255d814e48cebcdfb72da4dc87b34bd774227f8ceb546c5640f4bdc169","genesis_merkle_root":"1a45b4482532abb29b10e234d3f13132230525a339ecea91658ffa675a5b1325","genesis_message":"Bitflash 24/Jul/2026 Fair launch: one CPU one vote, no premine","genesis_nonce":3141,"genesis_time":1753315200,"genesis_time_utc":"2025-07-24T00:00:00Z"},"source_mode":"local-block-files","verdict":"FAIR_LAUNCH_BASELINE_VERIFIED"} | |||
diff --git a/tests/fixtures/chain-tools/utxo-proof-verification.json b/tests/fixtures/chain-tools/utxo-proof-verification.json new file mode 100644 index 0000000..a40c673 --- /dev/null +++ b/tests/fixtures/chain-tools/utxo-proof-verification.json | |||
| @@ -0,0 +1 @@ | |||
| {"checks":{"leaf_hash_matches_target":true,"root_matches":true,"schema_is_supported":true},"commitment":{"computed_root":"6e49b47ffccb178b62402235343ae7c55ec4a03effe19debb8c057e8ffc5b3c0","expected_root":"6e49b47ffccb178b62402235343ae7c55ec4a03effe19debb8c057e8ffc5b3c0","leaf_hash":"da964462812e40c918d6349baa57aee1dc838416eca44ccd31b782f0d1542d7b","path_length":3},"deterministic":true,"failures":[],"schema":"bitflash-utxo-proof-verification-1","target":{"created_height":2,"outpoint":"218609b2969dc0b6ae1c378ae255bbed863902987df4c943200e3c291b0e4c2a:1","value_btf":"17.50000000","value_satoshis":1750000000},"verdict":"UTXO_PROOF_VERIFIED"} | |||
diff --git a/tests/fixtures/chain-tools/utxo-proof.json b/tests/fixtures/chain-tools/utxo-proof.json new file mode 100644 index 0000000..154c45b --- /dev/null +++ b/tests/fixtures/chain-tools/utxo-proof.json | |||
| @@ -0,0 +1 @@ | |||
| {"chain":{"coin":100000000,"message_start_hex":"bf205cfd","name":"Bitflash","ticker":"BTF"},"commitment":{"algorithm":"sorted-outpoint-merkle-sha256","leaf_count":5,"leaf_domain":"BTFUTXO1","node_domain":"BTFNODE1","root":"6e49b47ffccb178b62402235343ae7c55ec4a03effe19debb8c057e8ffc5b3c0"},"deterministic":true,"proof":[{"duplicated":false,"hash":"7a4f4f13aaf91f8b6b32d1fb22feaa3d0398782504915e9c156e60fdeca1255d","level":0,"side":"left"},{"duplicated":false,"hash":"5f91d5ba472b7d6ab96e9ce99d689896dad3c264d3abbce4c77f257687608943","level":1,"side":"right"},{"duplicated":false,"hash":"f041ba6a82fbc6759f0632f412dd8aab971ac1317358d6f204af3e57da4d12de","level":2,"side":"right"}],"scanned":{"first_height":0,"last_height":2,"main_chain_block_count":3,"raw_block_count":3,"side_blocks_ignored":0,"tip_hash":"7c0e819cec25ebe29452049f1b35479526ba679bc2c1b00407417109384dea76","tip_time":1753315440,"tip_time_utc":"2025-07-24T00:04:00Z"},"schema":"bitflash-utxo-inclusion-proof-1","target":{"leaf_hash":"da964462812e40c918d6349baa57aee1dc838416eca44ccd31b782f0d1542d7b","leaf_index":1,"outpoint":"218609b2969dc0b6ae1c378ae255bbed863902987df4c943200e3c291b0e4c2a:1","txid":"218609b2969dc0b6ae1c378ae255bbed863902987df4c943200e3c291b0e4c2a","utxo":{"coinbase":false,"created_block_hash":"7c0e819cec25ebe29452049f1b35479526ba679bc2c1b00407417109384dea76","created_height":2,"created_txid":"218609b2969dc0b6ae1c378ae255bbed863902987df4c943200e3c291b0e4c2a","script_pub_key_hex":"76a914555555555555555555555555555555555555555588ac","txid":"218609b2969dc0b6ae1c378ae255bbed863902987df4c943200e3c291b0e4c2a","value_btf":"17.50000000","value_satoshis":1750000000,"vout":1},"vout":1},"verdict":"UTXO_INCLUSION_PROOF_CREATED","warnings":{"legacy_duplicate_output_overwrites":0}} | |||
diff --git a/tests/fixtures/chain-tools/utxo-report.json b/tests/fixtures/chain-tools/utxo-report.json new file mode 100644 index 0000000..c6e98ee --- /dev/null +++ b/tests/fixtures/chain-tools/utxo-report.json | |||
| @@ -0,0 +1 @@ | |||
| {"chain":{"coin":100000000,"message_start_hex":"bf205cfd","name":"Bitflash","ticker":"BTF"},"checks":{"all_scanned_merkle_roots_match":true,"genesis_hash_matches_source":true,"genesis_merkle_matches_source":true,"no_missing_spends":true},"commitment":{"algorithm":"sorted-outpoint-merkle-sha256","leaf_domain":"BTFUTXO1","node_domain":"BTFNODE1","root":"6e49b47ffccb178b62402235343ae7c55ec4a03effe19debb8c057e8ffc5b3c0"},"deterministic":true,"scanned":{"first_height":0,"last_height":2,"main_chain_block_count":3,"raw_block_count":3,"side_blocks_ignored":0,"tip_hash":"7c0e819cec25ebe29452049f1b35479526ba679bc2c1b00407417109384dea76","tip_time":1753315440,"tip_time_utc":"2025-07-24T00:04:00Z"},"schema":"bitflash-utxo-set-commitment-1","stats":{"coinbase_minus_unspent_btf":"1.50000000","coinbase_minus_unspent_satoshis":150000000,"duplicate_outputs":[],"missing_spends":[],"normal_transactions":2,"spent_outputs":8000000000,"total_coinbase_btf":"150.00000000","total_coinbase_satoshis":15000000000,"total_fees_btf":"1.50000000","total_fees_satoshis":150000000,"total_unspent_btf":"148.50000000","total_unspent_satoshis":14850000000,"utxo_count":5},"utxos":{"218609b2969dc0b6ae1c378ae255bbed863902987df4c943200e3c291b0e4c2a:0":{"coinbase":false,"created_block_hash":"7c0e819cec25ebe29452049f1b35479526ba679bc2c1b00407417109384dea76","created_height":2,"created_txid":"218609b2969dc0b6ae1c378ae255bbed863902987df4c943200e3c291b0e4c2a","script_pub_key_hex":"76a914444444444444444444444444444444444444444488ac","txid":"218609b2969dc0b6ae1c378ae255bbed863902987df4c943200e3c291b0e4c2a","value_btf":"12.00000000","value_satoshis":1200000000,"vout":0},"218609b2969dc0b6ae1c378ae255bbed863902987df4c943200e3c291b0e4c2a:1":{"coinbase":false,"created_block_hash":"7c0e819cec25ebe29452049f1b35479526ba679bc2c1b00407417109384dea76","created_height":2,"created_txid":"218609b2969dc0b6ae1c378ae255bbed863902987df4c943200e3c291b0e4c2a","script_pub_key_hex":"76a914555555555555555555555555555555555555555588ac","txid":"218609b2969dc0b6ae1c378ae255bbed863902987df4c943200e3c291b0e4c2a","value_btf":"17.50000000","value_satoshis":1750000000,"vout":1},"24bddfded9e22c2f98d9369e9ac00a4eccc8dcf05a2d1b9e12d94fd9f62ababc:1":{"coinbase":false,"created_block_hash":"17bdb455d41592adbff4aa97b7fca2091fef69600e67306baca829ab5a588b30","created_height":1,"created_txid":"24bddfded9e22c2f98d9369e9ac00a4eccc8dcf05a2d1b9e12d94fd9f62ababc","script_pub_key_hex":"76a914333333333333333333333333333333333333333388ac","txid":"24bddfded9e22c2f98d9369e9ac00a4eccc8dcf05a2d1b9e12d94fd9f62ababc","value_btf":"19.00000000","value_satoshis":1900000000,"vout":1},"d55af2c80e8b70a9ae8f362a8aac5448e7925267c7f737d1fa0d227fd472a657:0":{"coinbase":true,"created_block_hash":"7c0e819cec25ebe29452049f1b35479526ba679bc2c1b00407417109384dea76","created_height":2,"created_txid":"d55af2c80e8b70a9ae8f362a8aac5448e7925267c7f737d1fa0d227fd472a657","script_pub_key_hex":"76a914666666666666666666666666666666666666666688ac","txid":"d55af2c80e8b70a9ae8f362a8aac5448e7925267c7f737d1fa0d227fd472a657","value_btf":"50.00000000","value_satoshis":5000000000,"vout":0},"d6967c16013f1da136183f962aefd2f15e59b6836043f8ef49aadb92f38dca05:0":{"coinbase":true,"created_block_hash":"17bdb455d41592adbff4aa97b7fca2091fef69600e67306baca829ab5a588b30","created_height":1,"created_txid":"d6967c16013f1da136183f962aefd2f15e59b6836043f8ef49aadb92f38dca05","script_pub_key_hex":"76a914111111111111111111111111111111111111111188ac","txid":"d6967c16013f1da136183f962aefd2f15e59b6836043f8ef49aadb92f38dca05","value_btf":"50.00000000","value_satoshis":5000000000,"vout":0}},"verdict":"UTXO_COMMITMENT_VERIFIED","warnings":{"legacy_duplicate_output_overwrites":0}} | |||
diff --git a/tests/scripts/test_bitflash_tools.py b/tests/scripts/test_bitflash_tools.py index ff569e1..4b18d1e 100644 --- a/tests/scripts/test_bitflash_tools.py +++ b/tests/scripts/test_bitflash_tools.py | |||
| @@ -12,6 +12,7 @@ from pathlib import Path | |||
| 12 | 12 | ||
| 13 | ROOT = Path(__file__).resolve().parents[2] | 13 | ROOT = Path(__file__).resolve().parents[2] |
| 14 | SCRIPTS = ROOT / "scripts" | 14 | SCRIPTS = ROOT / "scripts" |
| 15 | FIXTURES = ROOT / "tests" / "fixtures" / "chain-tools" | ||
| 15 | sys.path.insert(0, str(SCRIPTS)) | 16 | sys.path.insert(0, str(SCRIPTS)) |
| 16 | 17 | ||
| 17 | import bitflash_chain as chain # noqa: E402 | 18 | import bitflash_chain as chain # noqa: E402 |
| @@ -45,12 +46,130 @@ def write_block_file(path, blocks): | |||
| 45 | f.write(payload) | 46 | f.write(payload) |
| 46 | 47 | ||
| 47 | 48 | ||
| 49 | def p2pkh_script(byte): | ||
| 50 | return "76a914%s88ac" % (bytes([byte]) * 20).hex() | ||
| 51 | |||
| 52 | |||
| 53 | def make_tx(vin, vout): | ||
| 54 | tx = { | ||
| 55 | "version": 1, | ||
| 56 | "vin": vin, | ||
| 57 | "vout": vout, | ||
| 58 | "lock_time": 0, | ||
| 59 | } | ||
| 60 | tx["txid"] = chain.hash_hex(chain.ser_tx(tx)) | ||
| 61 | return tx | ||
| 62 | |||
| 63 | |||
| 64 | def make_coinbase(label, script_byte, value=50 * chain.COIN): | ||
| 65 | return make_tx( | ||
| 66 | [{ | ||
| 67 | "prevout_hash": "0" * 64, | ||
| 68 | "prevout_n": 0xFFFFFFFF, | ||
| 69 | "script_sig_hex": label.encode("ascii").hex(), | ||
| 70 | "sequence": 0xFFFFFFFF, | ||
| 71 | }], | ||
| 72 | [{ | ||
| 73 | "value_satoshis": value, | ||
| 74 | "value_btf": chain.format_money(value), | ||
| 75 | "script_pub_key_hex": p2pkh_script(script_byte), | ||
| 76 | }], | ||
| 77 | ) | ||
| 78 | |||
| 79 | |||
| 80 | def make_spend(prev_txid, prev_n, outputs, label): | ||
| 81 | return make_tx( | ||
| 82 | [{ | ||
| 83 | "prevout_hash": prev_txid, | ||
| 84 | "prevout_n": prev_n, | ||
| 85 | "script_sig_hex": label.encode("ascii").hex(), | ||
| 86 | "sequence": 0xFFFFFFFF, | ||
| 87 | }], | ||
| 88 | [{ | ||
| 89 | "value_satoshis": value, | ||
| 90 | "value_btf": chain.format_money(value), | ||
| 91 | "script_pub_key_hex": p2pkh_script(script_byte), | ||
| 92 | } for value, script_byte in outputs], | ||
| 93 | ) | ||
| 94 | |||
| 95 | |||
| 96 | def make_block(prev_hash, txs, ntime, nonce): | ||
| 97 | merkle = chain.merkle_root([tx["txid"] for tx in txs]) | ||
| 98 | header = ( | ||
| 99 | struct.pack("<i", 1) | ||
| 100 | + bytes.fromhex(prev_hash)[::-1] | ||
| 101 | + bytes.fromhex(merkle)[::-1] | ||
| 102 | + struct.pack("<III", ntime, chain.GENESIS_BITS, nonce) | ||
| 103 | ) | ||
| 104 | block = { | ||
| 105 | "hash": chain.hash_hex(header), | ||
| 106 | "version": 1, | ||
| 107 | "previous_hash": prev_hash, | ||
| 108 | "merkle_root": merkle, | ||
| 109 | "computed_merkle_root": merkle, | ||
| 110 | "time": ntime, | ||
| 111 | "time_utc": chain.utc(ntime), | ||
| 112 | "bits": "0x%08x" % chain.GENESIS_BITS, | ||
| 113 | "nonce": nonce, | ||
| 114 | "tx_count": len(txs), | ||
| 115 | "transactions": txs, | ||
| 116 | "source_file": "synthetic", | ||
| 117 | "source_offset": 0, | ||
| 118 | "size": 80 + len(chain.ser_compact_size(len(txs))) + sum(len(chain.ser_tx(tx)) for tx in txs), | ||
| 119 | } | ||
| 120 | return block | ||
| 121 | |||
| 122 | |||
| 123 | def fixture_chain(): | ||
| 124 | genesis = chain.reconstructed_genesis() | ||
| 125 | spend1 = make_spend( | ||
| 126 | chain.GENESIS_MERKLE, | ||
| 127 | 0, | ||
| 128 | [(30 * chain.COIN, 0x22), (19 * chain.COIN, 0x33)], | ||
| 129 | "spend genesis with 1 BTF fee", | ||
| 130 | ) | ||
| 131 | block1 = make_block( | ||
| 132 | genesis["hash"], | ||
| 133 | [make_coinbase("fixture coinbase 1", 0x11), spend1], | ||
| 134 | chain.GENESIS_TIME + 120, | ||
| 135 | 4001, | ||
| 136 | ) | ||
| 137 | spend2 = make_spend( | ||
| 138 | spend1["txid"], | ||
| 139 | 0, | ||
| 140 | [(12 * chain.COIN, 0x44), (17 * chain.COIN + 50_000_000, 0x55)], | ||
| 141 | "split spend with 0.5 BTF fee", | ||
| 142 | ) | ||
| 143 | block2 = make_block( | ||
| 144 | block1["hash"], | ||
| 145 | [make_coinbase("fixture coinbase 2", 0x66), spend2], | ||
| 146 | chain.GENESIS_TIME + 240, | ||
| 147 | 4002, | ||
| 148 | ) | ||
| 149 | return [genesis, block1, block2], { | ||
| 150 | "genesis_outpoint": "%s:0" % chain.GENESIS_MERKLE, | ||
| 151 | "first_spend_txid": spend1["txid"], | ||
| 152 | "proof_outpoint": "%s:1" % spend2["txid"], | ||
| 153 | } | ||
| 154 | |||
| 155 | |||
| 156 | def compare_golden(name, actual, update): | ||
| 157 | path = FIXTURES / name | ||
| 158 | if update: | ||
| 159 | path.parent.mkdir(parents=True, exist_ok=True) | ||
| 160 | path.write_bytes(actual) | ||
| 161 | return | ||
| 162 | expected = path.read_bytes() | ||
| 163 | if actual != expected: | ||
| 164 | raise AssertionError("golden mismatch: %s" % name) | ||
| 165 | |||
| 166 | |||
| 48 | def assert_true(cond, msg): | 167 | def assert_true(cond, msg): |
| 49 | if not cond: | 168 | if not cond: |
| 50 | raise AssertionError(msg) | 169 | raise AssertionError(msg) |
| 51 | 170 | ||
| 52 | 171 | ||
| 53 | def main(): | 172 | def run_genesis_smoke(): |
| 54 | genesis = chain.reconstructed_genesis() | 173 | genesis = chain.reconstructed_genesis() |
| 55 | outpoint = "%s:0" % chain.GENESIS_MERKLE | 174 | outpoint = "%s:0" % chain.GENESIS_MERKLE |
| 56 | 175 | ||
| @@ -99,6 +218,63 @@ def main(): | |||
| 99 | else: | 218 | else: |
| 100 | raise AssertionError("strict duplicate output mode did not fail") | 219 | raise AssertionError("strict duplicate output mode did not fail") |
| 101 | 220 | ||
| 221 | |||
| 222 | def run_golden_fixture(update): | ||
| 223 | blocks, meta = fixture_chain() | ||
| 224 | |||
| 225 | with tempfile.TemporaryDirectory(prefix="bitflash-tool-golden-") as tmp: | ||
| 226 | tmp = Path(tmp) | ||
| 227 | datadir = tmp / "datadir" | ||
| 228 | datadir.mkdir() | ||
| 229 | blk1 = datadir / "blk0001.dat" | ||
| 230 | blk2 = datadir / "blk0002.dat" | ||
| 231 | write_block_file(blk1, blocks[:2]) | ||
| 232 | write_block_file(blk2, blocks[2:]) | ||
| 233 | |||
| 234 | fair = run([SCRIPTS / "verify-fair-launch.py", "--datadir", datadir, | ||
| 235 | "--max-blocks", "3", "--json"]).stdout.encode("ascii") | ||
| 236 | compare_golden("fair-launch-report.json", fair, update) | ||
| 237 | fair_report = json.loads(fair) | ||
| 238 | assert_true(fair_report["scanned"]["non_coinbase_transactions"] == 2, | ||
| 239 | "fair-launch fixture did not count normal transactions") | ||
| 240 | |||
| 241 | utxo = run([SCRIPTS / "verify-utxo-set.py", "--datadir", datadir, | ||
| 242 | "--include-utxos", "--strict-duplicates", "--json"]).stdout.encode("ascii") | ||
| 243 | compare_golden("utxo-report.json", utxo, update) | ||
| 244 | utxo_report = json.loads(utxo) | ||
| 245 | assert_true(utxo_report["stats"]["normal_transactions"] == 2, | ||
| 246 | "UTXO fixture did not apply normal transactions") | ||
| 247 | assert_true(utxo_report["stats"]["total_fees_btf"] == "1.50000000", | ||
| 248 | "UTXO fixture fee total changed") | ||
| 249 | assert_true(meta["genesis_outpoint"] not in utxo_report["utxos"], | ||
| 250 | "spent genesis output still appears in the UTXO map") | ||
| 251 | |||
| 252 | proof_path = tmp / "fixture-proof.json" | ||
| 253 | proof = run([SCRIPTS / "prove-utxo.py", meta["proof_outpoint"], | ||
| 254 | "--datadir", datadir, "--strict-duplicates", | ||
| 255 | "--out", proof_path, "--json"]).stdout.encode("ascii") | ||
| 256 | compare_golden("utxo-proof.json", proof, update) | ||
| 257 | |||
| 258 | proof_check = run([SCRIPTS / "verify-utxo-proof.py", proof_path, | ||
| 259 | "--root", utxo_report["commitment"]["root"], "--json"]).stdout.encode("ascii") | ||
| 260 | compare_golden("utxo-proof-verification.json", proof_check, update) | ||
| 261 | proof_report = json.loads(proof_check) | ||
| 262 | assert_true(proof_report["verdict"] == "UTXO_PROOF_VERIFIED", | ||
| 263 | "fixture UTXO proof did not verify") | ||
| 264 | |||
| 265 | explorer_dir = tmp / "explorer" | ||
| 266 | run([SCRIPTS / "build-explorer.py", blk1, blk2, explorer_dir]) | ||
| 267 | compare_golden("explorer-blocks.json", | ||
| 268 | (explorer_dir / "blocks.json").read_bytes(), update) | ||
| 269 | detail = json.loads((explorer_dir / "block" / "1.json").read_text(encoding="ascii")) | ||
| 270 | assert_true(len(detail["txs"]) == 2, | ||
| 271 | "explorer fixture block did not include the normal transaction") | ||
| 272 | |||
| 273 | |||
| 274 | def main(): | ||
| 275 | update = "--update-goldens" in sys.argv[1:] | ||
| 276 | run_genesis_smoke() | ||
| 277 | run_golden_fixture(update) | ||
| 102 | print("Bitflash script tool regressions passed") | 278 | print("Bitflash script tool regressions passed") |
| 103 | return 0 | 279 | return 0 |
| 104 | 280 | ||