Add safe bank failure diagnostics for T5 and T6
Address #14 with request correlation, bounded parser reasons, startup version reporting, and rate-limited storage and settlement logs. Preserve accounting and API identity contracts, extend portable tests, and update release versions and rollout guidance.
This commit is contained in:
@@ -104,6 +104,29 @@ int main(int argc, char** argv)
|
||||
for (const auto& text : {"", "<html>bad gateway</html>", "{", "null", "{\"ok\":true}"})
|
||||
assert(!parse_acknowledgement(text).valid);
|
||||
assert(!parse_acknowledgement(std::string(0x5000,' ')+valid.dump()).valid);
|
||||
// Every validation failure exposes a fixed reason and clears response data.
|
||||
const auto invalid = [](const std::string& text, const std::string& reason)
|
||||
{
|
||||
const auto result = parse_acknowledgement(text);
|
||||
assert(!result.valid && result.reason == reason);
|
||||
assert(result.state.empty() && result.code.empty() && result.id.empty());
|
||||
};
|
||||
assert(ack.reason == "ok");
|
||||
invalid("", "empty_body");
|
||||
invalid(std::string(0x5000, 'x'), "body_limit");
|
||||
invalid("secret-token-not-json", "invalid_json");
|
||||
invalid("null", "schema");
|
||||
invalid("{}", "schema");
|
||||
bad = valid; bad["code"] = std::string(65, 'x'); invalid(bad.dump(), "field_limit");
|
||||
bad = valid; bad["state"] = "secret-state"; invalid(bad.dump(), "state");
|
||||
bad = valid; bad["amount"] = -1; invalid(bad.dump(), "amount_range");
|
||||
bad = valid; bad["ok"] = false; invalid(bad.dump(), "ok_state");
|
||||
bad = valid; bad["request_id"] = ""; invalid(bad.dump(), "missing_id");
|
||||
bad = valid; bad["amount"] = 0; invalid(bad.dump(), "zero_transfer");
|
||||
bad = valid; bad["code"] = "private-token\nAuthorization: secret";
|
||||
// Compatibility: valid but unknown API codes remain available to callers;
|
||||
// scripts permit only fixed known codes in diagnostics.
|
||||
assert(parse_acknowledgement(bad.dump()).valid);
|
||||
{ std::ofstream stream(file); stream << "corrupt"; }
|
||||
must_fail([&]{queue.load();});
|
||||
must_fail([&]{queue.store(body("three","cancel"));});
|
||||
|
||||
Reference in New Issue
Block a user