|
| 1 | +{ |
| 2 | + "name": "Chain", |
| 3 | + "description": "Tests chain state operations including block processing, active chain tracking, and handling chain reorganizations", |
| 4 | + "stateful": true, |
| 5 | + "tests": [ |
| 6 | + { |
| 7 | + "id": "setup_regtest_chainstate_manager", |
| 8 | + "description": "Setup chainstate manager for regtest with default options", |
| 9 | + "method": "btck_chainstate_manager_create", |
| 10 | + "params": { |
| 11 | + "context": { |
| 12 | + "chain_type": "regtest" |
| 13 | + } |
| 14 | + }, |
| 15 | + "expected": { |
| 16 | + "success": true |
| 17 | + } |
| 18 | + }, |
| 19 | + { |
| 20 | + "id": "assert_chain_height_zero", |
| 21 | + "description": "Assert chain height is 0 (genesis block only)", |
| 22 | + "method": "btck_chain_get_height", |
| 23 | + "params": {}, |
| 24 | + "expected": { |
| 25 | + "success": true, |
| 26 | + "result": { |
| 27 | + "height": 0 |
| 28 | + } |
| 29 | + } |
| 30 | + }, |
| 31 | + { |
| 32 | + "id": "process_blocks_1_to_3", |
| 33 | + "description": "Process blocks 1-3 sequentially", |
| 34 | + "method": "btck_chainstate_manager_process_block", |
| 35 | + "params": { |
| 36 | + "blocks_hex": [ |
| 37 | + "0000002006226e46111a0b59caaf126043eb5bbf28c34f3a5e332a1fc7b2b73cf188910f35b99ed4e2e165de2ad77f1bba48049358c9bb740445f3c83ebdb3e83aa5bca8dbe5494dffff7f200000000001020000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff025100feffffff0200f2052a010000001976a9142b4569203694fc997e13f2c0a1383b9e16c77a0d88ac0000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf90120000000000000000000000000000000000000000000000000000000000000000000000000", |
| 38 | + "000000205e2f859d70e29641f32371f3bf17a282466ad851f9e51b44a70738abeace314a9cf876c62dbbe036af4ea4a7363cd4ca1c14c8572095cba3b76a87daa1303ed8dce5494dffff7f200200000001020000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff025200feffffff0200f2052a010000001976a9142b4569203694fc997e13f2c0a1383b9e16c77a0d88ac0000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf90120000000000000000000000000000000000000000000000000000000000000000001000000", |
| 39 | + "0000002077622c1ae937c9fec6be84d01521cb31b0e6f88ec48150965323dba6a1e36e19354352df0f2a5d635ca7d3a52064f9c95f070d2c13c0a6c087acba03dfeeae66dde5494dffff7f200000000001020000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff025300feffffff0200f2052a010000001976a9142b4569203694fc997e13f2c0a1383b9e16c77a0d88ac0000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf90120000000000000000000000000000000000000000000000000000000000000000002000000" |
| 40 | + ] |
| 41 | + }, |
| 42 | + "expected": { |
| 43 | + "success": true |
| 44 | + } |
| 45 | + }, |
| 46 | + { |
| 47 | + "id": "assert_chain_height_three", |
| 48 | + "description": "Assert chain height is 3 after processing blocks", |
| 49 | + "method": "btck_chain_get_height", |
| 50 | + "params": {}, |
| 51 | + "expected": { |
| 52 | + "success": true, |
| 53 | + "result": { |
| 54 | + "height": 3 |
| 55 | + } |
| 56 | + } |
| 57 | + }, |
| 58 | + { |
| 59 | + "id": "get_block_tree_entry_at_height_three", |
| 60 | + "description": "Get block tree entry at height 3", |
| 61 | + "method": "btck_chain_get_by_height", |
| 62 | + "params": { |
| 63 | + "height": 3 |
| 64 | + }, |
| 65 | + "expected": { |
| 66 | + "success": true, |
| 67 | + "result": { |
| 68 | + "height": 3, |
| 69 | + "block_hash": "1a81e97231fb262ccf464f937553a1deff996ac6901b062d0b35afe025ee2886" |
| 70 | + } |
| 71 | + } |
| 72 | + }, |
| 73 | + { |
| 74 | + "id": "process_reorg_blocks", |
| 75 | + "description": "Process 3 blocks that cause a chain reorganization", |
| 76 | + "method": "btck_chainstate_manager_process_block", |
| 77 | + "params": { |
| 78 | + "blocks_hex": [ |
| 79 | + "000000205e2f859d70e29641f32371f3bf17a282466ad851f9e51b44a70738abeace314a9cf876c62dbbe036af4ea4a7363cd4ca1c14c8572095cba3b76a87daa1303ed8dee5494dffff7f200000000001020000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff025200feffffff0200f2052a010000001976a9142b4569203694fc997e13f2c0a1383b9e16c77a0d88ac0000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf90120000000000000000000000000000000000000000000000000000000000000000001000000", |
| 80 | + "000000202c6c418b1f714cbe22c9c2906a5c1a3f5c0df22d32989b71f579b2289a0ccd4c354352df0f2a5d635ca7d3a52064f9c95f070d2c13c0a6c087acba03dfeeae66dfe5494dffff7f200200000001020000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff025300feffffff0200f2052a010000001976a9142b4569203694fc997e13f2c0a1383b9e16c77a0d88ac0000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf90120000000000000000000000000000000000000000000000000000000000000000002000000", |
| 81 | + "00000020732f2f7a1035b802d670218031da2b11d0fe7297ddaeb4a428fc51bf588770417bd00ba57498a2dfcf4e3f0d7ef7f279b254fc422133f300a49aed3c8ed7717fe0e5494dffff7f200100000001020000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff025400feffffff0200f2052a010000001976a9142b4569203694fc997e13f2c0a1383b9e16c77a0d88ac0000000000000000266a24aa21a9ede2f61c3f71d1defd3fa999dfa36953755c690689799962b48bebd836974e8cf90120000000000000000000000000000000000000000000000000000000000000000003000000" |
| 82 | + ] |
| 83 | + }, |
| 84 | + "expected": { |
| 85 | + "success": true |
| 86 | + } |
| 87 | + }, |
| 88 | + { |
| 89 | + "id": "verify_reorg_old_block_not_in_chain", |
| 90 | + "description": "Verify that the old block at height 3 is no longer in the active chain after reorg", |
| 91 | + "method": "btck_chain_contains", |
| 92 | + "params": { |
| 93 | + "block_hash": "1a81e97231fb262ccf464f937553a1deff996ac6901b062d0b35afe025ee2886" |
| 94 | + }, |
| 95 | + "expected": { |
| 96 | + "success": true, |
| 97 | + "result": { |
| 98 | + "contains": false |
| 99 | + } |
| 100 | + } |
| 101 | + }, |
| 102 | + { |
| 103 | + "id": "assert_chain_height_four", |
| 104 | + "description": "Assert chain height is 4 after reorg", |
| 105 | + "method": "btck_chain_get_height", |
| 106 | + "params": {}, |
| 107 | + "expected": { |
| 108 | + "success": true, |
| 109 | + "result": { |
| 110 | + "height": 4 |
| 111 | + } |
| 112 | + } |
| 113 | + }, |
| 114 | + { |
| 115 | + "id": "get_block_tree_entry_at_height_four", |
| 116 | + "description": "Get block tree entry at height 4 after reorg", |
| 117 | + "method": "btck_chain_get_by_height", |
| 118 | + "params": { |
| 119 | + "height": 4 |
| 120 | + }, |
| 121 | + "expected": { |
| 122 | + "success": true, |
| 123 | + "result": { |
| 124 | + "height": 4, |
| 125 | + "block_hash": "18618dcf64dddb10ea15d7850bc4c7965c9a72b613da8530b83057672f29bbfa" |
| 126 | + } |
| 127 | + } |
| 128 | + }, |
| 129 | + { |
| 130 | + "id": "teardown_chainstate_manager", |
| 131 | + "description": "Teardown chainstate manager and cleanup resources", |
| 132 | + "method": "btck_chainstate_manager_destroy", |
| 133 | + "params": {}, |
| 134 | + "expected": { |
| 135 | + "success": true |
| 136 | + } |
| 137 | + } |
| 138 | + ] |
| 139 | +} |
0 commit comments