|
16 | 16 | _pat_check_aggregate_counts, |
17 | 17 | _pat_post_aggregate_counts, |
18 | 18 | _pat_post_row_category, |
| 19 | + _require_validator_axons, |
19 | 20 | ) |
20 | 21 |
|
21 | 22 |
|
@@ -184,6 +185,67 @@ def test_combines_reasons_when_both_fail(self): |
184 | 185 | assert len(excluded[0]['reasons']) == 2 |
185 | 186 |
|
186 | 187 |
|
| 188 | +class TestRequireValidatorAxonsErrorPath: |
| 189 | + """Regression: the error path must surface the same `excluded` payload the |
| 190 | + success path renders, so operators see which threshold eliminated each UID.""" |
| 191 | + |
| 192 | + def test_filtered_json_envelope_includes_skipped_array(self, capsys): |
| 193 | + mg = _fake_metagraph( |
| 194 | + [ |
| 195 | + (0.99, True, 5_000.0), |
| 196 | + (0.85, True, 3_000.0), |
| 197 | + (0.72, True, 8_000.0), |
| 198 | + ] |
| 199 | + ) |
| 200 | + with pytest.raises(SystemExit) as exc_info: |
| 201 | + _require_validator_axons(mg, True, min_vtrust=0.25, min_stake=15_000.0) |
| 202 | + assert exc_info.value.code == 1 |
| 203 | + payload = json.loads(capsys.readouterr().out.strip()) |
| 204 | + assert payload['success'] is False |
| 205 | + assert '--min-stake' in payload['error'] |
| 206 | + assert '--min-vtrust' in payload['error'] |
| 207 | + assert len(payload['skipped']) == 3 |
| 208 | + assert {entry['uid'] for entry in payload['skipped']} == {0, 1, 2} |
| 209 | + assert all(entry['reasons'] for entry in payload['skipped']) |
| 210 | + |
| 211 | + def test_filtered_tty_renders_skipped_table_and_error(self, capsys): |
| 212 | + mg = _fake_metagraph( |
| 213 | + [ |
| 214 | + (0.99, True, 5_000.0), |
| 215 | + (0.85, False, 50_000.0), |
| 216 | + ] |
| 217 | + ) |
| 218 | + with pytest.raises(SystemExit) as exc_info: |
| 219 | + _require_validator_axons(mg, False, min_vtrust=0.25, min_stake=15_000.0) |
| 220 | + assert exc_info.value.code == 1 |
| 221 | + out = capsys.readouterr().out |
| 222 | + assert 'Skipped Validators' in out |
| 223 | + assert 'No validators passed' in out |
| 224 | + assert 'Error:' in out |
| 225 | + |
| 226 | + def test_truly_empty_metagraph_keeps_generic_message(self, capsys): |
| 227 | + mg = _fake_metagraph([]) |
| 228 | + with pytest.raises(SystemExit) as exc_info: |
| 229 | + _require_validator_axons(mg, True, min_vtrust=0.25, min_stake=15_000.0) |
| 230 | + assert exc_info.value.code == 1 |
| 231 | + payload = json.loads(capsys.readouterr().out.strip()) |
| 232 | + assert payload == { |
| 233 | + 'success': False, |
| 234 | + 'error': 'No reachable validator axons found on the network.', |
| 235 | + } |
| 236 | + |
| 237 | + def test_subvtrust_only_metagraph_keeps_generic_message(self, capsys): |
| 238 | + # Sub-vtrust UIDs are dropped silently and never enter `excluded`, |
| 239 | + # so the message should remain the generic one — not the threshold one. |
| 240 | + mg = _fake_metagraph([(0.10, True, 50_000.0), (0.05, True, 100_000.0)]) |
| 241 | + with pytest.raises(SystemExit) as exc_info: |
| 242 | + _require_validator_axons(mg, True, min_vtrust=0.25, min_stake=15_000.0) |
| 243 | + assert exc_info.value.code == 1 |
| 244 | + payload = json.loads(capsys.readouterr().out.strip()) |
| 245 | + assert payload['error'] == 'No reachable validator axons found on the network.' |
| 246 | + assert 'skipped' not in payload |
| 247 | + |
| 248 | + |
187 | 249 | class TestPatCheckAggregateCounts: |
188 | 250 | def test_splits_valid_no_pat_invalid_and_no_response(self): |
189 | 251 | results = [ |
|
0 commit comments