git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #67449 from mmahut/jormungandr

nixos/jormungandr: adding genesis tests

commit18dfe1a3f5114872e00a019e2a339286ed649f82 authorMarek Mahut <marek.mahut@gmail.com> dateSun 25 Aug 2019, 19:54 (7 years ago) parentbba3f5f1a6d3f5
3 files changed+45−1
nixos/modules/services/networking/jormungandr.nix+1−1 nixos/tests/jormungandr.nix+28 pkgs/applications/altcoins/jormungandr/default.nix+16
nixos/modules/services/networking/jormungandr.nix+1−1
@@ -13,7 +13,7 @@ let
1313 configSettings = {
1414 storage = dataDir;
1515 p2p = {
16− public_address = "/ip4/127.0.0.1/tcp/8606";
16+ public_address = "/ip4/127.0.0.1/tcp/8299";
1717 messages = "high";
1818 blocks = "high";
1919 };
nixos/tests/jormungandr.nix+28
@@ -5,9 +5,17 @@ import ./make-test.nix ({ pkgs, ... }: {
55 };
66
77 nodes = {
8+ # Testing the Byzantine Fault Tolerant protocol
89 bft = { ... }: {
910 environment.systemPackages = [ pkgs.jormungandr ];
11+ services.jormungandr.enable = true;
12+ services.jormungandr.genesisBlockFile = "/var/lib/jormungandr/block-0.bin";
13+ services.jormungandr.secretFile = "/etc/secrets/jormungandr.yaml";
14+ };
1015
16+ # Testing the Ouroboros Genesis Praos protocol
17+ genesis = { ... }: {
18+ environment.systemPackages = [ pkgs.jormungandr ];
1119 services.jormungandr.enable = true;
1220 services.jormungandr.genesisBlockFile = "/var/lib/jormungandr/block-0.bin";
1321 services.jormungandr.secretFile = "/etc/secrets/jormungandr.yaml";
@@ -17,6 +25,7 @@ import ./make-test.nix ({ pkgs, ... }: {
1725 testScript = ''
1826 startAll;
1927
28+ ## Testing BFT
2029 # Let's wait for the StateDirectory
2130 $bft->waitForFile("/var/lib/jormungandr/");
2231
@@ -45,5 +54,24 @@ import ./make-test.nix ({ pkgs, ... }: {
4554
4655 # Now we can test if we are able to reach the REST API
4756 $bft->waitUntilSucceeds("curl -L http://localhost:8607/api/v0/node/stats | grep uptime");
57+
58+ ## Testing Genesis
59+ # Let's wait for the StateDirectory
60+ $genesis->waitForFile("/var/lib/jormungandr/");
61+
62+ # Bootstraping the configuration
63+ $genesis->succeed("jormungandr-bootstrap -g -p 8607 -s 1");
64+
65+ # Moving generated files in place
66+ $genesis->succeed("mkdir -p /etc/secrets");
67+ $genesis->succeed("mv pool-secret1.yaml /etc/secrets/jormungandr.yaml");
68+ $genesis->succeed("mv block-0.bin /var/lib/jormungandr/");
69+
70+ # We should have everything to start the service now
71+ $genesis->succeed("systemctl restart jormungandr");
72+ $genesis->waitForUnit("jormungandr.service");
73+
74+ # Now we can create and delegate an account
75+ $genesis->succeed("./create-account-and-delegate.sh | tee -a /tmp/delegate.log");
4876 '';
4977})
pkgs/applications/altcoins/jormungandr/default.nix+16
@@ -24,6 +24,22 @@ rustPlatform.buildRustPackage rec {
2424 nativeBuildInputs = [ pkgconfig protobuf ];
2525 buildInputs = [ openssl ] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Security ];
2626
27+ patchPhase = ''
28+ sed -i "s~SCRIPTPATH=.*~SCRIPTPATH=$out/templates/~g" scripts/bootstrap
29+ '';
30+
31+ installPhase = ''
32+ install -d $out/bin $out/templates
33+ install -m755 target/*/release/jormungandr $out/bin/
34+ install -m755 target/*/release/jcli $out/bin/
35+ install -m755 scripts/send-transaction $out/templates
36+ install -m755 scripts/jcli-helpers $out/bin/
37+ install -m755 scripts/bootstrap $out/bin/jormungandr-bootstrap
38+ install -m644 scripts/faucet-send-money.shtempl $out/templates/
39+ install -m644 scripts/create-account-and-delegate.shtempl $out/templates/
40+ install -m644 scripts/faucet-send-certificate.shtempl $out/templates/
41+ '';
42+
2743 PROTOC = "${protobuf}/bin/protoc";
2844
2945 # Disabling integration tests