fix(test): repair the merged ConsensusSpanNames test file

The add/add resolution in 493475a9d4 did not compile. Two defects, one cause.

Both branches wrote this file independently and the union was assembled by
slicing each side's tests out of its own copy. That slice was asymmetric: it
started at the first TEST( line, which skipped the pre-merge side's
`using namespace xrpl::telemetry;` and its `namespace {` opener, but ended at the
`#endif`, which kept that side's `}  // namespace` closer. So the file lost the
scope its own tests depend on and gained a brace with nothing to close: 27
openers against 28 closers.

Clang reported 50 "use of undeclared identifier 'consensus'" sites from line 144
and gave up at 20; GCC got far enough to also report "expected declaration
before '}' token". Neither parent has this combination -- it exists only in the
merge.

The nine validation-accept tests spell their constants out from `consensus`,
which the surviving directive does not make visible: `using namespace
xrpl::telemetry::consensus::span` imports the MEMBERS of consensus::span, not the
enclosing namespace name. Fixed with a namespace alias rather than by restoring
the blanket `using namespace xrpl::telemetry;`, because that would pull
xrpl::telemetry::attr (SpanNames.h:117) into scope alongside
consensus::span::attr and make all eleven bare `attr::` references in the
phase-span tests ambiguous -- trading a hard error for a subtler one.

The orphan closer is removed rather than matched with a new opener. The nine
tests it used to wrap declare no helpers, so the anonymous namespace bought no
internal linkage, and the eight tests from the other side were never inside one.

Verification: braces balance 27/27 counted on comment- and string-stripped
source; 17 TEST cases intact; the alias at line 59 precedes the first bare
`consensus::` in CODE at 155 and the directive at 48 precedes the first bare
`attr::` at 64, both measured after stripping comments, because an earlier check
matched its own explanatory prose and reported a false ordering violation; no
blanket using-directive in code; pre-commit clean including clang-format and
clang-tidy. NOT compiled -- there is no approval to build here, so this fix is
structurally verified only, and CI is the first compiler to see it.
This commit is contained in:
Pratik Mankawde committed 2026-08-26 12:31:12 +01:00
1 parent 493475a9d4
commit 1e341d5413
1 file changed
+11 -2
@@ -47,6 +47,17 @@
using namespace xrpl::telemetry::consensus::span;
// The phase-span tests below reach their constants through the directive above.
// The validation-accept tests further down spell the path out from `consensus`,
// which that directive does NOT make visible: it imports the members of
// consensus::span, not the enclosing namespace name.
//
// An alias rather than a second `using namespace xrpl::telemetry;`, which would
// pull xrpl::telemetry::attr (SpanNames.h:117) into scope alongside
// consensus::span::attr and make every bare `attr::` in the phase-span tests
// ambiguous.
namespace consensus = xrpl::telemetry::consensus;
TEST(ConsensusSpanNames, phase_open_start_attribute_keys)
{
// Set once when the open-phase span is created in startRoundInternal().
@@ -273,5 +284,3 @@ TEST(ConsensusSpanNames, validationStatusValue_is_a_compile_time_rule)
static_assert(consensus::span::validationStatusValue(-1) == "unknown");
SUCCEED();
}
} // namespace