aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/libstore/worker-protocol.cc
diff options
context:
space:
mode:
authorRobert Hensing <roberth@users.noreply.github.com>2023-10-20 15:34:26 +0200
committereldritch horrors <pennae@lix.systems>2024-03-04 04:43:35 +0100
commitab40b2c5d0f90d6a119bf4b368f933f5331b0c15 (patch)
tree305c600d732546077701abefc9dddecdd2eadf0f /tests/unit/libstore/worker-protocol.cc
parent5ddd1a916667ec0d969f99a0a85a2092bf18b632 (diff)
Merge pull request #9157 from obsidiansystems/protocol-versions
Add protocol versions to `{Worker,Serve}Proto::*Conn` (cherry picked from commit 4d17c59d8d059a5b39f1d1da2b58f2ec8da44861) Change-Id: I497af39deb792e50c157a1305d8c9e722798740b
Diffstat (limited to 'tests/unit/libstore/worker-protocol.cc')
-rw-r--r--tests/unit/libstore/worker-protocol.cc49
1 files changed, 35 insertions, 14 deletions
diff --git a/tests/unit/libstore/worker-protocol.cc b/tests/unit/libstore/worker-protocol.cc
index 5c3faaae2..6e7f47168 100644
--- a/tests/unit/libstore/worker-protocol.cc
+++ b/tests/unit/libstore/worker-protocol.cc
@@ -14,12 +14,21 @@ namespace nix {
const char workerProtoDir[] = "worker-protocol";
-using WorkerProtoTest = ProtoTest<WorkerProto, workerProtoDir>;
+struct WorkerProtoTest : VersionedProtoTest<WorkerProto, workerProtoDir>
+{
+ /**
+ * For serializers that don't care about the minimum version, we
+ * used the oldest one: 1.0.
+ */
+ WorkerProto::Version defaultVersion = 1 << 8 | 0;
+};
-CHARACTERIZATION_TEST(
+
+VERSIONED_CHARACTERIZATION_TEST(
WorkerProtoTest,
string,
"string",
+ defaultVersion,
(std::tuple<std::string, std::string, std::string, std::string, std::string> {
"",
"hi",
@@ -28,19 +37,21 @@ CHARACTERIZATION_TEST(
"oh no \0\0\0 what was that!",
}))
-CHARACTERIZATION_TEST(
+VERSIONED_CHARACTERIZATION_TEST(
WorkerProtoTest,
storePath,
"store-path",
+ defaultVersion,
(std::tuple<StorePath, StorePath> {
StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" },
StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar" },
}))
-CHARACTERIZATION_TEST(
+VERSIONED_CHARACTERIZATION_TEST(
WorkerProtoTest,
contentAddress,
"content-address",
+ defaultVersion,
(std::tuple<ContentAddress, ContentAddress, ContentAddress> {
ContentAddress {
.method = TextIngestionMethod {},
@@ -56,10 +67,11 @@ CHARACTERIZATION_TEST(
},
}))
-CHARACTERIZATION_TEST(
+VERSIONED_CHARACTERIZATION_TEST(
WorkerProtoTest,
derivedPath,
"derived-path",
+ defaultVersion,
(std::tuple<DerivedPath, DerivedPath> {
DerivedPath::Opaque {
.path = StorePath { "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo" },
@@ -72,10 +84,11 @@ CHARACTERIZATION_TEST(
},
}))
-CHARACTERIZATION_TEST(
+VERSIONED_CHARACTERIZATION_TEST(
WorkerProtoTest,
drvOutput,
"drv-output",
+ defaultVersion,
(std::tuple<DrvOutput, DrvOutput> {
{
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
@@ -87,10 +100,11 @@ CHARACTERIZATION_TEST(
},
}))
-CHARACTERIZATION_TEST(
+VERSIONED_CHARACTERIZATION_TEST(
WorkerProtoTest,
realisation,
"realisation",
+ defaultVersion,
(std::tuple<Realisation, Realisation> {
Realisation {
.id = DrvOutput {
@@ -119,10 +133,11 @@ CHARACTERIZATION_TEST(
},
}))
-CHARACTERIZATION_TEST(
+VERSIONED_CHARACTERIZATION_TEST(
WorkerProtoTest,
buildResult,
"build-result",
+ defaultVersion,
({
using namespace std::literals::chrono_literals;
std::tuple<BuildResult, BuildResult, BuildResult> t {
@@ -177,10 +192,11 @@ CHARACTERIZATION_TEST(
t;
}))
-CHARACTERIZATION_TEST(
+VERSIONED_CHARACTERIZATION_TEST(
WorkerProtoTest,
keyedBuildResult,
"keyed-build-result",
+ defaultVersion,
({
using namespace std::literals::chrono_literals;
std::tuple<KeyedBuildResult, KeyedBuildResult/*, KeyedBuildResult*/> t {
@@ -213,20 +229,22 @@ CHARACTERIZATION_TEST(
t;
}))
-CHARACTERIZATION_TEST(
+VERSIONED_CHARACTERIZATION_TEST(
WorkerProtoTest,
optionalTrustedFlag,
"optional-trusted-flag",
+ defaultVersion,
(std::tuple<std::optional<TrustedFlag>, std::optional<TrustedFlag>, std::optional<TrustedFlag>> {
std::nullopt,
std::optional { Trusted },
std::optional { NotTrusted },
}))
-CHARACTERIZATION_TEST(
+VERSIONED_CHARACTERIZATION_TEST(
WorkerProtoTest,
vector,
"vector",
+ defaultVersion,
(std::tuple<std::vector<std::string>, std::vector<std::string>, std::vector<std::string>, std::vector<std::vector<std::string>>> {
{ },
{ "" },
@@ -234,10 +252,11 @@ CHARACTERIZATION_TEST(
{ {}, { "" }, { "", "1", "2" } },
}))
-CHARACTERIZATION_TEST(
+VERSIONED_CHARACTERIZATION_TEST(
WorkerProtoTest,
set,
"set",
+ defaultVersion,
(std::tuple<std::set<std::string>, std::set<std::string>, std::set<std::string>, std::set<std::set<std::string>>> {
{ },
{ "" },
@@ -245,10 +264,11 @@ CHARACTERIZATION_TEST(
{ {}, { "" }, { "", "1", "2" } },
}))
-CHARACTERIZATION_TEST(
+VERSIONED_CHARACTERIZATION_TEST(
WorkerProtoTest,
optionalStorePath,
"optional-store-path",
+ defaultVersion,
(std::tuple<std::optional<StorePath>, std::optional<StorePath>> {
std::nullopt,
std::optional {
@@ -256,10 +276,11 @@ CHARACTERIZATION_TEST(
},
}))
-CHARACTERIZATION_TEST(
+VERSIONED_CHARACTERIZATION_TEST(
WorkerProtoTest,
optionalContentAddress,
"optional-content-address",
+ defaultVersion,
(std::tuple<std::optional<ContentAddress>, std::optional<ContentAddress>> {
std::nullopt,
std::optional {