mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 12:06:01 +01:00
Merge 8dbd43b5d4 into 479b6b73a9
This commit is contained in:
commit
b8d8e9829c
76 changed files with 1288 additions and 143 deletions
|
|
@ -22,7 +22,15 @@ The store path info JSON format has been updated from version 1 to version 2:
|
||||||
- New: `"ca": {"method": "nar", "hash": {"algorithm": "sha256", "format": "base64", "hash": "EMIJ+giQ..."}}`
|
- New: `"ca": {"method": "nar", "hash": {"algorithm": "sha256", "format": "base64", "hash": "EMIJ+giQ..."}}`
|
||||||
- Still `null` values for input-addressed store objects
|
- Still `null` values for input-addressed store objects
|
||||||
|
|
||||||
Version 1 format is still accepted when reading for backward compatibility.
|
- **Structured hash fields**:
|
||||||
|
|
||||||
|
Hash values (`narHash` and `downloadHash`) are now structured JSON objects instead of strings:
|
||||||
|
|
||||||
|
- Old: `"narHash": "sha256:FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="`
|
||||||
|
- New: `"narHash": {"algorithm": "sha256", "format": "base64", "hash": "FePFYIlM..."}`
|
||||||
|
- Same structure applies to `downloadHash` in NAR info contexts
|
||||||
|
|
||||||
|
Nix currently only produces, and doesn't consume this format.
|
||||||
|
|
||||||
**Affected command**: `nix path-info --json`
|
**Affected command**: `nix path-info --json`
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ $defs:
|
||||||
Note: This field may not be present in all contexts, such as when the path is used as the key and the the store object info the value in map.
|
Note: This field may not be present in all contexts, such as when the path is used as the key and the the store object info the value in map.
|
||||||
|
|
||||||
narHash:
|
narHash:
|
||||||
type: string
|
"$ref": "./hash-v1.yaml"
|
||||||
title: NAR Hash
|
title: NAR Hash
|
||||||
description: |
|
description: |
|
||||||
Hash of the [file system object](@docroot@/store/file-system-object.md) part of the store object when serialized as a [Nix Archive](@docroot@/store/file-system-object/content-address.md#serial-nix-archive).
|
Hash of the [file system object](@docroot@/store/file-system-object.md) part of the store object when serialized as a [Nix Archive](@docroot@/store/file-system-object/content-address.md#serial-nix-archive).
|
||||||
|
|
@ -229,7 +229,7 @@ $defs:
|
||||||
> This is an impure "`.narinfo`" field that may not be included in certain contexts.
|
> This is an impure "`.narinfo`" field that may not be included in certain contexts.
|
||||||
|
|
||||||
downloadHash:
|
downloadHash:
|
||||||
type: string
|
"$ref": "./hash-v1.yaml"
|
||||||
title: Download Hash
|
title: Download Hash
|
||||||
description: |
|
description: |
|
||||||
A digest for the compressed archive itself, as opposed to the data contained within.
|
A digest for the compressed archive itself, as opposed to the data contained within.
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "nix/store/tests/libstore.hh"
|
#include "nix/store/tests/libstore.hh"
|
||||||
#include "nix/util/tests/characterization.hh"
|
#include "nix/util/tests/characterization.hh"
|
||||||
|
#include "nix/util/tests/json-characterization.hh"
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
|
@ -16,12 +17,30 @@ class ProtoTest : public CharacterizationTest
|
||||||
|
|
||||||
std::filesystem::path goldenMaster(std::string_view testStem) const override
|
std::filesystem::path goldenMaster(std::string_view testStem) const override
|
||||||
{
|
{
|
||||||
return unitTestData / (std::string{testStem + ".bin"});
|
return unitTestData / testStem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Path storeDir = "/nix/store";
|
Path storeDir = "/nix/store";
|
||||||
StoreDirConfig store{storeDir};
|
StoreDirConfig store{storeDir};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Golden test for `T` JSON reading
|
||||||
|
*/
|
||||||
|
template<typename T>
|
||||||
|
void readJsonTest(PathView testStem, const T & expected)
|
||||||
|
{
|
||||||
|
nix::readJsonTest(*this, testStem, expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Golden test for `T` JSON write
|
||||||
|
*/
|
||||||
|
template<typename T>
|
||||||
|
void writeJsonTest(PathView testStem, const T & decoded)
|
||||||
|
{
|
||||||
|
nix::writeJsonTest(*this, testStem, decoded);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class Proto, const char * protocolDir>
|
template<class Proto, const char * protocolDir>
|
||||||
|
|
@ -34,7 +53,7 @@ public:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void readProtoTest(PathView testStem, typename Proto::Version version, T expected)
|
void readProtoTest(PathView testStem, typename Proto::Version version, T expected)
|
||||||
{
|
{
|
||||||
CharacterizationTest::readTest(testStem, [&](const auto & encoded) {
|
CharacterizationTest::readTest(std::string{testStem + ".bin"}, [&](const auto & encoded) {
|
||||||
T got = ({
|
T got = ({
|
||||||
StringSource from{encoded};
|
StringSource from{encoded};
|
||||||
Proto::template Serialise<T>::read(
|
Proto::template Serialise<T>::read(
|
||||||
|
|
@ -55,7 +74,7 @@ public:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void writeProtoTest(PathView testStem, typename Proto::Version version, const T & decoded)
|
void writeProtoTest(PathView testStem, typename Proto::Version version, const T & decoded)
|
||||||
{
|
{
|
||||||
CharacterizationTest::writeTest(testStem, [&]() {
|
CharacterizationTest::writeTest(std::string{testStem + ".bin"}, [&]() {
|
||||||
StringSink to;
|
StringSink to;
|
||||||
Proto::template Serialise<T>::write(
|
Proto::template Serialise<T>::write(
|
||||||
this->store,
|
this->store,
|
||||||
|
|
@ -69,7 +88,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define VERSIONED_CHARACTERIZATION_TEST(FIXTURE, NAME, STEM, VERSION, VALUE) \
|
#define VERSIONED_CHARACTERIZATION_TEST_NO_JSON(FIXTURE, NAME, STEM, VERSION, VALUE) \
|
||||||
TEST_F(FIXTURE, NAME##_read) \
|
TEST_F(FIXTURE, NAME##_read) \
|
||||||
{ \
|
{ \
|
||||||
readProtoTest(STEM, VERSION, VALUE); \
|
readProtoTest(STEM, VERSION, VALUE); \
|
||||||
|
|
@ -79,4 +98,15 @@ public:
|
||||||
writeProtoTest(STEM, VERSION, VALUE); \
|
writeProtoTest(STEM, VERSION, VALUE); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define VERSIONED_CHARACTERIZATION_TEST(FIXTURE, NAME, STEM, VERSION, VALUE) \
|
||||||
|
VERSIONED_CHARACTERIZATION_TEST_NO_JSON(FIXTURE, NAME, STEM, VERSION, VALUE) \
|
||||||
|
TEST_F(FIXTURE, NAME##_json_read) \
|
||||||
|
{ \
|
||||||
|
readJsonTest(STEM, VALUE); \
|
||||||
|
} \
|
||||||
|
TEST_F(FIXTURE, NAME##_json_write) \
|
||||||
|
{ \
|
||||||
|
writeJsonTest(STEM, VALUE); \
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace nix
|
} // namespace nix
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include "nix/util/json-utils.hh"
|
||||||
#include "nix/store/common-protocol.hh"
|
#include "nix/store/common-protocol.hh"
|
||||||
#include "nix/store/common-protocol-impl.hh"
|
#include "nix/store/common-protocol-impl.hh"
|
||||||
#include "nix/store/build-result.hh"
|
#include "nix/store/build-result.hh"
|
||||||
|
|
@ -22,7 +23,7 @@ public:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void readProtoTest(PathView testStem, const T & expected)
|
void readProtoTest(PathView testStem, const T & expected)
|
||||||
{
|
{
|
||||||
CharacterizationTest::readTest(testStem, [&](const auto & encoded) {
|
CharacterizationTest::readTest(std::string{testStem + ".bin"}, [&](const auto & encoded) {
|
||||||
T got = ({
|
T got = ({
|
||||||
StringSource from{encoded};
|
StringSource from{encoded};
|
||||||
CommonProto::Serialise<T>::read(store, CommonProto::ReadConn{.from = from});
|
CommonProto::Serialise<T>::read(store, CommonProto::ReadConn{.from = from});
|
||||||
|
|
@ -38,7 +39,7 @@ public:
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void writeProtoTest(PathView testStem, const T & decoded)
|
void writeProtoTest(PathView testStem, const T & decoded)
|
||||||
{
|
{
|
||||||
CharacterizationTest::writeTest(testStem, [&]() -> std::string {
|
CharacterizationTest::writeTest(std::string{testStem + ".bin"}, [&]() -> std::string {
|
||||||
StringSink to;
|
StringSink to;
|
||||||
CommonProto::Serialise<T>::write(store, CommonProto::WriteConn{.to = to}, decoded);
|
CommonProto::Serialise<T>::write(store, CommonProto::WriteConn{.to = to}, decoded);
|
||||||
return to.s;
|
return to.s;
|
||||||
|
|
@ -54,6 +55,14 @@ public:
|
||||||
TEST_F(CommonProtoTest, NAME##_write) \
|
TEST_F(CommonProtoTest, NAME##_write) \
|
||||||
{ \
|
{ \
|
||||||
writeProtoTest(STEM, VALUE); \
|
writeProtoTest(STEM, VALUE); \
|
||||||
|
} \
|
||||||
|
TEST_F(CommonProtoTest, NAME##_json_read) \
|
||||||
|
{ \
|
||||||
|
readJsonTest(STEM, VALUE); \
|
||||||
|
} \
|
||||||
|
TEST_F(CommonProtoTest, NAME##_json_write) \
|
||||||
|
{ \
|
||||||
|
writeJsonTest(STEM, VALUE); \
|
||||||
}
|
}
|
||||||
|
|
||||||
CHARACTERIZATION_TEST(
|
CHARACTERIZATION_TEST(
|
||||||
|
|
|
||||||
26
src/libstore-tests/data/common-protocol/content-address.json
Normal file
26
src/libstore-tests/data/common-protocol/content-address.json
Normal 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"
|
||||||
|
}
|
||||||
|
]
|
||||||
4
src/libstore-tests/data/common-protocol/drv-output.json
Normal file
4
src/libstore-tests/data/common-protocol/drv-output.json
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
[
|
||||||
|
"sha256:15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527!baz",
|
||||||
|
"sha256:6f869f9ea2823bda165e06076fd0de4366dead2c0e8d2dbbad277d4f15c373f5!quux"
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
[
|
||||||
|
null,
|
||||||
|
{
|
||||||
|
"hash": {
|
||||||
|
"algorithm": "sha1",
|
||||||
|
"format": "base64",
|
||||||
|
"hash": "gGemBoenViNZM3hiwqns/Fgzqwo="
|
||||||
|
},
|
||||||
|
"method": "flat"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
[
|
||||||
|
null,
|
||||||
|
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar"
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"dependentRealisations": {
|
||||||
|
"sha256:6f869f9ea2823bda165e06076fd0de4366dead2c0e8d2dbbad277d4f15c373f5!quux": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"
|
||||||
|
},
|
||||||
|
"id": "sha256:15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527!baz",
|
||||||
|
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
|
||||||
|
"signatures": [
|
||||||
|
"asdf",
|
||||||
|
"qwer"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
17
src/libstore-tests/data/common-protocol/realisation.json
Normal file
17
src/libstore-tests/data/common-protocol/realisation.json
Normal 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"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
22
src/libstore-tests/data/common-protocol/set.json
Normal file
22
src/libstore-tests/data/common-protocol/set.json
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
[
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
""
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"",
|
||||||
|
"bar",
|
||||||
|
"foo"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
""
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"",
|
||||||
|
"1",
|
||||||
|
"2"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
4
src/libstore-tests/data/common-protocol/store-path.json
Normal file
4
src/libstore-tests/data/common-protocol/store-path.json
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
[
|
||||||
|
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
|
||||||
|
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar"
|
||||||
|
]
|
||||||
7
src/libstore-tests/data/common-protocol/string.json
Normal file
7
src/libstore-tests/data/common-protocol/string.json
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
[
|
||||||
|
"",
|
||||||
|
"hi",
|
||||||
|
"white rabbit",
|
||||||
|
"大白兔",
|
||||||
|
"oh no "
|
||||||
|
]
|
||||||
22
src/libstore-tests/data/common-protocol/vector.json
Normal file
22
src/libstore-tests/data/common-protocol/vector.json
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
[
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
""
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"",
|
||||||
|
"foo",
|
||||||
|
"bar"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
""
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"",
|
||||||
|
"1",
|
||||||
|
"2"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
@ -9,9 +9,17 @@
|
||||||
},
|
},
|
||||||
"compression": "xz",
|
"compression": "xz",
|
||||||
"deriver": "/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
"deriver": "/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
||||||
"downloadHash": "sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc=",
|
"downloadHash": {
|
||||||
|
"algorithm": "sha256",
|
||||||
|
"format": "base64",
|
||||||
|
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
|
||||||
|
},
|
||||||
"downloadSize": 4029176,
|
"downloadSize": 4029176,
|
||||||
"narHash": "sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc=",
|
"narHash": {
|
||||||
|
"algorithm": "sha256",
|
||||||
|
"format": "base64",
|
||||||
|
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
|
||||||
|
},
|
||||||
"narSize": 34878,
|
"narSize": 34878,
|
||||||
"references": [
|
"references": [
|
||||||
"/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
|
"/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,11 @@
|
||||||
},
|
},
|
||||||
"method": "nar"
|
"method": "nar"
|
||||||
},
|
},
|
||||||
"narHash": "sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc=",
|
"narHash": {
|
||||||
|
"algorithm": "sha256",
|
||||||
|
"format": "base64",
|
||||||
|
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
|
||||||
|
},
|
||||||
"narSize": 34878,
|
"narSize": 34878,
|
||||||
"references": [
|
"references": [
|
||||||
"/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
|
"/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
{
|
{
|
||||||
"ca": null,
|
"ca": null,
|
||||||
"deriver": null,
|
"deriver": null,
|
||||||
"narHash": "sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc=",
|
"narHash": {
|
||||||
|
"algorithm": "sha256",
|
||||||
|
"format": "base64",
|
||||||
|
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
|
||||||
|
},
|
||||||
"narSize": 0,
|
"narSize": 0,
|
||||||
"references": [],
|
"references": [],
|
||||||
"registrationTime": null,
|
"registrationTime": null,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
{
|
{
|
||||||
"ca": null,
|
"ca": null,
|
||||||
"narHash": "sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc=",
|
"narHash": {
|
||||||
|
"algorithm": "sha256",
|
||||||
|
"format": "base64",
|
||||||
|
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
|
||||||
|
},
|
||||||
"narSize": 0,
|
"narSize": 0,
|
||||||
"references": [],
|
"references": [],
|
||||||
"version": 2
|
"version": 2
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,11 @@
|
||||||
"method": "nar"
|
"method": "nar"
|
||||||
},
|
},
|
||||||
"deriver": "/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
"deriver": "/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
||||||
"narHash": "sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc=",
|
"narHash": {
|
||||||
|
"algorithm": "sha256",
|
||||||
|
"format": "base64",
|
||||||
|
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
|
||||||
|
},
|
||||||
"narSize": 34878,
|
"narSize": 34878,
|
||||||
"references": [
|
"references": [
|
||||||
"/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
|
"/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,11 @@
|
||||||
},
|
},
|
||||||
"method": "nar"
|
"method": "nar"
|
||||||
},
|
},
|
||||||
"narHash": "sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc=",
|
"narHash": {
|
||||||
|
"algorithm": "sha256",
|
||||||
|
"format": "base64",
|
||||||
|
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
|
||||||
|
},
|
||||||
"narSize": 34878,
|
"narSize": 34878,
|
||||||
"references": [
|
"references": [
|
||||||
"/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
|
"/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
|
||||||
|
|
|
||||||
28
src/libstore-tests/data/serve-protocol/build-result-2.2.json
Normal file
28
src/libstore-tests/data/serve-protocol/build-result-2.2.json
Normal 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
|
||||||
|
}
|
||||||
|
]
|
||||||
28
src/libstore-tests/data/serve-protocol/build-result-2.3.json
Normal file
28
src/libstore-tests/data/serve-protocol/build-result-2.3.json
Normal 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
|
||||||
|
}
|
||||||
|
]
|
||||||
41
src/libstore-tests/data/serve-protocol/build-result-2.6.json
Normal file
41
src/libstore-tests/data/serve-protocol/build-result-2.6.json
Normal 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
|
||||||
|
}
|
||||||
|
]
|
||||||
26
src/libstore-tests/data/serve-protocol/content-address.json
Normal file
26
src/libstore-tests/data/serve-protocol/content-address.json
Normal 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"
|
||||||
|
}
|
||||||
|
]
|
||||||
4
src/libstore-tests/data/serve-protocol/drv-output.json
Normal file
4
src/libstore-tests/data/serve-protocol/drv-output.json
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
[
|
||||||
|
"sha256:15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527!baz",
|
||||||
|
"sha256:6f869f9ea2823bda165e06076fd0de4366dead2c0e8d2dbbad277d4f15c373f5!quux"
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
[
|
||||||
|
null,
|
||||||
|
{
|
||||||
|
"hash": {
|
||||||
|
"algorithm": "sha1",
|
||||||
|
"format": "base64",
|
||||||
|
"hash": "gGemBoenViNZM3hiwqns/Fgzqwo="
|
||||||
|
},
|
||||||
|
"method": "flat"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
[
|
||||||
|
null,
|
||||||
|
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar"
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"dependentRealisations": {
|
||||||
|
"sha256:6f869f9ea2823bda165e06076fd0de4366dead2c0e8d2dbbad277d4f15c373f5!quux": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"
|
||||||
|
},
|
||||||
|
"id": "sha256:15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527!baz",
|
||||||
|
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
|
||||||
|
"signatures": [
|
||||||
|
"asdf",
|
||||||
|
"qwer"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
17
src/libstore-tests/data/serve-protocol/realisation.json
Normal file
17
src/libstore-tests/data/serve-protocol/realisation.json
Normal 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"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
22
src/libstore-tests/data/serve-protocol/set.json
Normal file
22
src/libstore-tests/data/serve-protocol/set.json
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
[
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
""
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"",
|
||||||
|
"bar",
|
||||||
|
"foo"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
""
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"",
|
||||||
|
"1",
|
||||||
|
"2"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
4
src/libstore-tests/data/serve-protocol/store-path.json
Normal file
4
src/libstore-tests/data/serve-protocol/store-path.json
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
[
|
||||||
|
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
|
||||||
|
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar"
|
||||||
|
]
|
||||||
7
src/libstore-tests/data/serve-protocol/string.json
Normal file
7
src/libstore-tests/data/serve-protocol/string.json
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
[
|
||||||
|
"",
|
||||||
|
"hi",
|
||||||
|
"white rabbit",
|
||||||
|
"大白兔",
|
||||||
|
"oh no "
|
||||||
|
]
|
||||||
|
|
@ -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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -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
|
||||||
|
}
|
||||||
|
]
|
||||||
22
src/libstore-tests/data/serve-protocol/vector.json
Normal file
22
src/libstore-tests/data/serve-protocol/vector.json
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
[
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
""
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"",
|
||||||
|
"foo",
|
||||||
|
"bar"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
""
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"",
|
||||||
|
"1",
|
||||||
|
"2"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
5
src/libstore-tests/data/worker-protocol/build-mode.json
Normal file
5
src/libstore-tests/data/worker-protocol/build-mode.json
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
[
|
||||||
|
0,
|
||||||
|
1,
|
||||||
|
2
|
||||||
|
]
|
||||||
|
|
@ -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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -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
|
||||||
|
}
|
||||||
|
]
|
||||||
26
src/libstore-tests/data/worker-protocol/content-address.json
Normal file
26
src/libstore-tests/data/worker-protocol/content-address.json
Normal 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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
[
|
||||||
|
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
|
||||||
|
{
|
||||||
|
"drvPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
||||||
|
"outputs": [
|
||||||
|
"*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"drvPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
||||||
|
"outputs": [
|
||||||
|
"x",
|
||||||
|
"y"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
[
|
||||||
|
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
|
||||||
|
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv",
|
||||||
|
{
|
||||||
|
"drvPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
||||||
|
"outputs": [
|
||||||
|
"*"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"drvPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
|
||||||
|
"outputs": [
|
||||||
|
"x",
|
||||||
|
"y"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
4
src/libstore-tests/data/worker-protocol/drv-output.json
Normal file
4
src/libstore-tests/data/worker-protocol/drv-output.json
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
[
|
||||||
|
"sha256:15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527!baz",
|
||||||
|
"sha256:6f869f9ea2823bda165e06076fd0de4366dead2c0e8d2dbbad277d4f15c373f5!quux"
|
||||||
|
]
|
||||||
|
|
@ -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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
[
|
||||||
|
null,
|
||||||
|
{
|
||||||
|
"hash": {
|
||||||
|
"algorithm": "sha1",
|
||||||
|
"format": "base64",
|
||||||
|
"hash": "gGemBoenViNZM3hiwqns/Fgzqwo="
|
||||||
|
},
|
||||||
|
"method": "flat"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
[
|
||||||
|
null,
|
||||||
|
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar"
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
[
|
||||||
|
null,
|
||||||
|
true,
|
||||||
|
false
|
||||||
|
]
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"dependentRealisations": {
|
||||||
|
"sha256:6f869f9ea2823bda165e06076fd0de4366dead2c0e8d2dbbad277d4f15c373f5!quux": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"
|
||||||
|
},
|
||||||
|
"id": "sha256:15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527!baz",
|
||||||
|
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
|
||||||
|
"signatures": [
|
||||||
|
"asdf",
|
||||||
|
"qwer"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
17
src/libstore-tests/data/worker-protocol/realisation.json
Normal file
17
src/libstore-tests/data/worker-protocol/realisation.json
Normal 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"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
22
src/libstore-tests/data/worker-protocol/set.json
Normal file
22
src/libstore-tests/data/worker-protocol/set.json
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
[
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
""
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"",
|
||||||
|
"bar",
|
||||||
|
"foo"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
""
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"",
|
||||||
|
"1",
|
||||||
|
"2"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
4
src/libstore-tests/data/worker-protocol/store-path.json
Normal file
4
src/libstore-tests/data/worker-protocol/store-path.json
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
[
|
||||||
|
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
|
||||||
|
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo-bar"
|
||||||
|
]
|
||||||
7
src/libstore-tests/data/worker-protocol/string.json
Normal file
7
src/libstore-tests/data/worker-protocol/string.json
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
[
|
||||||
|
"",
|
||||||
|
"hi",
|
||||||
|
"white rabbit",
|
||||||
|
"大白兔",
|
||||||
|
"oh no "
|
||||||
|
]
|
||||||
|
|
@ -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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -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
|
||||||
|
}
|
||||||
|
]
|
||||||
22
src/libstore-tests/data/worker-protocol/vector.json
Normal file
22
src/libstore-tests/data/worker-protocol/vector.json
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
[
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
""
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"",
|
||||||
|
"foo",
|
||||||
|
"bar"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
""
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"",
|
||||||
|
"1",
|
||||||
|
"2"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
@ -65,7 +65,7 @@ static NarInfo makeNarInfo(const Store & store, bool includeImpureInfo)
|
||||||
readTest(#STEM, [&](const auto & encoded_) { \
|
readTest(#STEM, [&](const auto & encoded_) { \
|
||||||
auto encoded = json::parse(encoded_); \
|
auto encoded = json::parse(encoded_); \
|
||||||
auto expected = makeNarInfo(*store, PURE); \
|
auto expected = makeNarInfo(*store, PURE); \
|
||||||
NarInfo got = NarInfo::fromJSON(*store, expected.path, encoded); \
|
auto got = UnkeyedNarInfo::fromJSON(&*store, encoded); \
|
||||||
ASSERT_EQ(got, expected); \
|
ASSERT_EQ(got, expected); \
|
||||||
}); \
|
}); \
|
||||||
} \
|
} \
|
||||||
|
|
@ -74,7 +74,7 @@ static NarInfo makeNarInfo(const Store & store, bool includeImpureInfo)
|
||||||
{ \
|
{ \
|
||||||
writeTest( \
|
writeTest( \
|
||||||
#STEM, \
|
#STEM, \
|
||||||
[&]() -> json { return makeNarInfo(*store, PURE).toJSON(*store, PURE, HashFormat::SRI); }, \
|
[&]() -> json { return makeNarInfo(*store, PURE).toJSON(&*store, PURE); }, \
|
||||||
[](const auto & file) { return json::parse(readFile(file)); }, \
|
[](const auto & file) { return json::parse(readFile(file)); }, \
|
||||||
[](const auto & file, const auto & got) { return writeFile(file, got.dump(2) + "\n"); }); \
|
[](const auto & file, const auto & got) { return writeFile(file, got.dump(2) + "\n"); }); \
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ static UnkeyedValidPathInfo makeFull(const Store & store, bool includeImpureInfo
|
||||||
{ \
|
{ \
|
||||||
readTest(#STEM, [&](const auto & encoded_) { \
|
readTest(#STEM, [&](const auto & encoded_) { \
|
||||||
auto encoded = json::parse(encoded_); \
|
auto encoded = json::parse(encoded_); \
|
||||||
UnkeyedValidPathInfo got = UnkeyedValidPathInfo::fromJSON(*store, encoded); \
|
UnkeyedValidPathInfo got = UnkeyedValidPathInfo::fromJSON(&*store, encoded); \
|
||||||
auto expected = OBJ; \
|
auto expected = OBJ; \
|
||||||
ASSERT_EQ(got, expected); \
|
ASSERT_EQ(got, expected); \
|
||||||
}); \
|
}); \
|
||||||
|
|
@ -80,7 +80,7 @@ static UnkeyedValidPathInfo makeFull(const Store & store, bool includeImpureInfo
|
||||||
{ \
|
{ \
|
||||||
writeTest( \
|
writeTest( \
|
||||||
#STEM, \
|
#STEM, \
|
||||||
[&]() -> json { return OBJ.toJSON(*store, PURE, HashFormat::SRI); }, \
|
[&]() -> json { return OBJ.toJSON(&*store, PURE); }, \
|
||||||
[](const auto & file) { return json::parse(readFile(file)); }, \
|
[](const auto & file) { return json::parse(readFile(file)); }, \
|
||||||
[](const auto & file, const auto & got) { return writeFile(file, got.dump(2) + "\n"); }); \
|
[](const auto & file, const auto & got) { return writeFile(file, got.dump(2) + "\n"); }); \
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include "nix/util/json-utils.hh"
|
||||||
#include "nix/store/serve-protocol.hh"
|
#include "nix/store/serve-protocol.hh"
|
||||||
#include "nix/store/serve-protocol-impl.hh"
|
#include "nix/store/serve-protocol-impl.hh"
|
||||||
#include "nix/store/serve-protocol-connection.hh"
|
#include "nix/store/serve-protocol-connection.hh"
|
||||||
|
|
@ -334,7 +335,7 @@ VERSIONED_CHARACTERIZATION_TEST(
|
||||||
}),
|
}),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
VERSIONED_CHARACTERIZATION_TEST(
|
VERSIONED_CHARACTERIZATION_TEST_NO_JSON(
|
||||||
ServeProtoTest,
|
ServeProtoTest,
|
||||||
build_options_2_1,
|
build_options_2_1,
|
||||||
"build-options-2.1",
|
"build-options-2.1",
|
||||||
|
|
@ -344,7 +345,7 @@ VERSIONED_CHARACTERIZATION_TEST(
|
||||||
.buildTimeout = 6,
|
.buildTimeout = 6,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
VERSIONED_CHARACTERIZATION_TEST(
|
VERSIONED_CHARACTERIZATION_TEST_NO_JSON(
|
||||||
ServeProtoTest,
|
ServeProtoTest,
|
||||||
build_options_2_2,
|
build_options_2_2,
|
||||||
"build-options-2.2",
|
"build-options-2.2",
|
||||||
|
|
@ -355,7 +356,7 @@ VERSIONED_CHARACTERIZATION_TEST(
|
||||||
.maxLogSize = 7,
|
.maxLogSize = 7,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
VERSIONED_CHARACTERIZATION_TEST(
|
VERSIONED_CHARACTERIZATION_TEST_NO_JSON(
|
||||||
ServeProtoTest,
|
ServeProtoTest,
|
||||||
build_options_2_3,
|
build_options_2_3,
|
||||||
"build-options-2.3",
|
"build-options-2.3",
|
||||||
|
|
@ -368,7 +369,7 @@ VERSIONED_CHARACTERIZATION_TEST(
|
||||||
.enforceDeterminism = true,
|
.enforceDeterminism = true,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
VERSIONED_CHARACTERIZATION_TEST(
|
VERSIONED_CHARACTERIZATION_TEST_NO_JSON(
|
||||||
ServeProtoTest,
|
ServeProtoTest,
|
||||||
build_options_2_7,
|
build_options_2_7,
|
||||||
"build-options-2.7",
|
"build-options-2.7",
|
||||||
|
|
@ -439,7 +440,7 @@ VERSIONED_CHARACTERIZATION_TEST(
|
||||||
|
|
||||||
TEST_F(ServeProtoTest, handshake_log)
|
TEST_F(ServeProtoTest, handshake_log)
|
||||||
{
|
{
|
||||||
CharacterizationTest::writeTest("handshake-to-client", [&]() -> std::string {
|
CharacterizationTest::writeTest("handshake-to-client.bin", [&]() -> std::string {
|
||||||
StringSink toClientLog;
|
StringSink toClientLog;
|
||||||
|
|
||||||
Pipe toClient, toServer;
|
Pipe toClient, toServer;
|
||||||
|
|
@ -475,7 +476,7 @@ struct NullBufferedSink : BufferedSink
|
||||||
|
|
||||||
TEST_F(ServeProtoTest, handshake_client_replay)
|
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;
|
NullBufferedSink nullSink;
|
||||||
|
|
||||||
StringSource in{toClientLog};
|
StringSource in{toClientLog};
|
||||||
|
|
@ -487,7 +488,7 @@ TEST_F(ServeProtoTest, handshake_client_replay)
|
||||||
|
|
||||||
TEST_F(ServeProtoTest, handshake_client_truncated_replay_throws)
|
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) {
|
for (size_t len = 0; len < toClientLog.size(); ++len) {
|
||||||
NullBufferedSink nullSink;
|
NullBufferedSink nullSink;
|
||||||
auto substring = toClientLog.substr(0, len);
|
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)
|
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) {
|
for (size_t idx = 0; idx < toClientLog.size(); ++idx) {
|
||||||
// corrupt a copy
|
// corrupt a copy
|
||||||
std::string toClientLogCorrupt = toClientLog;
|
std::string toClientLogCorrupt = toClientLog;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
#include "nix/util/json-utils.hh"
|
||||||
#include "nix/store/worker-protocol.hh"
|
#include "nix/store/worker-protocol.hh"
|
||||||
#include "nix/store/worker-protocol-connection.hh"
|
#include "nix/store/worker-protocol-connection.hh"
|
||||||
#include "nix/store/worker-protocol-impl.hh"
|
#include "nix/store/worker-protocol-impl.hh"
|
||||||
|
|
@ -649,7 +650,7 @@ VERSIONED_CHARACTERIZATION_TEST(
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
|
|
||||||
VERSIONED_CHARACTERIZATION_TEST(
|
VERSIONED_CHARACTERIZATION_TEST_NO_JSON(
|
||||||
WorkerProtoTest,
|
WorkerProtoTest,
|
||||||
clientHandshakeInfo_1_30,
|
clientHandshakeInfo_1_30,
|
||||||
"client-handshake-info_1_30",
|
"client-handshake-info_1_30",
|
||||||
|
|
@ -658,7 +659,7 @@ VERSIONED_CHARACTERIZATION_TEST(
|
||||||
{},
|
{},
|
||||||
}))
|
}))
|
||||||
|
|
||||||
VERSIONED_CHARACTERIZATION_TEST(
|
VERSIONED_CHARACTERIZATION_TEST_NO_JSON(
|
||||||
WorkerProtoTest,
|
WorkerProtoTest,
|
||||||
clientHandshakeInfo_1_33,
|
clientHandshakeInfo_1_33,
|
||||||
"client-handshake-info_1_33",
|
"client-handshake-info_1_33",
|
||||||
|
|
@ -672,7 +673,7 @@ VERSIONED_CHARACTERIZATION_TEST(
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
|
|
||||||
VERSIONED_CHARACTERIZATION_TEST(
|
VERSIONED_CHARACTERIZATION_TEST_NO_JSON(
|
||||||
WorkerProtoTest,
|
WorkerProtoTest,
|
||||||
clientHandshakeInfo_1_35,
|
clientHandshakeInfo_1_35,
|
||||||
"client-handshake-info_1_35",
|
"client-handshake-info_1_35",
|
||||||
|
|
@ -690,7 +691,7 @@ VERSIONED_CHARACTERIZATION_TEST(
|
||||||
|
|
||||||
TEST_F(WorkerProtoTest, handshake_log)
|
TEST_F(WorkerProtoTest, handshake_log)
|
||||||
{
|
{
|
||||||
CharacterizationTest::writeTest("handshake-to-client", [&]() -> std::string {
|
CharacterizationTest::writeTest("handshake-to-client.bin", [&]() -> std::string {
|
||||||
StringSink toClientLog;
|
StringSink toClientLog;
|
||||||
|
|
||||||
Pipe toClient, toServer;
|
Pipe toClient, toServer;
|
||||||
|
|
@ -751,7 +752,7 @@ struct NullBufferedSink : BufferedSink
|
||||||
|
|
||||||
TEST_F(WorkerProtoTest, handshake_client_replay)
|
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;
|
NullBufferedSink nullSink;
|
||||||
|
|
||||||
StringSource in{toClientLog};
|
StringSource in{toClientLog};
|
||||||
|
|
@ -764,7 +765,7 @@ TEST_F(WorkerProtoTest, handshake_client_replay)
|
||||||
|
|
||||||
TEST_F(WorkerProtoTest, handshake_client_truncated_replay_throws)
|
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) {
|
for (size_t len = 0; len < toClientLog.size(); ++len) {
|
||||||
NullBufferedSink nullSink;
|
NullBufferedSink nullSink;
|
||||||
auto substring = toClientLog.substr(0, len);
|
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)
|
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) {
|
for (size_t idx = 0; idx < toClientLog.size(); ++idx) {
|
||||||
// corrupt a copy
|
// corrupt a copy
|
||||||
std::string toClientLogCorrupt = toClientLog;
|
std::string toClientLogCorrupt = toClientLog;
|
||||||
|
|
|
||||||
|
|
@ -153,4 +153,20 @@ BuildResult adl_serializer<BuildResult>::from_json(const json & _json)
|
||||||
return br;
|
return br;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KeyedBuildResult adl_serializer<KeyedBuildResult>::from_json(const json & json0)
|
||||||
|
{
|
||||||
|
auto json = getObject(json0);
|
||||||
|
|
||||||
|
return KeyedBuildResult{
|
||||||
|
adl_serializer<BuildResult>::from_json(json0),
|
||||||
|
valueAt(json, "path"),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void adl_serializer<KeyedBuildResult>::to_json(json & json, const KeyedBuildResult & kbr)
|
||||||
|
{
|
||||||
|
adl_serializer<BuildResult>::to_json(json, kbr);
|
||||||
|
json["path"] = kbr.path;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace nlohmann
|
} // namespace nlohmann
|
||||||
|
|
|
||||||
|
|
@ -423,15 +423,6 @@ void adl_serializer<DerivationOptions>::to_json(json & json, const DerivationOpt
|
||||||
json["allowSubstitutes"] = o.allowSubstitutes;
|
json["allowSubstitutes"] = o.allowSubstitutes;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
static inline std::optional<T> ptrToOwned(const json * ptr)
|
|
||||||
{
|
|
||||||
if (ptr)
|
|
||||||
return std::optional{*ptr};
|
|
||||||
else
|
|
||||||
return std::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
DerivationOptions::OutputChecks adl_serializer<DerivationOptions::OutputChecks>::from_json(const json & json_)
|
DerivationOptions::OutputChecks adl_serializer<DerivationOptions::OutputChecks>::from_json(const json & json_)
|
||||||
{
|
{
|
||||||
auto & json = getObject(json_);
|
auto & json = getObject(json_);
|
||||||
|
|
|
||||||
|
|
@ -178,3 +178,4 @@ struct KeyedBuildResult : BuildResult
|
||||||
} // namespace nix
|
} // namespace nix
|
||||||
|
|
||||||
JSON_IMPL(nix::BuildResult)
|
JSON_IMPL(nix::BuildResult)
|
||||||
|
JSON_IMPL(nix::KeyedBuildResult)
|
||||||
|
|
|
||||||
|
|
@ -9,17 +9,38 @@ namespace nix {
|
||||||
|
|
||||||
struct StoreDirConfig;
|
struct StoreDirConfig;
|
||||||
|
|
||||||
struct NarInfo : ValidPathInfo
|
struct UnkeyedNarInfo : virtual UnkeyedValidPathInfo
|
||||||
{
|
{
|
||||||
std::string url;
|
std::string url;
|
||||||
std::string compression;
|
std::string compression;
|
||||||
std::optional<Hash> fileHash;
|
std::optional<Hash> fileHash;
|
||||||
uint64_t fileSize = 0;
|
uint64_t fileSize = 0;
|
||||||
|
|
||||||
|
UnkeyedNarInfo(UnkeyedValidPathInfo info)
|
||||||
|
: UnkeyedValidPathInfo(std::move(info))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const UnkeyedNarInfo &) const = default;
|
||||||
|
// TODO libc++ 16 (used by darwin) missing `std::optional::operator <=>`, can't do yet
|
||||||
|
// auto operator <=>(const NarInfo &) const = default;
|
||||||
|
|
||||||
|
nlohmann::json toJSON(const StoreDirConfig * store, bool includeImpureInfo) const override;
|
||||||
|
static UnkeyedNarInfo fromJSON(const StoreDirConfig * store, const nlohmann::json & json);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Key and the extra NAR fields
|
||||||
|
*/
|
||||||
|
struct NarInfo : ValidPathInfo, UnkeyedNarInfo
|
||||||
|
{
|
||||||
NarInfo() = delete;
|
NarInfo() = delete;
|
||||||
|
|
||||||
NarInfo(ValidPathInfo info)
|
NarInfo(ValidPathInfo info)
|
||||||
: ValidPathInfo{std::move(info)}
|
: UnkeyedValidPathInfo(std::move(static_cast<UnkeyedValidPathInfo &&>(info)))
|
||||||
|
// later moves will be partially ignored
|
||||||
|
, ValidPathInfo(std::move(info))
|
||||||
|
, UnkeyedNarInfo(std::move(info))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -37,13 +58,10 @@ struct NarInfo : ValidPathInfo
|
||||||
NarInfo(const StoreDirConfig & store, const std::string & s, const std::string & whence);
|
NarInfo(const StoreDirConfig & store, const std::string & s, const std::string & whence);
|
||||||
|
|
||||||
bool operator==(const NarInfo &) const = default;
|
bool operator==(const NarInfo &) const = default;
|
||||||
// TODO libc++ 16 (used by darwin) missing `std::optional::operator <=>`, can't do yet
|
|
||||||
// auto operator <=>(const NarInfo &) const = default;
|
|
||||||
|
|
||||||
std::string to_string(const StoreDirConfig & store) const;
|
std::string to_string(const StoreDirConfig & store) const;
|
||||||
|
|
||||||
nlohmann::json toJSON(const StoreDirConfig & store, bool includeImpureInfo, HashFormat hashFormat) const override;
|
|
||||||
static NarInfo fromJSON(const StoreDirConfig & store, const StorePath & path, const nlohmann::json & json);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace nix
|
} // namespace nix
|
||||||
|
|
||||||
|
JSON_IMPL(nix::UnkeyedNarInfo)
|
||||||
|
|
|
||||||
|
|
@ -117,11 +117,11 @@ struct UnkeyedValidPathInfo
|
||||||
* @param includeImpureInfo If true, variable elements such as the
|
* @param includeImpureInfo If true, variable elements such as the
|
||||||
* registration time are included.
|
* registration time are included.
|
||||||
*/
|
*/
|
||||||
virtual nlohmann::json toJSON(const StoreDirConfig & store, bool includeImpureInfo, HashFormat hashFormat) const;
|
virtual nlohmann::json toJSON(const StoreDirConfig * store, bool includeImpureInfo) const;
|
||||||
static UnkeyedValidPathInfo fromJSON(const StoreDirConfig & store, const nlohmann::json & json);
|
static UnkeyedValidPathInfo fromJSON(const StoreDirConfig * store, const nlohmann::json & json);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ValidPathInfo : UnkeyedValidPathInfo
|
struct ValidPathInfo : virtual UnkeyedValidPathInfo
|
||||||
{
|
{
|
||||||
StorePath path;
|
StorePath path;
|
||||||
|
|
||||||
|
|
@ -174,10 +174,14 @@ struct ValidPathInfo : UnkeyedValidPathInfo
|
||||||
|
|
||||||
ValidPathInfo(StorePath && path, UnkeyedValidPathInfo info)
|
ValidPathInfo(StorePath && path, UnkeyedValidPathInfo info)
|
||||||
: UnkeyedValidPathInfo(info)
|
: UnkeyedValidPathInfo(info)
|
||||||
, path(std::move(path)) {};
|
, path(std::move(path))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
ValidPathInfo(const StorePath & path, UnkeyedValidPathInfo info)
|
ValidPathInfo(const StorePath & path, UnkeyedValidPathInfo info)
|
||||||
: UnkeyedValidPathInfo(info)
|
: ValidPathInfo(StorePath{path}, std::move(info))
|
||||||
, path(path) {};
|
{
|
||||||
|
}
|
||||||
|
|
||||||
static ValidPathInfo
|
static ValidPathInfo
|
||||||
makeFromCA(const StoreDirConfig & store, std::string_view name, ContentAddressWithReferences && ca, Hash narHash);
|
makeFromCA(const StoreDirConfig & store, std::string_view name, ContentAddressWithReferences && ca, Hash narHash);
|
||||||
|
|
@ -191,3 +195,6 @@ static_assert(std::is_move_constructible_v<ValidPathInfo>);
|
||||||
using ValidPathInfos = std::map<StorePath, ValidPathInfo>;
|
using ValidPathInfos = std::map<StorePath, ValidPathInfo>;
|
||||||
|
|
||||||
} // namespace nix
|
} // namespace nix
|
||||||
|
|
||||||
|
JSON_IMPL(nix::UnkeyedValidPathInfo)
|
||||||
|
JSON_IMPL(nix::ValidPathInfo)
|
||||||
|
|
|
||||||
|
|
@ -182,5 +182,6 @@ public:
|
||||||
|
|
||||||
} // namespace nix
|
} // namespace nix
|
||||||
|
|
||||||
|
JSON_IMPL(nix::DrvOutput)
|
||||||
JSON_IMPL(nix::UnkeyedRealisation)
|
JSON_IMPL(nix::UnkeyedRealisation)
|
||||||
JSON_IMPL(nix::Realisation)
|
JSON_IMPL(nix::Realisation)
|
||||||
|
|
|
||||||
|
|
@ -1004,4 +1004,10 @@ const ContentAddress * getDerivationCA(const BasicDerivation & drv);
|
||||||
std::map<DrvOutput, StorePath>
|
std::map<DrvOutput, StorePath>
|
||||||
drvOutputReferences(Store & store, const Derivation & drv, const StorePath & outputPath, Store * evalStore = nullptr);
|
drvOutputReferences(Store & store, const Derivation & drv, const StorePath & outputPath, Store * evalStore = nullptr);
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct json_avoids_null<TrustedFlag> : std::true_type
|
||||||
|
{};
|
||||||
|
|
||||||
} // namespace nix
|
} // namespace nix
|
||||||
|
|
||||||
|
JSON_IMPL(nix::TrustedFlag)
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
#include "nix/util/closure.hh"
|
#include "nix/util/closure.hh"
|
||||||
#include "nix/store/filetransfer.hh"
|
#include "nix/store/filetransfer.hh"
|
||||||
#include "nix/util/strings.hh"
|
#include "nix/util/strings.hh"
|
||||||
|
#include "nix/util/json-utils.hh"
|
||||||
|
|
||||||
#include <boost/unordered/unordered_flat_set.hpp>
|
#include <boost/unordered/unordered_flat_set.hpp>
|
||||||
|
|
||||||
|
|
@ -479,3 +480,19 @@ OutputPathMap resolveDerivedPath(Store & store, const DerivedPath::Built & bfd)
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace nix
|
} // namespace nix
|
||||||
|
|
||||||
|
namespace nlohmann {
|
||||||
|
|
||||||
|
using namespace nix;
|
||||||
|
|
||||||
|
TrustedFlag adl_serializer<TrustedFlag>::from_json(const json & json)
|
||||||
|
{
|
||||||
|
return getBoolean(json) ? TrustedFlag::Trusted : TrustedFlag::NotTrusted;
|
||||||
|
}
|
||||||
|
|
||||||
|
void adl_serializer<TrustedFlag>::to_json(json & json, const TrustedFlag & trustedFlag)
|
||||||
|
{
|
||||||
|
json = static_cast<bool>(trustedFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace nlohmann
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,9 @@
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
NarInfo::NarInfo(const StoreDirConfig & store, const std::string & s, const std::string & whence)
|
NarInfo::NarInfo(const StoreDirConfig & store, const std::string & s, const std::string & whence)
|
||||||
: ValidPathInfo(StorePath(StorePath::dummy), Hash(Hash::dummy)) // FIXME: hack
|
: UnkeyedValidPathInfo(Hash::dummy) // FIXME: hack
|
||||||
|
, ValidPathInfo(StorePath::dummy, static_cast<const UnkeyedValidPathInfo &>(*this)) // FIXME: hack
|
||||||
|
, UnkeyedNarInfo(static_cast<const UnkeyedValidPathInfo &>(*this))
|
||||||
{
|
{
|
||||||
unsigned line = 1;
|
unsigned line = 1;
|
||||||
|
|
||||||
|
|
@ -130,11 +132,11 @@ std::string NarInfo::to_string(const StoreDirConfig & store) const
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json NarInfo::toJSON(const StoreDirConfig & store, bool includeImpureInfo, HashFormat hashFormat) const
|
nlohmann::json UnkeyedNarInfo::toJSON(const StoreDirConfig * store, bool includeImpureInfo) const
|
||||||
{
|
{
|
||||||
using nlohmann::json;
|
using nlohmann::json;
|
||||||
|
|
||||||
auto jsonObject = ValidPathInfo::toJSON(store, includeImpureInfo, hashFormat);
|
auto jsonObject = UnkeyedValidPathInfo::toJSON(store, includeImpureInfo);
|
||||||
|
|
||||||
if (includeImpureInfo) {
|
if (includeImpureInfo) {
|
||||||
if (!url.empty())
|
if (!url.empty())
|
||||||
|
|
@ -142,7 +144,7 @@ nlohmann::json NarInfo::toJSON(const StoreDirConfig & store, bool includeImpureI
|
||||||
if (!compression.empty())
|
if (!compression.empty())
|
||||||
jsonObject["compression"] = compression;
|
jsonObject["compression"] = compression;
|
||||||
if (fileHash)
|
if (fileHash)
|
||||||
jsonObject["downloadHash"] = fileHash->to_string(hashFormat, true);
|
jsonObject["downloadHash"] = *fileHash;
|
||||||
if (fileSize)
|
if (fileSize)
|
||||||
jsonObject["downloadSize"] = fileSize;
|
jsonObject["downloadSize"] = fileSize;
|
||||||
}
|
}
|
||||||
|
|
@ -150,30 +152,43 @@ nlohmann::json NarInfo::toJSON(const StoreDirConfig & store, bool includeImpureI
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
NarInfo NarInfo::fromJSON(const StoreDirConfig & store, const StorePath & path, const nlohmann::json & json)
|
UnkeyedNarInfo UnkeyedNarInfo::fromJSON(const StoreDirConfig * store, const nlohmann::json & json)
|
||||||
{
|
{
|
||||||
using nlohmann::detail::value_t;
|
using nlohmann::detail::value_t;
|
||||||
|
|
||||||
NarInfo res{ValidPathInfo{
|
UnkeyedNarInfo res{UnkeyedValidPathInfo::fromJSON(store, json)};
|
||||||
path,
|
|
||||||
UnkeyedValidPathInfo::fromJSON(store, json),
|
|
||||||
}};
|
|
||||||
|
|
||||||
auto & obj = getObject(json);
|
auto & obj = getObject(json);
|
||||||
|
|
||||||
if (json.contains("url"))
|
if (auto * url = get(obj, "url"))
|
||||||
res.url = getString(valueAt(obj, "url"));
|
res.url = getString(*url);
|
||||||
|
|
||||||
if (json.contains("compression"))
|
if (auto * compression = get(obj, "compression"))
|
||||||
res.compression = getString(valueAt(obj, "compression"));
|
res.compression = getString(*compression);
|
||||||
|
|
||||||
if (json.contains("downloadHash"))
|
if (auto * downloadHash = get(obj, "downloadHash"))
|
||||||
res.fileHash = Hash::parseAny(getString(valueAt(obj, "downloadHash")), std::nullopt);
|
res.fileHash = *downloadHash;
|
||||||
|
|
||||||
if (json.contains("downloadSize"))
|
if (auto * downloadSize = get(obj, "downloadSize"))
|
||||||
res.fileSize = getUnsigned(valueAt(obj, "downloadSize"));
|
res.fileSize = getUnsigned(*downloadSize);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace nix
|
} // namespace nix
|
||||||
|
|
||||||
|
namespace nlohmann {
|
||||||
|
|
||||||
|
using namespace nix;
|
||||||
|
|
||||||
|
UnkeyedNarInfo adl_serializer<UnkeyedNarInfo>::from_json(const json & json)
|
||||||
|
{
|
||||||
|
return UnkeyedNarInfo::fromJSON(nullptr, json);
|
||||||
|
}
|
||||||
|
|
||||||
|
void adl_serializer<UnkeyedNarInfo>::to_json(json & json, const UnkeyedNarInfo & c)
|
||||||
|
{
|
||||||
|
json = c.toJSON(nullptr, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace nlohmann
|
||||||
|
|
|
||||||
|
|
@ -149,8 +149,7 @@ ValidPathInfo ValidPathInfo::makeFromCA(
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
nlohmann::json
|
nlohmann::json UnkeyedValidPathInfo::toJSON(const StoreDirConfig * store, bool includeImpureInfo) const
|
||||||
UnkeyedValidPathInfo::toJSON(const StoreDirConfig & store, bool includeImpureInfo, HashFormat hashFormat) const
|
|
||||||
{
|
{
|
||||||
using nlohmann::json;
|
using nlohmann::json;
|
||||||
|
|
||||||
|
|
@ -158,19 +157,21 @@ UnkeyedValidPathInfo::toJSON(const StoreDirConfig & store, bool includeImpureInf
|
||||||
|
|
||||||
jsonObject["version"] = 2;
|
jsonObject["version"] = 2;
|
||||||
|
|
||||||
jsonObject["narHash"] = narHash.to_string(hashFormat, true);
|
jsonObject["narHash"] = narHash;
|
||||||
jsonObject["narSize"] = narSize;
|
jsonObject["narSize"] = narSize;
|
||||||
|
|
||||||
{
|
{
|
||||||
auto & jsonRefs = jsonObject["references"] = json::array();
|
auto & jsonRefs = jsonObject["references"] = json::array();
|
||||||
for (auto & ref : references)
|
for (auto & ref : references)
|
||||||
jsonRefs.emplace_back(store.printStorePath(ref));
|
jsonRefs.emplace_back(store ? static_cast<json>(store->printStorePath(ref)) : static_cast<json>(ref));
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonObject["ca"] = ca;
|
jsonObject["ca"] = ca;
|
||||||
|
|
||||||
if (includeImpureInfo) {
|
if (includeImpureInfo) {
|
||||||
jsonObject["deriver"] = deriver ? (std::optional{store.printStorePath(*deriver)}) : std::nullopt;
|
jsonObject["deriver"] = deriver ? (store ? static_cast<json>(std::optional{store->printStorePath(*deriver)})
|
||||||
|
: static_cast<json>(std::optional{*deriver}))
|
||||||
|
: static_cast<json>(std::optional<StorePath>{});
|
||||||
|
|
||||||
jsonObject["registrationTime"] = registrationTime ? (std::optional{registrationTime}) : std::nullopt;
|
jsonObject["registrationTime"] = registrationTime ? (std::optional{registrationTime}) : std::nullopt;
|
||||||
|
|
||||||
|
|
@ -184,7 +185,7 @@ UnkeyedValidPathInfo::toJSON(const StoreDirConfig & store, bool includeImpureInf
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
UnkeyedValidPathInfo UnkeyedValidPathInfo::fromJSON(const StoreDirConfig & store, const nlohmann::json & _json)
|
UnkeyedValidPathInfo UnkeyedValidPathInfo::fromJSON(const StoreDirConfig * store, const nlohmann::json & _json)
|
||||||
{
|
{
|
||||||
UnkeyedValidPathInfo res{
|
UnkeyedValidPathInfo res{
|
||||||
Hash(Hash::dummy),
|
Hash(Hash::dummy),
|
||||||
|
|
@ -192,44 +193,34 @@ UnkeyedValidPathInfo UnkeyedValidPathInfo::fromJSON(const StoreDirConfig & store
|
||||||
|
|
||||||
auto & json = getObject(_json);
|
auto & json = getObject(_json);
|
||||||
|
|
||||||
// Check version (optional for backward compatibility)
|
{
|
||||||
nlohmann::json::number_unsigned_t version = 1;
|
auto version = getUnsigned(valueAt(json, "version"));
|
||||||
if (json.contains("version")) {
|
if (version != 2)
|
||||||
version = getUnsigned(valueAt(json, "version"));
|
throw Error("Unsupported path info JSON format version %d, only version 2 is currently supported", version);
|
||||||
if (version != 1 && version != 2) {
|
|
||||||
throw Error("Unsupported path info JSON format version %d, expected 1 through 2", version);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res.narHash = Hash::parseAny(getString(valueAt(json, "narHash")), std::nullopt);
|
res.narHash = valueAt(json, "narHash");
|
||||||
res.narSize = getUnsigned(valueAt(json, "narSize"));
|
res.narSize = getUnsigned(valueAt(json, "narSize"));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto references = getStringList(valueAt(json, "references"));
|
auto references = getStringList(valueAt(json, "references"));
|
||||||
for (auto & input : references)
|
for (auto & input : references)
|
||||||
res.references.insert(store.parseStorePath(static_cast<const std::string &>(input)));
|
res.references.insert(store ? store->parseStorePath(getString(input)) : static_cast<StorePath>(input));
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
e.addTrace({}, "while reading key 'references'");
|
e.addTrace({}, "while reading key 'references'");
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
// New format as this as nullable but mandatory field; handling
|
try {
|
||||||
// missing is for back-compat.
|
res.ca = ptrToOwned<ContentAddress>(getNullable(valueAt(json, "ca")));
|
||||||
if (auto * rawCa0 = optionalValueAt(json, "ca"))
|
} catch (Error & e) {
|
||||||
if (auto * rawCa = getNullable(*rawCa0))
|
e.addTrace({}, "while reading key 'ca'");
|
||||||
switch (version) {
|
throw;
|
||||||
case 1:
|
|
||||||
// old string format also used in SQLite DB and .narinfo
|
|
||||||
res.ca = ContentAddress::parse(getString(*rawCa));
|
|
||||||
break;
|
|
||||||
case 2 ... std::numeric_limits<decltype(version)>::max():
|
|
||||||
res.ca = *rawCa;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (auto * rawDeriver0 = optionalValueAt(json, "deriver"))
|
if (auto * rawDeriver0 = optionalValueAt(json, "deriver"))
|
||||||
if (auto * rawDeriver = getNullable(*rawDeriver0))
|
if (auto * rawDeriver = getNullable(*rawDeriver0))
|
||||||
res.deriver = store.parseStorePath(getString(*rawDeriver));
|
res.deriver = store ? store->parseStorePath(getString(*rawDeriver)) : static_cast<StorePath>(*rawDeriver);
|
||||||
|
|
||||||
if (auto * rawRegistrationTime0 = optionalValueAt(json, "registrationTime"))
|
if (auto * rawRegistrationTime0 = optionalValueAt(json, "registrationTime"))
|
||||||
if (auto * rawRegistrationTime = getNullable(*rawRegistrationTime0))
|
if (auto * rawRegistrationTime = getNullable(*rawRegistrationTime0))
|
||||||
|
|
@ -245,3 +236,35 @@ UnkeyedValidPathInfo UnkeyedValidPathInfo::fromJSON(const StoreDirConfig & store
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace nix
|
} // namespace nix
|
||||||
|
|
||||||
|
namespace nlohmann {
|
||||||
|
|
||||||
|
using namespace nix;
|
||||||
|
|
||||||
|
UnkeyedValidPathInfo adl_serializer<UnkeyedValidPathInfo>::from_json(const json & json)
|
||||||
|
{
|
||||||
|
return UnkeyedValidPathInfo::fromJSON(nullptr, json);
|
||||||
|
}
|
||||||
|
|
||||||
|
void adl_serializer<UnkeyedValidPathInfo>::to_json(json & json, const UnkeyedValidPathInfo & c)
|
||||||
|
{
|
||||||
|
json = c.toJSON(nullptr, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
ValidPathInfo adl_serializer<ValidPathInfo>::from_json(const json & json0)
|
||||||
|
{
|
||||||
|
auto json = getObject(json0);
|
||||||
|
|
||||||
|
return ValidPathInfo{
|
||||||
|
valueAt(json, "path"),
|
||||||
|
adl_serializer<UnkeyedValidPathInfo>::from_json(json0),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void adl_serializer<ValidPathInfo>::to_json(json & json, const ValidPathInfo & v)
|
||||||
|
{
|
||||||
|
adl_serializer<UnkeyedValidPathInfo>::to_json(json, v);
|
||||||
|
json["path"] = v.path;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace nlohmann
|
||||||
|
|
|
||||||
|
|
@ -144,6 +144,16 @@ namespace nlohmann {
|
||||||
|
|
||||||
using namespace nix;
|
using namespace nix;
|
||||||
|
|
||||||
|
DrvOutput adl_serializer<DrvOutput>::from_json(const json & json)
|
||||||
|
{
|
||||||
|
return DrvOutput::parse(getString(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
void adl_serializer<DrvOutput>::to_json(json & json, const DrvOutput & drvOutput)
|
||||||
|
{
|
||||||
|
json = drvOutput.to_string();
|
||||||
|
}
|
||||||
|
|
||||||
UnkeyedRealisation adl_serializer<UnkeyedRealisation>::from_json(const json & json0)
|
UnkeyedRealisation adl_serializer<UnkeyedRealisation>::from_json(const json & json0)
|
||||||
{
|
{
|
||||||
auto json = getObject(json0);
|
auto json = getObject(json0);
|
||||||
|
|
@ -182,14 +192,14 @@ Realisation adl_serializer<Realisation>::from_json(const json & json0)
|
||||||
|
|
||||||
return Realisation{
|
return Realisation{
|
||||||
static_cast<UnkeyedRealisation>(json0),
|
static_cast<UnkeyedRealisation>(json0),
|
||||||
DrvOutput::parse(valueAt(json, "id")),
|
valueAt(json, "id"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void adl_serializer<Realisation>::to_json(json & json, const Realisation & r)
|
void adl_serializer<Realisation>::to_json(json & json, const Realisation & r)
|
||||||
{
|
{
|
||||||
json = static_cast<const UnkeyedRealisation &>(r);
|
json = static_cast<const UnkeyedRealisation &>(r);
|
||||||
json["id"] = r.id.to_string();
|
json["id"] = r.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace nlohmann
|
} // namespace nlohmann
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,34 @@
|
||||||
|
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Golden test for JSON reading
|
||||||
|
*/
|
||||||
|
template<typename T>
|
||||||
|
void readJsonTest(CharacterizationTest & test, PathView testStem, const T & expected, auto... args)
|
||||||
|
{
|
||||||
|
using namespace nlohmann;
|
||||||
|
test.readTest(Path{testStem} + ".json", [&](const auto & encodedRaw) {
|
||||||
|
auto encoded = json::parse(encodedRaw);
|
||||||
|
T decoded = adl_serializer<T>::from_json(encoded, args...);
|
||||||
|
ASSERT_EQ(decoded, expected);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Golden test for JSON writing
|
||||||
|
*/
|
||||||
|
template<typename T>
|
||||||
|
void writeJsonTest(CharacterizationTest & test, PathView testStem, const T & value)
|
||||||
|
{
|
||||||
|
using namespace nlohmann;
|
||||||
|
test.writeTest(
|
||||||
|
Path{testStem} + ".json",
|
||||||
|
[&]() -> json { return static_cast<json>(value); },
|
||||||
|
[](const auto & file) { return json::parse(readFile(file)); },
|
||||||
|
[](const auto & file, const auto & got) { return writeFile(file, got.dump(2) + "\n"); });
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mixin class for writing characterization tests for `nlohmann::json`
|
* Mixin class for writing characterization tests for `nlohmann::json`
|
||||||
* conversions for a given type.
|
* conversions for a given type.
|
||||||
|
|
@ -26,12 +54,7 @@ struct JsonCharacterizationTest : virtual CharacterizationTest
|
||||||
*/
|
*/
|
||||||
void readJsonTest(PathView testStem, const T & expected, auto... args)
|
void readJsonTest(PathView testStem, const T & expected, auto... args)
|
||||||
{
|
{
|
||||||
using namespace nlohmann;
|
nix::readJsonTest(*this, testStem, expected, args...);
|
||||||
readTest(Path{testStem} + ".json", [&](const auto & encodedRaw) {
|
|
||||||
auto encoded = json::parse(encodedRaw);
|
|
||||||
T decoded = adl_serializer<T>::from_json(encoded, args...);
|
|
||||||
ASSERT_EQ(decoded, expected);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -42,12 +65,7 @@ struct JsonCharacterizationTest : virtual CharacterizationTest
|
||||||
*/
|
*/
|
||||||
void writeJsonTest(PathView testStem, const T & value)
|
void writeJsonTest(PathView testStem, const T & value)
|
||||||
{
|
{
|
||||||
using namespace nlohmann;
|
nix::writeJsonTest(*this, testStem, value);
|
||||||
writeTest(
|
|
||||||
Path{testStem} + ".json",
|
|
||||||
[&]() -> json { return static_cast<json>(value); },
|
|
||||||
[](const auto & file) { return json::parse(readFile(file)); },
|
|
||||||
[](const auto & file, const auto & got) { return writeFile(file, got.dump(2) + "\n"); });
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,4 +114,13 @@ struct adl_serializer<std::optional<T>>
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
static inline std::optional<T> ptrToOwned(const json * ptr)
|
||||||
|
{
|
||||||
|
if (ptr)
|
||||||
|
return std::optional{*ptr};
|
||||||
|
else
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace nlohmann
|
} // namespace nlohmann
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ static json pathInfoToJSON(Store & store, const StorePathSet & storePaths, bool
|
||||||
// know the name yet until we've read the NAR info.
|
// know the name yet until we've read the NAR info.
|
||||||
printedStorePath = store.printStorePath(info->path);
|
printedStorePath = store.printStorePath(info->path);
|
||||||
|
|
||||||
jsonObject = info->toJSON(store, true, HashFormat::SRI);
|
jsonObject = info->toJSON(&store, true);
|
||||||
|
|
||||||
if (showClosureSize) {
|
if (showClosureSize) {
|
||||||
StorePathSet closure;
|
StorePathSet closure;
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,16 @@ diff --unified --color=always \
|
||||||
jq --sort-keys 'map_values(.narHash)') \
|
jq --sort-keys 'map_values(.narHash)') \
|
||||||
<(jq --sort-keys <<-EOF
|
<(jq --sort-keys <<-EOF
|
||||||
{
|
{
|
||||||
"$foo": "sha256-QvtAMbUl/uvi+LCObmqOhvNOapHdA2raiI4xG5zI5pA=",
|
"$foo": {
|
||||||
"$bar": "sha256-9fhYGu9fqxcQC2Kc81qh2RMo1QcLBUBo8U+pPn+jthQ=",
|
"algorithm": "sha256",
|
||||||
|
"format": "base64",
|
||||||
|
"hash": "QvtAMbUl/uvi+LCObmqOhvNOapHdA2raiI4xG5zI5pA="
|
||||||
|
},
|
||||||
|
"$bar": {
|
||||||
|
"algorithm": "sha256",
|
||||||
|
"format": "base64",
|
||||||
|
"hash": "9fhYGu9fqxcQC2Kc81qh2RMo1QcLBUBo8U+pPn+jthQ="
|
||||||
|
},
|
||||||
"$baz": null
|
"$baz": null
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue