| 58 | std::optional<std::string> m_expected_valid_block = std::nullopt; |
| 59 | |
| 60 | void BlockChecked(Block block, BlockValidationStateView state) override |
| 61 | { |
| 62 | auto mode{state.GetValidationMode()}; |
| 63 | switch (mode) { |
| 64 | case ValidationMode::VALID: { |
| 65 | std::cout << "Valid block" << std::endl; |
| 66 | return; |
| 67 | } |
| 68 | case ValidationMode::INVALID: { |
| 69 | std::cout << "Invalid block: "; |
| 70 | auto result{state.GetBlockValidationResult()}; |
| 71 | switch (result) { |
| 72 | case BlockValidationResult::UNSET: |
| 73 | std::cout << "initial value. Block has not yet been rejected" << std::endl; |
| 74 | break; |
| 75 | case BlockValidationResult::HEADER_LOW_WORK: |
| 76 | std::cout << "the block header may be on a too-little-work chain" << std::endl; |
| 77 | break; |
| 78 | case BlockValidationResult::CONSENSUS: |
| 79 | std::cout << "invalid by consensus rules" << std::endl; |
| 80 | break; |
| 81 | case BlockValidationResult::CACHED_INVALID: |
| 82 | std::cout << "this block was cached as being invalid and we didn't store the reason why" << std::endl; |
| 83 | break; |
| 84 | case BlockValidationResult::INVALID_HEADER: |
| 85 | std::cout << "invalid proof of work or time too old" << std::endl; |
| 86 | break; |
| 87 | case BlockValidationResult::MUTATED: |
| 88 | std::cout << "the block's data didn't match the data committed to by the PoW" << std::endl; |
| 89 | break; |
| 90 | case BlockValidationResult::MISSING_PREV: |
| 91 | std::cout << "We don't have the previous block the checked one is built on" << std::endl; |
| 92 | break; |
| 93 | case BlockValidationResult::INVALID_PREV: |
| 94 | std::cout << "A block this one builds on is invalid" << std::endl; |
| 95 | break; |
| 96 | case BlockValidationResult::TIME_FUTURE: |
| 97 | std::cout << "block timestamp was > 2 hours in the future (or our clock is bad)" << std::endl; |
| 98 | break; |
| 99 | } |
| 100 | return; |
| 101 | } |
| 102 | case ValidationMode::INTERNAL_ERROR: { |
| 103 | std::cout << "Internal error" << std::endl; |
| 104 | return; |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | }; |
| 109 | |
| 110 | class TestKernelNotifications : public KernelNotifications |
nothing calls this directly
no test coverage detected