Merge pull request #67449 from mmahut/jormungandr

nixos/jormungandr: adding genesis tests
This commit is contained in:
Marek Mahut 2019-08-25 19:54:03 +02:00 committed by GitHub
commit 18dfe1a3f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 1 deletions

View file

@ -13,7 +13,7 @@ let
configSettings = { configSettings = {
storage = dataDir; storage = dataDir;
p2p = { p2p = {
public_address = "/ip4/127.0.0.1/tcp/8606"; public_address = "/ip4/127.0.0.1/tcp/8299";
messages = "high"; messages = "high";
blocks = "high"; blocks = "high";
}; };

View file

@ -5,9 +5,17 @@ import ./make-test.nix ({ pkgs, ... }: {
}; };
nodes = { nodes = {
# Testing the Byzantine Fault Tolerant protocol
bft = { ... }: { bft = { ... }: {
environment.systemPackages = [ pkgs.jormungandr ]; environment.systemPackages = [ pkgs.jormungandr ];
services.jormungandr.enable = true;
services.jormungandr.genesisBlockFile = "/var/lib/jormungandr/block-0.bin";
services.jormungandr.secretFile = "/etc/secrets/jormungandr.yaml";
};
# Testing the Ouroboros Genesis Praos protocol
genesis = { ... }: {
environment.systemPackages = [ pkgs.jormungandr ];
services.jormungandr.enable = true; services.jormungandr.enable = true;
services.jormungandr.genesisBlockFile = "/var/lib/jormungandr/block-0.bin"; services.jormungandr.genesisBlockFile = "/var/lib/jormungandr/block-0.bin";
services.jormungandr.secretFile = "/etc/secrets/jormungandr.yaml"; services.jormungandr.secretFile = "/etc/secrets/jormungandr.yaml";
@ -17,6 +25,7 @@ import ./make-test.nix ({ pkgs, ... }: {
testScript = '' testScript = ''
startAll; startAll;
## Testing BFT
# Let's wait for the StateDirectory # Let's wait for the StateDirectory
$bft->waitForFile("/var/lib/jormungandr/"); $bft->waitForFile("/var/lib/jormungandr/");
@ -45,5 +54,24 @@ import ./make-test.nix ({ pkgs, ... }: {
# Now we can test if we are able to reach the REST API # Now we can test if we are able to reach the REST API
$bft->waitUntilSucceeds("curl -L http://localhost:8607/api/v0/node/stats | grep uptime"); $bft->waitUntilSucceeds("curl -L http://localhost:8607/api/v0/node/stats | grep uptime");
## Testing Genesis
# Let's wait for the StateDirectory
$genesis->waitForFile("/var/lib/jormungandr/");
# Bootstraping the configuration
$genesis->succeed("jormungandr-bootstrap -g -p 8607 -s 1");
# Moving generated files in place
$genesis->succeed("mkdir -p /etc/secrets");
$genesis->succeed("mv pool-secret1.yaml /etc/secrets/jormungandr.yaml");
$genesis->succeed("mv block-0.bin /var/lib/jormungandr/");
# We should have everything to start the service now
$genesis->succeed("systemctl restart jormungandr");
$genesis->waitForUnit("jormungandr.service");
# Now we can create and delegate an account
$genesis->succeed("./create-account-and-delegate.sh | tee -a /tmp/delegate.log");
''; '';
}) })

View file

@ -24,6 +24,22 @@ rustPlatform.buildRustPackage rec {
nativeBuildInputs = [ pkgconfig protobuf ]; nativeBuildInputs = [ pkgconfig protobuf ];
buildInputs = [ openssl ] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security ]; buildInputs = [ openssl ] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security ];
patchPhase = ''
sed -i "s~SCRIPTPATH=.*~SCRIPTPATH=$out/templates/~g" scripts/bootstrap
'';
installPhase = ''
install -d $out/bin $out/templates
install -m755 target/*/release/jormungandr $out/bin/
install -m755 target/*/release/jcli $out/bin/
install -m755 scripts/send-transaction $out/templates
install -m755 scripts/jcli-helpers $out/bin/
install -m755 scripts/bootstrap $out/bin/jormungandr-bootstrap
install -m644 scripts/faucet-send-money.shtempl $out/templates/
install -m644 scripts/create-account-and-delegate.shtempl $out/templates/
install -m644 scripts/faucet-send-certificate.shtempl $out/templates/
'';
PROTOC = "${protobuf}/bin/protoc"; PROTOC = "${protobuf}/bin/protoc";
# Disabling integration tests # Disabling integration tests