1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-21 01:39:36 +01:00

JSON alongside binary proto serialization test data

This makes the proto serializer characterisation test data be
accompanied by JSON data.

This is arguably useful for a reasons:

- The JSON data is human-readable while the binary data is not, so it
  provides some indication of what the test data means beyond the C++
  literals.

- The JSON data is language-agnostic, and so can be used to quickly rig
  up tests for implementation in other languages, without having source
  code literals at all (just go back and forth between the JSON and the
  binary).

- Even though we have no concrete plans to place the binary protocol 1-1
  or with JSON, it is still nice to ensure that the JSON serializers and
  binary protocols have (near) equal coverage over data types, to help
  ensure we didn't forget a JSON (de)serializer.
This commit is contained in:
John Ericson 2025-10-30 14:47:05 -04:00
parent f5390e76e4
commit 204749270b
60 changed files with 1097 additions and 42 deletions

View file

@ -3,6 +3,7 @@
#include <nlohmann/json.hpp>
#include <gtest/gtest.h>
#include "nix/util/json-utils.hh"
#include "nix/store/common-protocol.hh"
#include "nix/store/common-protocol-impl.hh"
#include "nix/store/build-result.hh"
@ -22,7 +23,7 @@ public:
template<typename T>
void readProtoTest(PathView testStem, const T & expected)
{
CharacterizationTest::readTest(testStem, [&](const auto & encoded) {
CharacterizationTest::readTest(std::string{testStem + ".bin"}, [&](const auto & encoded) {
T got = ({
StringSource from{encoded};
CommonProto::Serialise<T>::read(store, CommonProto::ReadConn{.from = from});
@ -38,7 +39,7 @@ public:
template<typename T>
void writeProtoTest(PathView testStem, const T & decoded)
{
CharacterizationTest::writeTest(testStem, [&]() -> std::string {
CharacterizationTest::writeTest(std::string{testStem + ".bin"}, [&]() -> std::string {
StringSink to;
CommonProto::Serialise<T>::write(store, CommonProto::WriteConn{.to = to}, decoded);
return to.s;
@ -54,6 +55,14 @@ public:
TEST_F(CommonProtoTest, NAME##_write) \
{ \
writeProtoTest(STEM, VALUE); \
} \
TEST_F(CommonProtoTest, NAME##_json_read) \
{ \
readJsonTest(STEM, VALUE); \
} \
TEST_F(CommonProtoTest, NAME##_json_write) \
{ \
writeJsonTest(STEM, VALUE); \
}
CHARACTERIZATION_TEST(

View file

@ -0,0 +1,26 @@
[
{
"hash": {
"algorithm": "sha256",
"format": "base64",
"hash": "+Xc9Ll6mcPltwaewrk/BAQ56Y3G5T//wzhKUc0zrYu0="
},
"method": "text"
},
{
"hash": {
"algorithm": "sha1",
"format": "base64",
"hash": "gGemBoenViNZM3hiwqns/Fgzqwo="
},
"method": "flat"
},
{
"hash": {
"algorithm": "sha256",
"format": "base64",
"hash": "EMIJ+giQ/gLIWoxmPKjno3zHZrxbGymgzGGyZvZBIdM="
},
"method": "nar"
}
]

View file

@ -0,0 +1,4 @@
[
"sha256:15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527!baz",
"sha256:6f869f9ea2823bda165e06076fd0de4366dead2c0e8d2dbbad277d4f15c373f5!quux"
]

View file

@ -0,0 +1,11 @@
[
null,
{
"hash": {
"algorithm": "sha1",
"format": "base64",
"hash": "gGemBoenViNZM3hiwqns/Fgzqwo="
},
"method": "flat"
}
]

View file

@ -0,0 +1,4 @@
[
null,
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar"
]

View file

@ -0,0 +1,13 @@
[
{
"dependentRealisations": {
"sha256:6f869f9ea2823bda165e06076fd0de4366dead2c0e8d2dbbad277d4f15c373f5!quux": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"
},
"id": "sha256:15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527!baz",
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
"signatures": [
"asdf",
"qwer"
]
}
]

View file

@ -0,0 +1,17 @@
[
{
"dependentRealisations": {},
"id": "sha256:15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527!baz",
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
"signatures": []
},
{
"dependentRealisations": {},
"id": "sha256:15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527!baz",
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
"signatures": [
"asdf",
"qwer"
]
}
]

View file

@ -0,0 +1,22 @@
[
[],
[
""
],
[
"",
"bar",
"foo"
],
[
[],
[
""
],
[
"",
"1",
"2"
]
]
]

View file

@ -0,0 +1,4 @@
[
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar"
]

View file

@ -0,0 +1,7 @@
[
"",
"hi",
"white rabbit",
"大白兔",
"oh no "
]

View file

@ -0,0 +1,22 @@
[
[],
[
""
],
[
"",
"foo",
"bar"
],
[
[],
[
""
],
[
"",
"1",
"2"
]
]
]

View file

@ -0,0 +1,28 @@
[
{
"errorMsg": "no idea why",
"isNonDeterministic": false,
"startTime": 0,
"status": "OutputRejected",
"stopTime": 0,
"success": false,
"timesBuilt": 0
},
{
"errorMsg": "no idea why",
"isNonDeterministic": false,
"startTime": 0,
"status": "NotDeterministic",
"stopTime": 0,
"success": false,
"timesBuilt": 0
},
{
"builtOutputs": {},
"startTime": 0,
"status": "Built",
"stopTime": 0,
"success": true,
"timesBuilt": 0
}
]

View file

@ -0,0 +1,28 @@
[
{
"errorMsg": "no idea why",
"isNonDeterministic": false,
"startTime": 0,
"status": "OutputRejected",
"stopTime": 0,
"success": false,
"timesBuilt": 0
},
{
"errorMsg": "no idea why",
"isNonDeterministic": true,
"startTime": 30,
"status": "NotDeterministic",
"stopTime": 50,
"success": false,
"timesBuilt": 3
},
{
"builtOutputs": {},
"startTime": 30,
"status": "Built",
"stopTime": 50,
"success": true,
"timesBuilt": 0
}
]

View file

@ -0,0 +1,41 @@
[
{
"errorMsg": "no idea why",
"isNonDeterministic": false,
"startTime": 0,
"status": "OutputRejected",
"stopTime": 0,
"success": false,
"timesBuilt": 0
},
{
"errorMsg": "no idea why",
"isNonDeterministic": true,
"startTime": 30,
"status": "NotDeterministic",
"stopTime": 50,
"success": false,
"timesBuilt": 3
},
{
"builtOutputs": {
"bar": {
"dependentRealisations": {},
"id": "sha256:6f869f9ea2823bda165e06076fd0de4366dead2c0e8d2dbbad277d4f15c373f5!bar",
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
"signatures": []
},
"foo": {
"dependentRealisations": {},
"id": "sha256:6f869f9ea2823bda165e06076fd0de4366dead2c0e8d2dbbad277d4f15c373f5!foo",
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
"signatures": []
}
},
"startTime": 30,
"status": "Built",
"stopTime": 50,
"success": true,
"timesBuilt": 1
}
]

View file

@ -0,0 +1,26 @@
[
{
"hash": {
"algorithm": "sha256",
"format": "base64",
"hash": "+Xc9Ll6mcPltwaewrk/BAQ56Y3G5T//wzhKUc0zrYu0="
},
"method": "text"
},
{
"hash": {
"algorithm": "sha1",
"format": "base64",
"hash": "gGemBoenViNZM3hiwqns/Fgzqwo="
},
"method": "flat"
},
{
"hash": {
"algorithm": "sha256",
"format": "base64",
"hash": "EMIJ+giQ/gLIWoxmPKjno3zHZrxbGymgzGGyZvZBIdM="
},
"method": "nar"
}
]

View file

@ -0,0 +1,4 @@
[
"sha256:15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527!baz",
"sha256:6f869f9ea2823bda165e06076fd0de4366dead2c0e8d2dbbad277d4f15c373f5!quux"
]

View file

@ -0,0 +1,11 @@
[
null,
{
"hash": {
"algorithm": "sha1",
"format": "base64",
"hash": "gGemBoenViNZM3hiwqns/Fgzqwo="
},
"method": "flat"
}
]

View file

@ -0,0 +1,4 @@
[
null,
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar"
]

View file

@ -0,0 +1,13 @@
[
{
"dependentRealisations": {
"sha256:6f869f9ea2823bda165e06076fd0de4366dead2c0e8d2dbbad277d4f15c373f5!quux": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"
},
"id": "sha256:15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527!baz",
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
"signatures": [
"asdf",
"qwer"
]
}
]

View file

@ -0,0 +1,17 @@
[
{
"dependentRealisations": {},
"id": "sha256:15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527!baz",
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
"signatures": []
},
{
"dependentRealisations": {},
"id": "sha256:15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527!baz",
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
"signatures": [
"asdf",
"qwer"
]
}
]

View file

@ -0,0 +1,22 @@
[
[],
[
""
],
[
"",
"bar",
"foo"
],
[
[],
[
""
],
[
"",
"1",
"2"
]
]
]

View file

@ -0,0 +1,4 @@
[
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar"
]

View file

@ -0,0 +1,7 @@
[
"",
"hi",
"white rabbit",
"大白兔",
"oh no "
]

View file

@ -0,0 +1,34 @@
[
{
"ca": null,
"deriver": null,
"narHash": {
"algorithm": "sha256",
"format": "base64",
"hash": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
},
"narSize": 34878,
"references": [],
"registrationTime": null,
"signatures": [],
"ultimate": false,
"version": 2
},
{
"ca": null,
"deriver": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
"narHash": {
"algorithm": "sha256",
"format": "base64",
"hash": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
},
"narSize": 34878,
"references": [
"g1w7hyyyy1w7hy3qg1w7hy3qgqqqqy3q-foo.drv"
],
"registrationTime": null,
"signatures": [],
"ultimate": false,
"version": 2
}
]

View file

@ -0,0 +1,47 @@
[
{
"ca": null,
"deriver": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
"narHash": {
"algorithm": "sha256",
"format": "base64",
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
},
"narSize": 34878,
"references": [
"g1w7hyyyy1w7hy3qg1w7hy3qgqqqqy3q-foo.drv"
],
"registrationTime": null,
"signatures": [],
"ultimate": false,
"version": 2
},
{
"ca": {
"hash": {
"algorithm": "sha256",
"format": "base64",
"hash": "EMIJ+giQ/gLIWoxmPKjno3zHZrxbGymgzGGyZvZBIdM="
},
"method": "nar"
},
"deriver": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
"narHash": {
"algorithm": "sha256",
"format": "base64",
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
},
"narSize": 34878,
"references": [
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
"n5wkd9frr45pa74if5gpz9j7mifg27fh-foo"
],
"registrationTime": null,
"signatures": [
"fake-sig-1",
"fake-sig-2"
],
"ultimate": false,
"version": 2
}
]

View file

@ -0,0 +1,22 @@
[
[],
[
""
],
[
"",
"foo",
"bar"
],
[
[],
[
""
],
[
"",
"1",
"2"
]
]
]

View file

@ -0,0 +1,5 @@
[
0,
1,
2
]

View file

@ -0,0 +1,28 @@
[
{
"errorMsg": "no idea why",
"isNonDeterministic": false,
"startTime": 0,
"status": "OutputRejected",
"stopTime": 0,
"success": false,
"timesBuilt": 0
},
{
"errorMsg": "no idea why",
"isNonDeterministic": false,
"startTime": 0,
"status": "NotDeterministic",
"stopTime": 0,
"success": false,
"timesBuilt": 0
},
{
"builtOutputs": {},
"startTime": 0,
"status": "Built",
"stopTime": 0,
"success": true,
"timesBuilt": 0
}
]

View file

@ -0,0 +1,41 @@
[
{
"errorMsg": "no idea why",
"isNonDeterministic": false,
"startTime": 0,
"status": "OutputRejected",
"stopTime": 0,
"success": false,
"timesBuilt": 0
},
{
"errorMsg": "no idea why",
"isNonDeterministic": false,
"startTime": 0,
"status": "NotDeterministic",
"stopTime": 0,
"success": false,
"timesBuilt": 0
},
{
"builtOutputs": {
"bar": {
"dependentRealisations": {},
"id": "sha256:6f869f9ea2823bda165e06076fd0de4366dead2c0e8d2dbbad277d4f15c373f5!bar",
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
"signatures": []
},
"foo": {
"dependentRealisations": {},
"id": "sha256:6f869f9ea2823bda165e06076fd0de4366dead2c0e8d2dbbad277d4f15c373f5!foo",
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
"signatures": []
}
},
"startTime": 0,
"status": "Built",
"stopTime": 0,
"success": true,
"timesBuilt": 0
}
]

View file

@ -0,0 +1,41 @@
[
{
"errorMsg": "no idea why",
"isNonDeterministic": false,
"startTime": 0,
"status": "OutputRejected",
"stopTime": 0,
"success": false,
"timesBuilt": 0
},
{
"errorMsg": "no idea why",
"isNonDeterministic": true,
"startTime": 30,
"status": "NotDeterministic",
"stopTime": 50,
"success": false,
"timesBuilt": 3
},
{
"builtOutputs": {
"bar": {
"dependentRealisations": {},
"id": "sha256:6f869f9ea2823bda165e06076fd0de4366dead2c0e8d2dbbad277d4f15c373f5!bar",
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
"signatures": []
},
"foo": {
"dependentRealisations": {},
"id": "sha256:6f869f9ea2823bda165e06076fd0de4366dead2c0e8d2dbbad277d4f15c373f5!foo",
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
"signatures": []
}
},
"startTime": 30,
"status": "Built",
"stopTime": 50,
"success": true,
"timesBuilt": 1
}
]

View file

@ -0,0 +1,43 @@
[
{
"errorMsg": "no idea why",
"isNonDeterministic": false,
"startTime": 0,
"status": "OutputRejected",
"stopTime": 0,
"success": false,
"timesBuilt": 0
},
{
"errorMsg": "no idea why",
"isNonDeterministic": true,
"startTime": 30,
"status": "NotDeterministic",
"stopTime": 50,
"success": false,
"timesBuilt": 3
},
{
"builtOutputs": {
"bar": {
"dependentRealisations": {},
"id": "sha256:6f869f9ea2823bda165e06076fd0de4366dead2c0e8d2dbbad277d4f15c373f5!bar",
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
"signatures": []
},
"foo": {
"dependentRealisations": {},
"id": "sha256:6f869f9ea2823bda165e06076fd0de4366dead2c0e8d2dbbad277d4f15c373f5!foo",
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
"signatures": []
}
},
"cpuSystem": 604000000,
"cpuUser": 500000000,
"startTime": 30,
"status": "Built",
"stopTime": 50,
"success": true,
"timesBuilt": 1
}
]

View file

@ -0,0 +1,26 @@
[
{
"hash": {
"algorithm": "sha256",
"format": "base64",
"hash": "+Xc9Ll6mcPltwaewrk/BAQ56Y3G5T//wzhKUc0zrYu0="
},
"method": "text"
},
{
"hash": {
"algorithm": "sha1",
"format": "base64",
"hash": "gGemBoenViNZM3hiwqns/Fgzqwo="
},
"method": "flat"
},
{
"hash": {
"algorithm": "sha256",
"format": "base64",
"hash": "EMIJ+giQ/gLIWoxmPKjno3zHZrxbGymgzGGyZvZBIdM="
},
"method": "nar"
}
]

View file

@ -0,0 +1,16 @@
[
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
{
"drvPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
"outputs": [
"*"
]
},
{
"drvPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
"outputs": [
"x",
"y"
]
}
]

View file

@ -0,0 +1,17 @@
[
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv",
{
"drvPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
"outputs": [
"*"
]
},
{
"drvPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
"outputs": [
"x",
"y"
]
}
]

View file

@ -0,0 +1,4 @@
[
"sha256:15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527!baz",
"sha256:6f869f9ea2823bda165e06076fd0de4366dead2c0e8d2dbbad277d4f15c373f5!quux"
]

View file

@ -0,0 +1,27 @@
[
{
"errorMsg": "no idea why",
"isNonDeterministic": false,
"path": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-xxx",
"startTime": 0,
"status": "OutputRejected",
"stopTime": 0,
"success": false,
"timesBuilt": 0
},
{
"errorMsg": "no idea why",
"isNonDeterministic": true,
"path": {
"drvPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
"outputs": [
"out"
]
},
"startTime": 30,
"status": "NotDeterministic",
"stopTime": 50,
"success": false,
"timesBuilt": 3
}
]

View file

@ -0,0 +1,11 @@
[
null,
{
"hash": {
"algorithm": "sha1",
"format": "base64",
"hash": "gGemBoenViNZM3hiwqns/Fgzqwo="
},
"method": "flat"
}
]

View file

@ -0,0 +1,4 @@
[
null,
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar"
]

View file

@ -0,0 +1,5 @@
[
null,
true,
false
]

View file

@ -0,0 +1,13 @@
[
{
"dependentRealisations": {
"sha256:6f869f9ea2823bda165e06076fd0de4366dead2c0e8d2dbbad277d4f15c373f5!quux": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"
},
"id": "sha256:15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527!baz",
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
"signatures": [
"asdf",
"qwer"
]
}
]

View file

@ -0,0 +1,17 @@
[
{
"dependentRealisations": {},
"id": "sha256:15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527!baz",
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
"signatures": []
},
{
"dependentRealisations": {},
"id": "sha256:15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527!baz",
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
"signatures": [
"asdf",
"qwer"
]
}
]

View file

@ -0,0 +1,22 @@
[
[],
[
""
],
[
"",
"bar",
"foo"
],
[
[],
[
""
],
[
"",
"1",
"2"
]
]
]

View file

@ -0,0 +1,4 @@
[
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar"
]

View file

@ -0,0 +1,7 @@
[
"",
"hi",
"white rabbit",
"大白兔",
"oh no "
]

View file

@ -0,0 +1,34 @@
[
{
"ca": null,
"deriver": null,
"narHash": {
"algorithm": "sha256",
"format": "base64",
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
},
"narSize": 34878,
"references": [],
"registrationTime": 23423,
"signatures": [],
"ultimate": false,
"version": 2
},
{
"ca": null,
"deriver": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
"narHash": {
"algorithm": "sha256",
"format": "base64",
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
},
"narSize": 34878,
"references": [
"g1w7hyyyy1w7hy3qg1w7hy3qgqqqqy3q-foo.drv"
],
"registrationTime": 23423,
"signatures": [],
"ultimate": false,
"version": 2
}
]

View file

@ -0,0 +1,37 @@
[
{
"ca": null,
"deriver": null,
"narHash": {
"algorithm": "sha256",
"format": "base64",
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
},
"narSize": 34878,
"path": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
"references": [],
"registrationTime": 23423,
"signatures": [],
"ultimate": false,
"version": 2
},
{
"ca": null,
"deriver": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
"narHash": {
"algorithm": "sha256",
"format": "base64",
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
},
"narSize": 34878,
"path": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
"references": [
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
"g1w7hyyyy1w7hy3qg1w7hy3qgqqqqy3q-foo"
],
"registrationTime": 23423,
"signatures": [],
"ultimate": false,
"version": 2
}
]

View file

@ -0,0 +1,66 @@
[
{
"ca": null,
"deriver": null,
"narHash": {
"algorithm": "sha256",
"format": "base64",
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
},
"narSize": 34878,
"path": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
"references": [],
"registrationTime": 23423,
"signatures": [],
"ultimate": true,
"version": 2
},
{
"ca": null,
"deriver": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
"narHash": {
"algorithm": "sha256",
"format": "base64",
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
},
"narSize": 34878,
"path": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
"references": [
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
"g1w7hyyyy1w7hy3qg1w7hy3qgqqqqy3q-foo"
],
"registrationTime": 23423,
"signatures": [
"fake-sig-1",
"fake-sig-2"
],
"ultimate": false,
"version": 2
},
{
"ca": {
"hash": {
"algorithm": "sha256",
"format": "base64",
"hash": "EMIJ+giQ/gLIWoxmPKjno3zHZrxbGymgzGGyZvZBIdM="
},
"method": "nar"
},
"deriver": null,
"narHash": {
"algorithm": "sha256",
"format": "base64",
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
},
"narSize": 34878,
"path": "n5wkd9frr45pa74if5gpz9j7mifg27fh-foo",
"references": [
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
"n5wkd9frr45pa74if5gpz9j7mifg27fh-foo"
],
"registrationTime": 23423,
"signatures": [],
"ultimate": false,
"version": 2
}
]

View file

@ -0,0 +1,22 @@
[
[],
[
""
],
[
"",
"foo",
"bar"
],
[
[],
[
""
],
[
"",
"1",
"2"
]
]
]

View file

@ -4,6 +4,7 @@
#include <nlohmann/json.hpp>
#include <gtest/gtest.h>
#include "nix/util/json-utils.hh"
#include "nix/store/serve-protocol.hh"
#include "nix/store/serve-protocol-impl.hh"
#include "nix/store/serve-protocol-connection.hh"
@ -334,7 +335,7 @@ VERSIONED_CHARACTERIZATION_TEST(
}),
}))
VERSIONED_CHARACTERIZATION_TEST(
VERSIONED_CHARACTERIZATION_TEST_NO_JSON(
ServeProtoTest,
build_options_2_1,
"build-options-2.1",
@ -344,7 +345,7 @@ VERSIONED_CHARACTERIZATION_TEST(
.buildTimeout = 6,
}))
VERSIONED_CHARACTERIZATION_TEST(
VERSIONED_CHARACTERIZATION_TEST_NO_JSON(
ServeProtoTest,
build_options_2_2,
"build-options-2.2",
@ -355,7 +356,7 @@ VERSIONED_CHARACTERIZATION_TEST(
.maxLogSize = 7,
}))
VERSIONED_CHARACTERIZATION_TEST(
VERSIONED_CHARACTERIZATION_TEST_NO_JSON(
ServeProtoTest,
build_options_2_3,
"build-options-2.3",
@ -368,7 +369,7 @@ VERSIONED_CHARACTERIZATION_TEST(
.enforceDeterminism = true,
}))
VERSIONED_CHARACTERIZATION_TEST(
VERSIONED_CHARACTERIZATION_TEST_NO_JSON(
ServeProtoTest,
build_options_2_7,
"build-options-2.7",
@ -439,7 +440,7 @@ VERSIONED_CHARACTERIZATION_TEST(
TEST_F(ServeProtoTest, handshake_log)
{
CharacterizationTest::writeTest("handshake-to-client", [&]() -> std::string {
CharacterizationTest::writeTest("handshake-to-client.bin", [&]() -> std::string {
StringSink toClientLog;
Pipe toClient, toServer;
@ -475,7 +476,7 @@ struct NullBufferedSink : BufferedSink
TEST_F(ServeProtoTest, handshake_client_replay)
{
CharacterizationTest::readTest("handshake-to-client", [&](std::string toClientLog) {
CharacterizationTest::readTest("handshake-to-client.bin", [&](std::string toClientLog) {
NullBufferedSink nullSink;
StringSource in{toClientLog};
@ -487,7 +488,7 @@ TEST_F(ServeProtoTest, handshake_client_replay)
TEST_F(ServeProtoTest, handshake_client_truncated_replay_throws)
{
CharacterizationTest::readTest("handshake-to-client", [&](std::string toClientLog) {
CharacterizationTest::readTest("handshake-to-client.bin", [&](std::string toClientLog) {
for (size_t len = 0; len < toClientLog.size(); ++len) {
NullBufferedSink nullSink;
auto substring = toClientLog.substr(0, len);
@ -505,7 +506,7 @@ TEST_F(ServeProtoTest, handshake_client_truncated_replay_throws)
TEST_F(ServeProtoTest, handshake_client_corrupted_throws)
{
CharacterizationTest::readTest("handshake-to-client", [&](const std::string toClientLog) {
CharacterizationTest::readTest("handshake-to-client.bin", [&](const std::string toClientLog) {
for (size_t idx = 0; idx < toClientLog.size(); ++idx) {
// corrupt a copy
std::string toClientLogCorrupt = toClientLog;

View file

@ -4,6 +4,7 @@
#include <nlohmann/json.hpp>
#include <gtest/gtest.h>
#include "nix/util/json-utils.hh"
#include "nix/store/worker-protocol.hh"
#include "nix/store/worker-protocol-connection.hh"
#include "nix/store/worker-protocol-impl.hh"
@ -649,7 +650,7 @@ VERSIONED_CHARACTERIZATION_TEST(
},
}))
VERSIONED_CHARACTERIZATION_TEST(
VERSIONED_CHARACTERIZATION_TEST_NO_JSON(
WorkerProtoTest,
clientHandshakeInfo_1_30,
"client-handshake-info_1_30",
@ -658,7 +659,7 @@ VERSIONED_CHARACTERIZATION_TEST(
{},
}))
VERSIONED_CHARACTERIZATION_TEST(
VERSIONED_CHARACTERIZATION_TEST_NO_JSON(
WorkerProtoTest,
clientHandshakeInfo_1_33,
"client-handshake-info_1_33",
@ -672,7 +673,7 @@ VERSIONED_CHARACTERIZATION_TEST(
},
}))
VERSIONED_CHARACTERIZATION_TEST(
VERSIONED_CHARACTERIZATION_TEST_NO_JSON(
WorkerProtoTest,
clientHandshakeInfo_1_35,
"client-handshake-info_1_35",
@ -690,7 +691,7 @@ VERSIONED_CHARACTERIZATION_TEST(
TEST_F(WorkerProtoTest, handshake_log)
{
CharacterizationTest::writeTest("handshake-to-client", [&]() -> std::string {
CharacterizationTest::writeTest("handshake-to-client.bin", [&]() -> std::string {
StringSink toClientLog;
Pipe toClient, toServer;
@ -751,7 +752,7 @@ struct NullBufferedSink : BufferedSink
TEST_F(WorkerProtoTest, handshake_client_replay)
{
CharacterizationTest::readTest("handshake-to-client", [&](std::string toClientLog) {
CharacterizationTest::readTest("handshake-to-client.bin", [&](std::string toClientLog) {
NullBufferedSink nullSink;
StringSource in{toClientLog};
@ -764,7 +765,7 @@ TEST_F(WorkerProtoTest, handshake_client_replay)
TEST_F(WorkerProtoTest, handshake_client_truncated_replay_throws)
{
CharacterizationTest::readTest("handshake-to-client", [&](std::string toClientLog) {
CharacterizationTest::readTest("handshake-to-client.bin", [&](std::string toClientLog) {
for (size_t len = 0; len < toClientLog.size(); ++len) {
NullBufferedSink nullSink;
auto substring = toClientLog.substr(0, len);
@ -782,7 +783,7 @@ TEST_F(WorkerProtoTest, handshake_client_truncated_replay_throws)
TEST_F(WorkerProtoTest, handshake_client_corrupted_throws)
{
CharacterizationTest::readTest("handshake-to-client", [&](const std::string toClientLog) {
CharacterizationTest::readTest("handshake-to-client.bin", [&](const std::string toClientLog) {
for (size_t idx = 0; idx < toClientLog.size(); ++idx) {
// corrupt a copy
std::string toClientLogCorrupt = toClientLog;