Update: add component catalog transactions
CI / GCC 16 / C++26 / sanitizers (push) Failing after 2m35s
CI / GCC 16 / C++26 / default (push) Failing after 2m39s
CI / GCC 16 / C++26 / werror (push) Failing after 1m54s

This commit is contained in:
faumaray committed 2026-07-29 00:22:20 +03:00
1 parent 9d8b334b4b
commit 05815c4668
3 files changed
+540 -7

No files matched your search

+113
View File
@@ -90,6 +90,85 @@ namespace
Void::Encoding::Base64::encode_url(payload),
Void::Encoding::Base64::encode_url(signature));
}
std::string signedEnvelope(std::string_view message,
std::uint32_t schemaVersion)
{
return std::format("{{\"schemaVersion\":{},\"keyId\":\"test-key\","
"\"payload\":\"{}\",\"signature\":\"{}\"}}",
schemaVersion,
Void::Encoding::Base64::encode_url(message),
Void::Encoding::Base64::encode_url(sign(message)));
}
constexpr std::string_view componentCatalogPayload = R"json({
"schemaVersion": 2,
"document": "echoion-component-catalog",
"channel": "stable",
"sequence": 11,
"generatedAt": "2026-01-01T00:00:00Z",
"expiresAt": "2099-01-01T00:00:00Z",
"productVersion": "2.0.0",
"components": [{
"componentId": "Host",
"pluginId": null,
"kind": "runtime-module",
"componentVersion": "2.0.1",
"activation": "restart-required",
"dependencies": {"Api": ">=2.0.0 <3.0.0"},
"sequence": 11,
"latestUrl": "https://updates.invalid/feeds/stable/host/latest.json",
"artifactSha256": "1111111111111111111111111111111111111111111111111111111111111111"
}, {
"componentId": "Api",
"pluginId": null,
"kind": "sdk",
"componentVersion": "2.0.0",
"activation": "restart-required",
"dependencies": {},
"sequence": 11,
"latestUrl": "https://updates.invalid/feeds/stable/api/latest.json",
"artifactSha256": "2222222222222222222222222222222222222222222222222222222222222222"
}]
})json";
std::string componentReleasePayload(std::string_view componentId,
std::string_view version,
std::string_view artifactHash,
std::string_view dependencies)
{
return std::format(
R"json({{
"schemaVersion": 2,
"document": "echoion-component-release",
"channel": "stable",
"sequence": 11,
"generatedAt": "2026-01-01T00:00:00Z",
"expiresAt": "2099-01-01T00:00:00Z",
"productVersion": "2.0.0",
"componentId": "{}",
"pluginId": null,
"kind": "{}",
"componentVersion": "{}",
"sourceSha": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"sourceTreeHash": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
"abiHash": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
"artifactIdentity": "{}-{}-linux-x86_64",
"activation": "restart-required",
"dependencies": {},
"artifact": {{
"name": "{}-{}.tar.zst",
"url": "https://updates.invalid/{}-{}.tar.zst",
"sha256": "{}",
"size": 42,
"manifestSha256": "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd",
"packageType": "tar.zst"
}}
}})json",
componentId, componentId == "Api" ? "sdk" : "runtime-module",
version, componentId, version, dependencies, componentId, version,
componentId, version, artifactHash);
}
} // namespace
Void::Testing::Test update_feed_verifies_before_parsing()
@@ -140,6 +219,40 @@ Void::Testing::Test update_feed_unsigned_parse_replay_and_selection()
!Void::Update::selectRelease(*parsed, request).has_value());
}
Void::Testing::Test component_feed_verifies_and_resolves_complete_set()
{
auto envelope = Void::Update::verifyEnvelope(
signedEnvelope(componentCatalogPayload, 2), keyring());
Void::Testing::require(envelope.has_value());
Void::Testing::expect_eq(envelope->schemaVersion, std::uint32_t{2});
auto catalog =
Void::Update::parseComponentCatalogPayload(envelope->signedPayload);
Void::Testing::require(catalog.has_value());
Void::Testing::expect_eq(catalog->components.size(), std::size_t{2});
auto host =
Void::Update::parseComponentReleasePayload(componentReleasePayload(
"Host", "2.0.1",
"1111111111111111111111111111111111111111111111111111111111111111",
R"json({"Api":">=2.0.0 <3.0.0"})json"));
auto api =
Void::Update::parseComponentReleasePayload(componentReleasePayload(
"Api", "2.0.0",
"2222222222222222222222222222222222222222222222222222222222222222",
"{}"));
Void::Testing::require(host.has_value());
Void::Testing::require(api.has_value());
std::map<std::string, Void::Update::ComponentRelease> releases;
releases.emplace("Api", *api);
releases.emplace("Host", *host);
Void::Testing::expect(
Void::Update::validateComponentSet(*catalog, releases).has_value());
releases.at("Api").componentVersion = *Void::Semver::parse("3.0.0");
Void::Testing::expect(
!Void::Update::validateComponentSet(*catalog, releases).has_value());
}
Void::Testing::Test update_feed_rejects_empty_fractional_timestamp()
{
std::string malformed{payload};