Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
# Add some executables from other relevant packages
inherit (bech32.components.exes) bech32;
inherit (ouroboros-consensus-cardano.components.exes) db-analyser db-synthesizer db-truncater snapshot-converter;
inherit (kes-agent.components.exes) kes-agent kes-agent-control kes-service-client-demo;
# Add cardano-node, cardano-cli and tx-generator with their git revision stamp.
# Keep available an alternative without the git revision, like the other
# passthru (profiled and asserted in nix/haskell.nix) that
Expand Down Expand Up @@ -297,10 +298,15 @@
"db-analyser"
"db-synthesizer"
"db-truncater"
"kes-agent"
"kes-agent-control"
"snapshot-converter"
"tx-generator"
];

# Binaries only supported on Linux; excluded from Windows and Darwin releases.
linuxOnlyBins = ["kes-agent" "kes-agent-control"];

ciJobsVariants =
mapAttrs (
_: p:
Expand Down Expand Up @@ -368,7 +374,7 @@
inherit (exes.cardano-node.identifier) version;
platform = "win";
exes = collect isDerivation (
filterAttrs (n: _: elem n releaseBins) projectExes
filterAttrs (n: _: elem n releaseBins && !(elem n linuxOnlyBins)) projectExes
);
};
internal.roots.project = windowsProject.roots;
Expand All @@ -388,7 +394,7 @@
inherit (exes.cardano-node.identifier) version;
platform = "macos";
exes = collect isDerivation (
filterAttrs (n: _: elem n releaseBins) (collectExes project)
filterAttrs (n: _: elem n releaseBins && !(elem n linuxOnlyBins)) (collectExes project)
);
};
shells = removeAttrs devShells ["profiled"];
Expand Down Expand Up @@ -495,6 +501,7 @@
cardano-cli
cardano-node
cardano-submit-api
cardano-testnet
cardano-tracer
db-analyser
db-synthesizer
Expand Down
108 changes: 108 additions & 0 deletions nix/nixos/tests/cardano-node-dbtools.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{pkgs, ...}: let
inherit (lib) getExe;
inherit (pkgs) cardanoNodePackages lib;

# NixosTest script fns supporting a timeout have a default of 900 seconds.
#
# There is no pre-existing history for chain synthesis, and default
# cardano-testnet genesis parameters set epochs to be short and fast, so a 30
# second global timeout should be more than sufficient.
globalTimeout = 30;

testDir = "testnet";
in {
inherit globalTimeout;

name = "cardano-node-dbtools-test";
nodes = {
machine = _: {
nixpkgs.pkgs = pkgs;

environment = {
systemPackages = with cardanoNodePackages; [
cardano-cli
cardano-node
cardano-testnet
db-analyser
db-synthesizer
db-truncater
];

variables = {
CARDANO_CLI = getExe cardanoNodePackages.cardano-cli;
CARDANO_NODE = getExe cardanoNodePackages.cardano-node;
KES_KEY = "${testDir}/pools-keys/pool1/kes.skey";
OPCERT = "${testDir}/pools-keys/pool1/opcert.cert";
VRF_KEY = "${testDir}/pools-keys/pool1/vrf.skey";
};
};
};
};

testScript = ''
import re
countRegex = r'Counted (\d+) blocks\.'

start_all()
print(machine.succeed("cardano-node --version"))
print(machine.succeed("cardano-cli --version"))
print(machine.succeed("cardano-testnet version"))
print(machine.succeed("cardano-testnet create-env --output ${testDir}"))

# TODO: Until db-synthesizer is fixed upstream
# print(machine.succeed("db-synthesizer \
# --config ${testDir}/configuration.yaml \
# --db db \
# --shelley-operational-certificate $OPCERT \
# --shelley-vrf-key $VRF_KEY \
# --shelley-kes-key $KES_KEY \
# --epochs 1 \
# 2>&1")

print(machine.succeed("echo Analyze synthesized chain"))
out = machine.succeed("db-analyser \
--db db \
--verbose \
--count-blocks \
--v2-in-mem \
--config ${testDir}/configuration.yaml \
2>&1"
)
print(out)
match = re.search(countRegex, out)
assert match is not None, f"Could not find block count in post-synthesis output: {out}"
blocks_before = int(match.group(1))
print(f"Found {blocks_before} blocks post synthesis")

# TODO: Until db-synthesizer is fixed upstream
# assert blocks_before > 0, f"No blocks were synthesized: {blocks_before}"

print(machine.succeed("echo Truncate synthesized chain"))
print(machine.succeed("db-truncater \
--db db \
--truncate-after-block 1 \
--verbose \
--config ${testDir}/configuration.yaml \
2>&1")
)

print(machine.succeed("echo Analyze truncated chain"))
out = machine.succeed("db-analyser \
--db db \
--verbose \
--count-blocks \
--v2-in-mem \
--config ${testDir}/configuration.yaml \
2>&1"
)
print(out)
match = re.search(countRegex, out)
assert match is not None, f"Could not find block count in post-truncation output: {out}"
blocks_after = int(match.group(1))
print(f"Found {blocks_after} blocks post truncation")

# TODO: Until db-synthesizer is fixed upstream
# assert blocks_after == 1, f"Expected exactly 1 block after truncation, got {blocks_after}"
# assert blocks_before > blocks_after, f"Pre-truncation blockHeight of {blocks_before} should be larger than post-truncation blockHeight of {blocks_after}"
'';
}
3 changes: 3 additions & 0 deletions nix/nixos/tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ in {
# Tests the linux release binary envs with pre-bundled config.
cardanoNodeArtifact = callTest ./cardano-node-artifact.nix {inherit cardano-node-linux;};

# Tests db-tools (synthesizer, analyser, truncater) against a cardano-testnet create-env environment.
cardanoNodeDbtools = callTest ./cardano-node-dbtools.nix {};

# Tests a mainnet edge node with submit-api using nixos service config.
cardanoNodeEdge = callTest ./cardano-node-edge.nix {};
}
Loading