@@ -1,77 +0,0 @@
1−import ./make-test.nix ({ pkgs, ... }: {
2− name = "jormungandr";
3− meta = with pkgs.stdenv.lib.maintainers; {
4− maintainers = [ mmahut ];
5− };
6−
7− nodes = {
8− # Testing the Byzantine Fault Tolerant protocol
9− bft = { ... }: {
10− 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− };
15−
16− # Testing the Ouroboros Genesis Praos protocol
17− genesis = { ... }: {
18− environment.systemPackages = [ pkgs.jormungandr ];
19− services.jormungandr.enable = true;
20− services.jormungandr.genesisBlockFile = "/var/lib/jormungandr/block-0.bin";
21− services.jormungandr.secretFile = "/etc/secrets/jormungandr.yaml";
22− };
23− };
24−
25− testScript = ''
26− startAll;
27−
28− ## Testing BFT
29− # Let's wait for the StateDirectory
30− $bft->waitForFile("/var/lib/jormungandr/");
31−
32− # First, we generate the genesis file for our new blockchain
33− $bft->succeed("jcli genesis init > /root/genesis.yaml");
34−
35− # We need to generate our secret key
36− $bft->succeed("jcli key generate --type=Ed25519 > /root/key.prv");
37−
38− # We include the secret key into our services.jormungandr.secretFile
39− $bft->succeed("mkdir -p /etc/secrets");
40− $bft->succeed("echo -e \"bft:\\n signing_key:\" \$(cat /root/key.prv) > /etc/secrets/jormungandr.yaml");
41−
42− # After that, we generate our public key from it
43− $bft->succeed("cat /root/key.prv | jcli key to-public > /root/key.pub");
44−
45− # We add our public key as a consensus leader in the genesis configration file
46− $bft->succeed("sed -ie \"s/ed25519_pk1vvwp2s0n5jl5f4xcjurp2e92sj2awehkrydrlas4vgqr7xzt33jsadha32/\$(cat /root/key.pub)/\" /root/genesis.yaml");
47−
48− # Now we can generate the genesis block from it
49− $bft->succeed("jcli genesis encode --input /root/genesis.yaml --output /var/lib/jormungandr/block-0.bin");
50−
51− # We should have everything to start the service now
52− $bft->succeed("systemctl restart jormungandr");
53− $bft->waitForUnit("jormungandr.service");
54−
55− # Now we can test if we are able to reach the REST API
56− $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");
76− '';
77−})