From c0cd8e33c80b788f016b603756d43632f4e84eae Mon Sep 17 00:00:00 2001 From: Marek Mahut Date: Sun, 25 Aug 2019 17:07:34 +0200 Subject: [PATCH 1/3] jormungandr: installing the bootstrap scripts --- .../altcoins/jormungandr/default.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkgs/applications/altcoins/jormungandr/default.nix b/pkgs/applications/altcoins/jormungandr/default.nix index abfd3fa5171..8c276d6bb80 100644 --- a/pkgs/applications/altcoins/jormungandr/default.nix +++ b/pkgs/applications/altcoins/jormungandr/default.nix @@ -24,6 +24,22 @@ rustPlatform.buildRustPackage rec { nativeBuildInputs = [ pkgconfig protobuf ]; 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"; # Disabling integration tests From f6ced211e68cd1b00cb3df98504d778d191fdd58 Mon Sep 17 00:00:00 2001 From: Marek Mahut Date: Sun, 25 Aug 2019 17:37:58 +0200 Subject: [PATCH 2/3] nixos/jormungandr: changing the port to match upstream --- nixos/modules/services/networking/jormungandr.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/networking/jormungandr.nix b/nixos/modules/services/networking/jormungandr.nix index c1a16a316b7..0c66b85fe8a 100644 --- a/nixos/modules/services/networking/jormungandr.nix +++ b/nixos/modules/services/networking/jormungandr.nix @@ -13,7 +13,7 @@ let configSettings = { storage = dataDir; p2p = { - public_address = "/ip4/127.0.0.1/tcp/8606"; + public_address = "/ip4/127.0.0.1/tcp/8299"; messages = "high"; blocks = "high"; }; From 1a6d3f5bc25a1cd8879f25d1086aa63eb810d4ff Mon Sep 17 00:00:00 2001 From: Marek Mahut Date: Sun, 25 Aug 2019 18:07:59 +0200 Subject: [PATCH 3/3] nixos/jormungandr: adding genesis tests --- nixos/tests/jormungandr.nix | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/nixos/tests/jormungandr.nix b/nixos/tests/jormungandr.nix index ab4edf0506a..2abafc53ce5 100644 --- a/nixos/tests/jormungandr.nix +++ b/nixos/tests/jormungandr.nix @@ -5,9 +5,17 @@ import ./make-test.nix ({ pkgs, ... }: { }; nodes = { + # Testing the Byzantine Fault Tolerant protocol bft = { ... }: { 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.genesisBlockFile = "/var/lib/jormungandr/block-0.bin"; services.jormungandr.secretFile = "/etc/secrets/jormungandr.yaml"; @@ -17,6 +25,7 @@ import ./make-test.nix ({ pkgs, ... }: { testScript = '' startAll; + ## Testing BFT # Let's wait for the StateDirectory $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 $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"); ''; })