From 907ca0d34ffad8441a7b48b68d5f2a6995038232 Mon Sep 17 00:00:00 2001 From: jared <> Date: Tue, 1 Apr 2025 17:35:04 -0600 Subject: [PATCH 1/6] Draft of drop-in replacement testnet --- modules/default.nix | 8 + modules/fixtures/README.md | 3 + modules/fixtures/test-node/byron-delegate.key | Bin 0 -> 130 bytes .../fixtures/test-node/byron-delegation.cert | 8 + modules/fixtures/test-node/config.json | 81 ++++ modules/fixtures/test-node/faucet.skey | 5 + .../fixtures/test-node/genesis-alonzo.json | 51 +++ modules/fixtures/test-node/genesis-byron.json | 36 ++ .../fixtures/test-node/genesis-conway.json | 66 +++ .../fixtures/test-node/genesis-shelley.json | 64 +++ modules/fixtures/test-node/kes.skey | 5 + modules/fixtures/test-node/opcert.cert | 5 + modules/fixtures/test-node/topology.json | 3 + modules/fixtures/test-node/vrf.skey | 5 + modules/node.nix | 32 +- modules/test-node.nix | 401 ++++++++++++++++++ templates/default/flake.lock | 0 tests/default.nix | 1 + tests/test-node.nix | 82 ++++ 19 files changed, 851 insertions(+), 5 deletions(-) create mode 100644 modules/fixtures/README.md create mode 100644 modules/fixtures/test-node/byron-delegate.key create mode 100644 modules/fixtures/test-node/byron-delegation.cert create mode 100644 modules/fixtures/test-node/config.json create mode 100644 modules/fixtures/test-node/faucet.skey create mode 100644 modules/fixtures/test-node/genesis-alonzo.json create mode 100644 modules/fixtures/test-node/genesis-byron.json create mode 100644 modules/fixtures/test-node/genesis-conway.json create mode 100644 modules/fixtures/test-node/genesis-shelley.json create mode 100644 modules/fixtures/test-node/kes.skey create mode 100644 modules/fixtures/test-node/opcert.cert create mode 100644 modules/fixtures/test-node/topology.json create mode 100644 modules/fixtures/test-node/vrf.skey create mode 100644 modules/test-node.nix create mode 100644 templates/default/flake.lock create mode 100644 tests/test-node.nix diff --git a/modules/default.nix b/modules/default.nix index 4d14e9e..1ce4d00 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -23,6 +23,14 @@ ./node.nix ]; }; + + test-node = { + imports = [ + config.flake.nixosModules.node + ./test-node.nix + ]; + }; + ogmios = { imports = [ ./services/ogmios.nix diff --git a/modules/fixtures/README.md b/modules/fixtures/README.md new file mode 100644 index 0000000..aedb11a --- /dev/null +++ b/modules/fixtures/README.md @@ -0,0 +1,3 @@ +# `./fixtures` + +This directory contains [_fixtures_](https://en.wikipedia.org/wiki/Test_fixture#Software) for testing. diff --git a/modules/fixtures/test-node/byron-delegate.key b/modules/fixtures/test-node/byron-delegate.key new file mode 100644 index 0000000000000000000000000000000000000000..6693ec7706777aa4da360aeb4ef9a8dd56d923b1 GIT binary patch literal 130 zcmV-|0Db>hfJhJpMAL|soH`HS$J85Ti_uO*&)dR|kV1;ij>55VRpM>_gJ@~-Ve=4b z6*4KMp|mD#my~k2q4Pg0GS#Vq%-e^fM6aX>J2iuc_dUuT6h#GA14UZb=DL9`RR{e1 kh_;Vv?p$}9CT3Yaye$FN$zuTGNK5P hack to get config file path + # + # NOTE(jaredponn) April 11, 2025: This line forces the config file to be + # known at Nix evaluation time which causes trouble if you want to + # "dynamically create" the config which is desirable when -- for + # example -- creating a test node setup that sets the system + # start time to now. + text = readFile (elemAt (match ".* --config ([^ ]+) .*" (replaceStrings [ "\n" ] [ " " ] config.services.cardano-node.script)) 0); + user = "cardano-node"; + group = "cardano-node"; + }; }; environment.variables = { + # Set convenience environment variables when interacting with the node + # via `cardano-cli` in the machine. + # In particular, see + # + # for details on the environment variables it reads. CARDANO_NODE_SOCKET_PATH = cfg.socketPath; + CARDANO_NODE_NETWORK_ID = if config.cardano.network == "mainnet" then "mainnet" else config.cardano.networkNumber; }; services.cardano-node = { diff --git a/modules/test-node.nix b/modules/test-node.nix new file mode 100644 index 0000000..9a1877f --- /dev/null +++ b/modules/test-node.nix @@ -0,0 +1,401 @@ +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.cardano.test-node; +in +{ + + imports = [ + ./cardano.nix + ./node.nix + ]; + + options.cardano.test-node = { + enable = lib.mkEnableOption '' + cardano-devnet node (a private testnet node) which -- when enabled -- + switches the system's cardano-node to a private testnet node (with its + own testnet network magic) with the environment variable $FAUCET as an address + loaded with LOVELACE (approx. 1000000000000 LOVELACE) that can be + distributed with the CLI utility `request-from-faucet --address + addr_test1vztc80na8320zymhjekl40yjsnxkcvhu58x59mc2fuwvgkc332vxv + --amount 10000000`''; + + initialFunds = lib.mkOption { + type = lib.types.attrsOf ( + lib.types.oneOf [ + (lib.types.nonEmptyListOf lib.types.ints.unsigned) + lib.types.ints.unsigned + ] + ); + default = { }; + + example = { + addr_test1vzrv7az4xq620y20pyn44yhvl89r7nwa7ga5ftn9rleenxqharu33 = [ + 10000000 + 1000000 + ]; + addr_test1vr6ue2hmlnj8pzzqy7353lv3yj8xu7m24pgpctv7z3qhv8c3qdt46 = 1000000; + }; + description = '' + A mapping from bech32 encoded addresses to either a single LOVELACE + amount or a non-empty list of LOVELACE amounts which initializes the + addresses with UTxOs containing the provided LOVELACE amounts from the + FAUCET. + + When using the [NixOS + Tests](https://nixos.org/manual/nixos/stable/index.html#sec-call-nixos-test-outside-nixos), + it's good to wait for the unit `test-cardano-node-initial-funds.service` before + spending from these wallets i.e., having the following in the + `testScript` would be a good idea: + ``` + machine.wait_for_unit("test-cardano-node-initial-funds") + ``` + ''; + }; + + testNodeConfigDirectory = lib.mkOption { + internal = true; + type = lib.types.str; + default = "cardano-node"; + description = '' + The ConfigurationDirectory (see `man systemd.exec (5)`) to put the test + Cardano node's configuration in. Thus, the node's configuration + will be in `/etc/`. + ''; + }; + + # The following options are the genesis files for specific eras + ############################## + genesisAlonzo = lib.mkOption { + internal = true; + type = lib.types.path; + default = ./fixtures/test-node/genesis-alonzo.json; + }; + + genesisConway = lib.mkOption { + internal = true; + type = lib.types.path; + default = ./fixtures/test-node/genesis-conway.json; + }; + + genesisByron = lib.mkOption { + internal = true; + type = lib.types.path; + default = ./fixtures/test-node/genesis-byron.json; + }; + + genesisShelley = lib.mkOption { + internal = true; + type = lib.types.path; + default = ./fixtures/test-node/genesis-shelley.json; + }; + + # The following options are wrappers for the options provided by the cardano-node + ############################## + nodeConfigFile = lib.mkOption { + internal = true; + type = lib.types.path; + default = ./fixtures/test-node/config.json; + }; + + vrfKey = lib.mkOption { + internal = true; + type = lib.types.path; + default = ./fixtures/test-node/vrf.skey; + }; + + kesKey = lib.mkOption { + internal = true; + type = lib.types.path; + default = ./fixtures/test-node/kes.skey; + }; + + delegationCertificate = lib.mkOption { + internal = true; + type = lib.types.path; + default = ./fixtures/test-node/byron-delegation.cert; + }; + + operationalCertificate = lib.mkOption { + internal = true; + type = lib.types.path; + default = ./fixtures/test-node/opcert.cert; + }; + + signingKey = lib.mkOption { + internal = true; + type = lib.types.path; + default = ./fixtures/test-node/byron-delegate.key; + }; + + topology = lib.mkOption { + internal = true; + type = lib.types.path; + default = ./fixtures/test-node/topology.json; + }; + + }; + + config = lib.mkIf cfg.enable { + # Set the `cardano.network` option to `private` which has network magic 42. + # In particular, this matches the `networkMagic` value in + # `./fixtures/test-node/genesis-shelley.json` + cardano.network = lib.mkForce "private"; + + # Create a directory of the test node's config files + # Why don't we just link the Cardano node directly to the files in + # `./fixtures/test-node/`? This is because we need to dynamically fill some + # values in when the system is running e.g. the system start time. + systemd.services.cardano-node-config = { + enable = true; + wantedBy = [ "multi-user.target" ]; + before = [ "cardano-node.service" ]; + serviceConfig = { + Type = "oneshot"; + Restart = "on-failure"; + RemainAfterExit = true; + User = "cardano-node"; + Group = "cardano-node"; + ConfigurationDirectory = [ cfg.testNodeConfigDirectory ]; + }; + + path = [ pkgs.jq ]; + script = '' + # If we've built the configuration before, then don't do + # anything. + if test -f "$CONFIGURATION_DIRECTORY/done" # REMARK: we know that ConfigurationDirectory has only one element + then + exit 0 + fi + + # Copy most of the configuration files over + install -o cardano-node -g cardano-node -m 664 ${cfg.nodeConfigFile} "$CONFIGURATION_DIRECTORY/config.json" + install -o cardano-node -g cardano-node -m 664 ${cfg.genesisAlonzo} "$CONFIGURATION_DIRECTORY/genesis-alonzo.json" + install -o cardano-node -g cardano-node -m 664 ${cfg.genesisConway} "$CONFIGURATION_DIRECTORY/genesis-conway.json" + install -o cardano-node -g cardano-node -m 600 ${cfg.vrfKey} "$CONFIGURATION_DIRECTORY/vrf.skey" + install -o cardano-node -g cardano-node -m 600 ${cfg.kesKey} "$CONFIGURATION_DIRECTORY/kes.skey" + install -o cardano-node -g cardano-node -m 600 ${cfg.delegationCertificate} "$CONFIGURATION_DIRECTORY/byron-delegation.cert" + install -o cardano-node -g cardano-node -m 600 ${cfg.operationalCertificate} "$CONFIGURATION_DIRECTORY/opcert.cert" + install -o cardano-node -g cardano-node -m 600 ${cfg.signingKey} "$CONFIGURATION_DIRECTORY/byron-delegate.key" + install -o cardano-node -g cardano-node -m 600 ${cfg.topology} "$CONFIGURATION_DIRECTORY/topology.json" + + # Copy the configuration files that require additional initialization + # on boot + START_TIME="$(date -u)" + + jq '.startTime |= $start_time' \ + --argjson start_time "$(date -d "$START_TIME" +%s)" \ + < ${cfg.genesisByron} \ + > "$CONFIGURATION_DIRECTORY/genesis-byron.json" + + jq '.systemStart |= $start_time' \ + --arg start_time "$(date -d "$START_TIME" -u +%FT%TZ)" \ + < ${cfg.genesisShelley} \ + > "$CONFIGURATION_DIRECTORY/genesis-shelley.json" + + touch "$CONFIGURATION_DIRECTORY/done" + ''; + }; + + # Setup the cardano node + cardano.node.enable = true; + cardano.node.copyCardanoNodeConfigToEtc = lib.mkForce false; + + # Change the cardano node s.t. it uses a custom setup + services.cardano-node = { + nodeConfigFile = "/etc/${cfg.testNodeConfigDirectory}/config.json"; + topology = "/etc/${cfg.testNodeConfigDirectory}/topology.json"; + kesKey = "/etc/${cfg.testNodeConfigDirectory}/kes.skey"; + vrfKey = "/etc/${cfg.testNodeConfigDirectory}/vrf.skey"; + operationalCertificate = "/etc/${cfg.testNodeConfigDirectory}/opcert.cert"; + delegationCertificate = "/etc/${cfg.testNodeConfigDirectory}/byron-delegation.cert"; + signingKey = "/etc/${cfg.testNodeConfigDirectory}/byron-delegate.key"; + + # Override the `useSystemdReload` from the `./node.nix` defaults that + # messes with things. Note that if `useSystemdReload` is true, it makes + # the `cardano-node` go looking in `/etc/cardano-node/topology-0.yaml` + # instead of whatever value we provide. See + # + # for details. + useSystemdReload = lib.mkForce false; + }; + + systemd.services.test-cardano-node-initial-funds = { + description = "Pays LOVELACE to the initialFunds at most once."; + after = [ "cardano-node-socket.service" ]; + requires = [ "cardano-node.service" ]; + bindsTo = [ "cardano-node.service" ]; + requiredBy = [ "cardano-node.service" ]; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + StateDirectory = [ "test-cardano-node-initial-funds" ]; + }; + environment = { + inherit (config.environment.variables) + FAUCET + FAUCET_SKEY + CARDANO_NODE_SOCKET_PATH + CARDANO_NODE_NETWORK_ID + ; + }; + path = [ pkgs.request-from-faucet ]; + script = '' + # Check if we've already initialized. If we have, then we're done. + if test -f /var/lib/test-cardano-node-initial-funds/done + then + 1>&2 echo "Initial funds have already been distributed, so doing nothing." + exit 0 + fi + + 1>&2 echo "Distributing initial funds." + ${lib.attrsets.foldlAttrs ( + acc: addr: amountOrAmounts: + # WARNING(jaredponn) April 22, 2025: probably terrible time complexity. + # NOTE(jaredponn) April 22, 2025: Loosely, this convoluted nix + # expression builds a shell script like + # ``` + # request-from-faucet --address --amount + # request-from-faucet --address --amount + # request-from-faucet --address --amount + # ``` + # when given an `initialFunds` like + # ``` + # { = [ ]; = ; } + # ``` + let + amounts = if builtins.typeOf amountOrAmounts == "int" then [ amountOrAmounts ] else amountOrAmounts; + in + '' + ${acc} + ${builtins.concatStringsSep "\n" (builtins.map (amount: ''request-from-faucet --address ${lib.escapeShellArg addr} --amount ${builtins.toString amount}'') amounts)} + '' + ) "" cfg.initialFunds} + + touch /var/lib/test-cardano-node-initial-funds/done + + 1>&2 echo "Finished distributing initial funds." + ''; + }; + + nixpkgs.overlays = [ + (_self: _super: { + # Add the package `request-from-faucet` + request-from-faucet = pkgs.writeShellApplication { + name = "request-from-faucet"; + runtimeInputs = [ + pkgs.jq + pkgs.cardano-cli + ]; + + text = '' + while test "$#" -gt 0; do + case "$1" in + --address) + shift + ADDRESS="$1" + shift + ;; + --amount) + shift + AMOUNT="$1" + shift + ;; + -h|--help) + 1>&2 echo "Usage: $0 --address --amount " + 1>&2 echo "Pays lovelace (a base 10 integer) to (human readable bech32 address) from the address specified by the \$FAUCET environment variable using the private key located in the file specified by the \$FAUCET_SKEY environment variable. This uses 'cardano-cli' internally, and hence requires the \$CARDANO_NODE_SOCKET_PATH and \$CARDANO_NODE_NETWORK_ID environment variables to be set appropriately." + exit 1 + ;; + *) + 1>&2 echo "$0: unrecognized option '$1'" + 1>&2 echo "Try '$0 --help' for more information." + exit 1 + ;; + esac + done + + 1>&2 echo "Creating a UTxO for $ADDRESS with $AMOUNT lovelace from $FAUCET" + + # Temporary working directory + ############################# + TMP="$(mktemp -d)" + trap "rm -rf \$TMP" EXIT + + # Build and sign the tx from the faucet + ############################# + + # NOTE(jaredponn) April 21, 2025: Most of the + # tx building follows from the following + # articles: + # - https://developers.cardano.org/docs/get-started/create-simple-transaction/ + # - https://github.com/cardano-scaling/hydra/blob/master/demo/seed-devnet.sh + + 1>&2 echo "Building and signing the transaction" + + # Create a tx which: + # - Uses the first largest in lovelace 64 UTxOs + # from the FAUCET address to finance the + # transaction. We limit it to using 64 UTxOs + # to help stay under transaction size limits. + # - Pay a single transaction output to ADDRESS + # with the specified AMOUNT + + # We ignore these shellcheck warnings (they + # arise from getting the tx-ins from the FAUCET + # address) because we know the form of the + # tx-ins is `#` + # shellcheck disable=SC2162 + # shellcheck disable=SC2046 + 1>&2 cardano-cli conway transaction build \ + --change-address "$FAUCET" \ + $(cardano-cli query utxo --output-json --address "$FAUCET" \ + | jq -r 'to_entries | sort_by(- .value.value.lovelace) | map(.key) | .[0:64] | .[]' \ + | while read FAUCET_TX_IN; do echo "--tx-in" "$FAUCET_TX_IN" ; done) \ + --tx-out "$ADDRESS"+"$AMOUNT" \ + --out-file tx.draft + + 1>&2 cardano-cli conway transaction sign \ + --tx-body-file tx.draft \ + --signing-key-file "$FAUCET_SKEY" \ + --out-file tx.signed + + TX_ID="$(cardano-cli conway transaction txid --tx-file tx.signed)" + TX_IN="$TX_ID#0" + + 1>&2 cardano-cli conway transaction submit --tx-file tx.signed + + 1>&2 echo "Finished building and signing transaction $TX_ID" + + # Await the tx + ############################# + 1>&2 echo "Awaiting $TX_ID by waiting for tx-in $TX_IN" + + while test "$(cardano-cli query utxo --tx-in "$TX_IN" --output-json | jq length)" -eq 0; do + sleep 1 + 1>&2 echo -n "." + done + + 1>&2 echo "" + + 1>&2 echo "Done" + ''; + }; + }) + ]; + + environment = { + variables = { + FAUCET = "addr_test1vztc80na8320zymhjekl40yjsnxkcvhu58x59mc2fuwvgkc332vxv"; + FAUCET_SKEY = ./fixtures/test-node/faucet.skey; + }; + + systemPackages = [ pkgs.request-from-faucet ]; + }; + + }; + +} diff --git a/templates/default/flake.lock b/templates/default/flake.lock new file mode 100644 index 0000000..e69de29 diff --git a/tests/default.nix b/tests/default.nix index 6397b85..cf7c91a 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -2,6 +2,7 @@ imports = [ ./cardano-cli.nix ./node.nix + ./test-node.nix ./ogmios.nix ./kupo.nix ./http.nix diff --git a/tests/test-node.nix b/tests/test-node.nix new file mode 100644 index 0000000..ab9d3f1 --- /dev/null +++ b/tests/test-node.nix @@ -0,0 +1,82 @@ +{ + perSystem.vmTests.tests.test-cardano-node = { + impure = false; + module = { + nodes.machine = + { pkgs, ... }: + { + cardano = { + cli.enable = true; + test-node.enable = true; + test-node.initialFunds = { + addr_test1vzrv7az4xq620y20pyn44yhvl89r7nwa7ga5ftn9rleenxqharu33 = [ + 2000000 + 3000000 + ]; + addr_test1vr6ue2hmlnj8pzzqy7353lv3yj8xu7m24pgpctv7z3qhv8c3qdt46 = 1500000; + }; + }; + + environment.systemPackages = with pkgs; [ + jq + bc + ]; + }; + + testScript = + { nodes, ... }: + let + magic = toString nodes.machine.config.cardano.networkNumber; + in + '' + machine.wait_for_unit("cardano-node") + + # Check the test-node is working and syncing properly + machine.wait_until_succeeds("""[[ $(echo "$(cardano-cli query tip --testnet-magic ${magic} | jq '.syncProgress' --raw-output) > 0.001" | bc) == "1" ]]""", 10) + + # Check that the FAUCET address has a decent amount of ADA + # (note that because we have a non-zero amount of initial funds, some + # will be drained from the FAUCET initially) + machine.succeed(""" + test \ + "$(cardano-cli query utxo --output-json --address "$FAUCET" \ + | jq --arg faucet "$FAUCET" '.[] | (.address == $faucet and .value.lovelace >= 100000000000)')" \ + = \ + true + """) + + # Verify that the initial funds have been correctly distributed. + machine.wait_for_unit("test-cardano-node-initial-funds") + machine.succeed(""" + test \ + "$(cardano-cli query utxo --output-json --address addr_test1vzrv7az4xq620y20pyn44yhvl89r7nwa7ga5ftn9rleenxqharu33 \ + | jq 'to_entries | map(.value.value) | sort | . == [ {"lovelace" : 2000000}, {"lovelace" : 3000000} ]')" \ + = \ + true + """) + machine.succeed(""" + test \ + "$(cardano-cli query utxo --output-json --address addr_test1vr6ue2hmlnj8pzzqy7353lv3yj8xu7m24pgpctv7z3qhv8c3qdt46 \ + | jq 'to_entries | map(.value.value) | sort | . == [ {"lovelace" : 1500000} ]')" \ + = \ + true + """) + + # Verify that we can actually use the FAUCET to give ADA out + machine.succeed(""" + request-from-faucet --address addr_test1vq64jjlez93yz57ytlwtwsfz73n3elpty7e0w3z8l6yv3agc0e6jz --amount 10000000 + """) + machine.succeed(""" + test \ + "$(cardano-cli query utxo --output-json --address addr_test1vq64jjlez93yz57ytlwtwsfz73n3elpty7e0w3z8l6yv3agc0e6jz \ + | jq '.[] | (.value.lovelace >= 10000000)')" \ + = \ + true + """) + + print(machine.succeed("systemd-analyze security cardano-node")) + print('\nVM Test Succeeded.') + ''; + }; + }; +} From db9252bfc14bbe2b071e77356400a1509858d700 Mon Sep 17 00:00:00 2001 From: jared <> Date: Wed, 23 Apr 2025 01:36:29 -0600 Subject: [PATCH 2/6] Add licensing --- modules/fixtures/test-node/byron-delegate.key.license | 3 +++ modules/fixtures/test-node/byron-delegation.cert.license | 3 +++ modules/fixtures/test-node/config.json.license | 3 +++ modules/fixtures/test-node/faucet.skey.license | 3 +++ modules/fixtures/test-node/genesis-alonzo.json.license | 3 +++ modules/fixtures/test-node/genesis-byron.json.license | 3 +++ modules/fixtures/test-node/genesis-conway.json.license | 3 +++ modules/fixtures/test-node/genesis-shelley.json.license | 3 +++ modules/fixtures/test-node/kes.skey.license | 3 +++ modules/fixtures/test-node/opcert.cert.license | 3 +++ modules/fixtures/test-node/topology.json.license | 3 +++ modules/fixtures/test-node/vrf.skey.license | 3 +++ 12 files changed, 36 insertions(+) create mode 100644 modules/fixtures/test-node/byron-delegate.key.license create mode 100644 modules/fixtures/test-node/byron-delegation.cert.license create mode 100644 modules/fixtures/test-node/config.json.license create mode 100644 modules/fixtures/test-node/faucet.skey.license create mode 100644 modules/fixtures/test-node/genesis-alonzo.json.license create mode 100644 modules/fixtures/test-node/genesis-byron.json.license create mode 100644 modules/fixtures/test-node/genesis-conway.json.license create mode 100644 modules/fixtures/test-node/genesis-shelley.json.license create mode 100644 modules/fixtures/test-node/kes.skey.license create mode 100644 modules/fixtures/test-node/opcert.cert.license create mode 100644 modules/fixtures/test-node/topology.json.license create mode 100644 modules/fixtures/test-node/vrf.skey.license diff --git a/modules/fixtures/test-node/byron-delegate.key.license b/modules/fixtures/test-node/byron-delegate.key.license new file mode 100644 index 0000000..e845f20 --- /dev/null +++ b/modules/fixtures/test-node/byron-delegate.key.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2025 Jared Pon + +SPDX-License-Identifier: Apache-2.0 diff --git a/modules/fixtures/test-node/byron-delegation.cert.license b/modules/fixtures/test-node/byron-delegation.cert.license new file mode 100644 index 0000000..e845f20 --- /dev/null +++ b/modules/fixtures/test-node/byron-delegation.cert.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2025 Jared Pon + +SPDX-License-Identifier: Apache-2.0 diff --git a/modules/fixtures/test-node/config.json.license b/modules/fixtures/test-node/config.json.license new file mode 100644 index 0000000..e845f20 --- /dev/null +++ b/modules/fixtures/test-node/config.json.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2025 Jared Pon + +SPDX-License-Identifier: Apache-2.0 diff --git a/modules/fixtures/test-node/faucet.skey.license b/modules/fixtures/test-node/faucet.skey.license new file mode 100644 index 0000000..e845f20 --- /dev/null +++ b/modules/fixtures/test-node/faucet.skey.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2025 Jared Pon + +SPDX-License-Identifier: Apache-2.0 diff --git a/modules/fixtures/test-node/genesis-alonzo.json.license b/modules/fixtures/test-node/genesis-alonzo.json.license new file mode 100644 index 0000000..e845f20 --- /dev/null +++ b/modules/fixtures/test-node/genesis-alonzo.json.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2025 Jared Pon + +SPDX-License-Identifier: Apache-2.0 diff --git a/modules/fixtures/test-node/genesis-byron.json.license b/modules/fixtures/test-node/genesis-byron.json.license new file mode 100644 index 0000000..e845f20 --- /dev/null +++ b/modules/fixtures/test-node/genesis-byron.json.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2025 Jared Pon + +SPDX-License-Identifier: Apache-2.0 diff --git a/modules/fixtures/test-node/genesis-conway.json.license b/modules/fixtures/test-node/genesis-conway.json.license new file mode 100644 index 0000000..e845f20 --- /dev/null +++ b/modules/fixtures/test-node/genesis-conway.json.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2025 Jared Pon + +SPDX-License-Identifier: Apache-2.0 diff --git a/modules/fixtures/test-node/genesis-shelley.json.license b/modules/fixtures/test-node/genesis-shelley.json.license new file mode 100644 index 0000000..e845f20 --- /dev/null +++ b/modules/fixtures/test-node/genesis-shelley.json.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2025 Jared Pon + +SPDX-License-Identifier: Apache-2.0 diff --git a/modules/fixtures/test-node/kes.skey.license b/modules/fixtures/test-node/kes.skey.license new file mode 100644 index 0000000..e845f20 --- /dev/null +++ b/modules/fixtures/test-node/kes.skey.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2025 Jared Pon + +SPDX-License-Identifier: Apache-2.0 diff --git a/modules/fixtures/test-node/opcert.cert.license b/modules/fixtures/test-node/opcert.cert.license new file mode 100644 index 0000000..e845f20 --- /dev/null +++ b/modules/fixtures/test-node/opcert.cert.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2025 Jared Pon + +SPDX-License-Identifier: Apache-2.0 diff --git a/modules/fixtures/test-node/topology.json.license b/modules/fixtures/test-node/topology.json.license new file mode 100644 index 0000000..e845f20 --- /dev/null +++ b/modules/fixtures/test-node/topology.json.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2025 Jared Pon + +SPDX-License-Identifier: Apache-2.0 diff --git a/modules/fixtures/test-node/vrf.skey.license b/modules/fixtures/test-node/vrf.skey.license new file mode 100644 index 0000000..e845f20 --- /dev/null +++ b/modules/fixtures/test-node/vrf.skey.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: 2025 Jared Pon + +SPDX-License-Identifier: Apache-2.0 From 2adb830793d569c135c5927c5215860abe438330 Mon Sep 17 00:00:00 2001 From: Andrea Ciceri Date: Mon, 5 May 2025 11:06:05 +0200 Subject: [PATCH 3/6] Drop ad-hoc license files and use shared `.reuse/dep5` --- .reuse/dep5 | 4 ++++ modules/fixtures/test-node/byron-delegate.key.license | 3 --- modules/fixtures/test-node/byron-delegation.cert.license | 3 --- modules/fixtures/test-node/config.json.license | 3 --- modules/fixtures/test-node/faucet.skey.license | 3 --- modules/fixtures/test-node/genesis-alonzo.json.license | 3 --- modules/fixtures/test-node/genesis-byron.json.license | 3 --- modules/fixtures/test-node/genesis-conway.json.license | 3 --- modules/fixtures/test-node/genesis-shelley.json.license | 3 --- modules/fixtures/test-node/kes.skey.license | 3 --- modules/fixtures/test-node/opcert.cert.license | 3 --- modules/fixtures/test-node/topology.json.license | 3 --- modules/fixtures/test-node/vrf.skey.license | 3 --- 13 files changed, 4 insertions(+), 36 deletions(-) delete mode 100644 modules/fixtures/test-node/byron-delegate.key.license delete mode 100644 modules/fixtures/test-node/byron-delegation.cert.license delete mode 100644 modules/fixtures/test-node/config.json.license delete mode 100644 modules/fixtures/test-node/faucet.skey.license delete mode 100644 modules/fixtures/test-node/genesis-alonzo.json.license delete mode 100644 modules/fixtures/test-node/genesis-byron.json.license delete mode 100644 modules/fixtures/test-node/genesis-conway.json.license delete mode 100644 modules/fixtures/test-node/genesis-shelley.json.license delete mode 100644 modules/fixtures/test-node/kes.skey.license delete mode 100644 modules/fixtures/test-node/opcert.cert.license delete mode 100644 modules/fixtures/test-node/topology.json.license delete mode 100644 modules/fixtures/test-node/vrf.skey.license diff --git a/.reuse/dep5 b/.reuse/dep5 index 3962301..a4374ee 100644 --- a/.reuse/dep5 +++ b/.reuse/dep5 @@ -10,3 +10,7 @@ License: Apache-2.0 Files: docs/assets/favicon.png docs/assets/logo.svg Copyright: © 2023 MLabs LTD License: LicenseRef-MLabs + +Files: modules/fixtures/* +Copyright: © 2023 MLabs LTD +License: LicenseRef-MLabs diff --git a/modules/fixtures/test-node/byron-delegate.key.license b/modules/fixtures/test-node/byron-delegate.key.license deleted file mode 100644 index e845f20..0000000 --- a/modules/fixtures/test-node/byron-delegate.key.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2025 Jared Pon - -SPDX-License-Identifier: Apache-2.0 diff --git a/modules/fixtures/test-node/byron-delegation.cert.license b/modules/fixtures/test-node/byron-delegation.cert.license deleted file mode 100644 index e845f20..0000000 --- a/modules/fixtures/test-node/byron-delegation.cert.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2025 Jared Pon - -SPDX-License-Identifier: Apache-2.0 diff --git a/modules/fixtures/test-node/config.json.license b/modules/fixtures/test-node/config.json.license deleted file mode 100644 index e845f20..0000000 --- a/modules/fixtures/test-node/config.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2025 Jared Pon - -SPDX-License-Identifier: Apache-2.0 diff --git a/modules/fixtures/test-node/faucet.skey.license b/modules/fixtures/test-node/faucet.skey.license deleted file mode 100644 index e845f20..0000000 --- a/modules/fixtures/test-node/faucet.skey.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2025 Jared Pon - -SPDX-License-Identifier: Apache-2.0 diff --git a/modules/fixtures/test-node/genesis-alonzo.json.license b/modules/fixtures/test-node/genesis-alonzo.json.license deleted file mode 100644 index e845f20..0000000 --- a/modules/fixtures/test-node/genesis-alonzo.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2025 Jared Pon - -SPDX-License-Identifier: Apache-2.0 diff --git a/modules/fixtures/test-node/genesis-byron.json.license b/modules/fixtures/test-node/genesis-byron.json.license deleted file mode 100644 index e845f20..0000000 --- a/modules/fixtures/test-node/genesis-byron.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2025 Jared Pon - -SPDX-License-Identifier: Apache-2.0 diff --git a/modules/fixtures/test-node/genesis-conway.json.license b/modules/fixtures/test-node/genesis-conway.json.license deleted file mode 100644 index e845f20..0000000 --- a/modules/fixtures/test-node/genesis-conway.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2025 Jared Pon - -SPDX-License-Identifier: Apache-2.0 diff --git a/modules/fixtures/test-node/genesis-shelley.json.license b/modules/fixtures/test-node/genesis-shelley.json.license deleted file mode 100644 index e845f20..0000000 --- a/modules/fixtures/test-node/genesis-shelley.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2025 Jared Pon - -SPDX-License-Identifier: Apache-2.0 diff --git a/modules/fixtures/test-node/kes.skey.license b/modules/fixtures/test-node/kes.skey.license deleted file mode 100644 index e845f20..0000000 --- a/modules/fixtures/test-node/kes.skey.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2025 Jared Pon - -SPDX-License-Identifier: Apache-2.0 diff --git a/modules/fixtures/test-node/opcert.cert.license b/modules/fixtures/test-node/opcert.cert.license deleted file mode 100644 index e845f20..0000000 --- a/modules/fixtures/test-node/opcert.cert.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2025 Jared Pon - -SPDX-License-Identifier: Apache-2.0 diff --git a/modules/fixtures/test-node/topology.json.license b/modules/fixtures/test-node/topology.json.license deleted file mode 100644 index e845f20..0000000 --- a/modules/fixtures/test-node/topology.json.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2025 Jared Pon - -SPDX-License-Identifier: Apache-2.0 diff --git a/modules/fixtures/test-node/vrf.skey.license b/modules/fixtures/test-node/vrf.skey.license deleted file mode 100644 index e845f20..0000000 --- a/modules/fixtures/test-node/vrf.skey.license +++ /dev/null @@ -1,3 +0,0 @@ -SPDX-FileCopyrightText: 2025 Jared Pon - -SPDX-License-Identifier: Apache-2.0 From 7095cec9572184e3b32e0514e53b89c59f105472 Mon Sep 17 00:00:00 2001 From: Andrea Ciceri Date: Mon, 5 May 2025 11:14:59 +0200 Subject: [PATCH 4/6] Rephrase notes into a single note --- modules/node.nix | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/modules/node.nix b/modules/node.nix index f314ff4..ebf80bb 100644 --- a/modules/node.nix +++ b/modules/node.nix @@ -47,15 +47,13 @@ in config = lib.mkIf cfg.enable { environment.etc = lib.mkIf cfg.copyCardanoNodeConfigToEtc { "cardano-node/config.json" = { - # NOTE(jaredponn) April 11, 2025: The previous author mentions that this is a - # - # > hack to get config file path - # - # NOTE(jaredponn) April 11, 2025: This line forces the config file to be - # known at Nix evaluation time which causes trouble if you want to - # "dynamically create" the config which is desirable when -- for - # example -- creating a test node setup that sets the system - # start time to now. + # NOTE(jaredponn): This is a hack to get config file path + # This line forces the config file to be known at Nix + # evaluation time which causes trouble if you want to + # "dynamically create" the config which is desirable when -- + # for example -- creating a test node setup that sets the + # system start time to now. + text = readFile (elemAt (match ".* --config ([^ ]+) .*" (replaceStrings [ "\n" ] [ " " ] config.services.cardano-node.script)) 0); user = "cardano-node"; group = "cardano-node"; From e8f06bb5db16fdc38a2b49045ea9ce4cebfe0dab Mon Sep 17 00:00:00 2001 From: Andrea Ciceri Date: Mon, 5 May 2025 11:26:21 +0200 Subject: [PATCH 5/6] Rename `node` and `online-node` tests --- tests/default.nix | 2 +- tests/node.nix | 59 ++++++++++++++++++++++++++++--- tests/online-node.nix | 33 +++++++++++++++++ tests/test-node.nix | 82 ------------------------------------------- 4 files changed, 88 insertions(+), 88 deletions(-) create mode 100644 tests/online-node.nix delete mode 100644 tests/test-node.nix diff --git a/tests/default.nix b/tests/default.nix index cf7c91a..73975f3 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -2,7 +2,7 @@ imports = [ ./cardano-cli.nix ./node.nix - ./test-node.nix + ./online-node.nix ./ogmios.nix ./kupo.nix ./http.nix diff --git a/tests/node.nix b/tests/node.nix index 8699e3f..f032c99 100644 --- a/tests/node.nix +++ b/tests/node.nix @@ -1,14 +1,20 @@ { - perSystem.vmTests.tests.cardano-node = { - impure = true; + perSystem.vmTests.tests.node = { + impure = false; module = { nodes.machine = { pkgs, ... }: { cardano = { - network = "preview"; cli.enable = true; - node.enable = true; + test-node.enable = true; + test-node.initialFunds = { + addr_test1vzrv7az4xq620y20pyn44yhvl89r7nwa7ga5ftn9rleenxqharu33 = [ + 2000000 + 3000000 + ]; + addr_test1vr6ue2hmlnj8pzzqy7353lv3yj8xu7m24pgpctv7z3qhv8c3qdt46 = 1500000; + }; }; environment.systemPackages = with pkgs; [ @@ -24,7 +30,50 @@ in '' machine.wait_for_unit("cardano-node") - machine.wait_until_succeeds("""[[ $(echo "$(cardano-cli query tip --testnet-magic ${magic} | jq '.syncProgress' --raw-output) > 0.001" | bc) == "1" ]]""") + + # Check the test-node is working and syncing properly + machine.wait_until_succeeds("""[[ $(echo "$(cardano-cli query tip --testnet-magic ${magic} | jq '.syncProgress' --raw-output) > 0.001" | bc) == "1" ]]""", 10) + + # Check that the FAUCET address has a decent amount of ADA + # (note that because we have a non-zero amount of initial funds, some + # will be drained from the FAUCET initially) + machine.succeed(""" + test \ + "$(cardano-cli query utxo --output-json --address "$FAUCET" \ + | jq --arg faucet "$FAUCET" '.[] | (.address == $faucet and .value.lovelace >= 100000000000)')" \ + = \ + true + """) + + # Verify that the initial funds have been correctly distributed. + machine.wait_for_unit("test-cardano-node-initial-funds") + machine.succeed(""" + test \ + "$(cardano-cli query utxo --output-json --address addr_test1vzrv7az4xq620y20pyn44yhvl89r7nwa7ga5ftn9rleenxqharu33 \ + | jq 'to_entries | map(.value.value) | sort | . == [ {"lovelace" : 2000000}, {"lovelace" : 3000000} ]')" \ + = \ + true + """) + machine.succeed(""" + test \ + "$(cardano-cli query utxo --output-json --address addr_test1vr6ue2hmlnj8pzzqy7353lv3yj8xu7m24pgpctv7z3qhv8c3qdt46 \ + | jq 'to_entries | map(.value.value) | sort | . == [ {"lovelace" : 1500000} ]')" \ + = \ + true + """) + + # Verify that we can actually use the FAUCET to give ADA out + machine.succeed(""" + request-from-faucet --address addr_test1vq64jjlez93yz57ytlwtwsfz73n3elpty7e0w3z8l6yv3agc0e6jz --amount 10000000 + """) + machine.succeed(""" + test \ + "$(cardano-cli query utxo --output-json --address addr_test1vq64jjlez93yz57ytlwtwsfz73n3elpty7e0w3z8l6yv3agc0e6jz \ + | jq '.[] | (.value.lovelace >= 10000000)')" \ + = \ + true + """) + print(machine.succeed("systemd-analyze security cardano-node")) print('\nVM Test Succeeded.') ''; diff --git a/tests/online-node.nix b/tests/online-node.nix new file mode 100644 index 0000000..9a64607 --- /dev/null +++ b/tests/online-node.nix @@ -0,0 +1,33 @@ +{ + perSystem.vmTests.tests.online-node = { + impure = true; + module = { + nodes.machine = + { pkgs, ... }: + { + cardano = { + network = "preview"; + cli.enable = true; + node.enable = true; + }; + + environment.systemPackages = with pkgs; [ + jq + bc + ]; + }; + + testScript = + { nodes, ... }: + let + magic = toString nodes.machine.config.cardano.networkNumber; + in + '' + machine.wait_for_unit("cardano-node") + machine.wait_until_succeeds("""[[ $(echo "$(cardano-cli query tip --testnet-magic ${magic} | jq '.syncProgress' --raw-output) > 0.001" | bc) == "1" ]]""") + print(machine.succeed("systemd-analyze security cardano-node")) + print('\nVM Test Succeeded.') + ''; + }; + }; +} diff --git a/tests/test-node.nix b/tests/test-node.nix deleted file mode 100644 index ab9d3f1..0000000 --- a/tests/test-node.nix +++ /dev/null @@ -1,82 +0,0 @@ -{ - perSystem.vmTests.tests.test-cardano-node = { - impure = false; - module = { - nodes.machine = - { pkgs, ... }: - { - cardano = { - cli.enable = true; - test-node.enable = true; - test-node.initialFunds = { - addr_test1vzrv7az4xq620y20pyn44yhvl89r7nwa7ga5ftn9rleenxqharu33 = [ - 2000000 - 3000000 - ]; - addr_test1vr6ue2hmlnj8pzzqy7353lv3yj8xu7m24pgpctv7z3qhv8c3qdt46 = 1500000; - }; - }; - - environment.systemPackages = with pkgs; [ - jq - bc - ]; - }; - - testScript = - { nodes, ... }: - let - magic = toString nodes.machine.config.cardano.networkNumber; - in - '' - machine.wait_for_unit("cardano-node") - - # Check the test-node is working and syncing properly - machine.wait_until_succeeds("""[[ $(echo "$(cardano-cli query tip --testnet-magic ${magic} | jq '.syncProgress' --raw-output) > 0.001" | bc) == "1" ]]""", 10) - - # Check that the FAUCET address has a decent amount of ADA - # (note that because we have a non-zero amount of initial funds, some - # will be drained from the FAUCET initially) - machine.succeed(""" - test \ - "$(cardano-cli query utxo --output-json --address "$FAUCET" \ - | jq --arg faucet "$FAUCET" '.[] | (.address == $faucet and .value.lovelace >= 100000000000)')" \ - = \ - true - """) - - # Verify that the initial funds have been correctly distributed. - machine.wait_for_unit("test-cardano-node-initial-funds") - machine.succeed(""" - test \ - "$(cardano-cli query utxo --output-json --address addr_test1vzrv7az4xq620y20pyn44yhvl89r7nwa7ga5ftn9rleenxqharu33 \ - | jq 'to_entries | map(.value.value) | sort | . == [ {"lovelace" : 2000000}, {"lovelace" : 3000000} ]')" \ - = \ - true - """) - machine.succeed(""" - test \ - "$(cardano-cli query utxo --output-json --address addr_test1vr6ue2hmlnj8pzzqy7353lv3yj8xu7m24pgpctv7z3qhv8c3qdt46 \ - | jq 'to_entries | map(.value.value) | sort | . == [ {"lovelace" : 1500000} ]')" \ - = \ - true - """) - - # Verify that we can actually use the FAUCET to give ADA out - machine.succeed(""" - request-from-faucet --address addr_test1vq64jjlez93yz57ytlwtwsfz73n3elpty7e0w3z8l6yv3agc0e6jz --amount 10000000 - """) - machine.succeed(""" - test \ - "$(cardano-cli query utxo --output-json --address addr_test1vq64jjlez93yz57ytlwtwsfz73n3elpty7e0w3z8l6yv3agc0e6jz \ - | jq '.[] | (.value.lovelace >= 10000000)')" \ - = \ - true - """) - - print(machine.succeed("systemd-analyze security cardano-node")) - print('\nVM Test Succeeded.') - ''; - }; - }; -} From 47b8c25ec209b88b0cef4a947fe9c9c2366f21c6 Mon Sep 17 00:00:00 2001 From: Andrea Ciceri Date: Mon, 5 May 2025 11:51:21 +0200 Subject: [PATCH 6/6] Rename files and stylistic choices --- modules/default.nix | 4 ++-- modules/node.nix | 2 +- ...test-node.nix => private-testnet-node.nix} | 23 ++++++------------- tests/default.nix | 2 +- tests/{node.nix => private-testnet-node.nix} | 4 ++-- 5 files changed, 13 insertions(+), 22 deletions(-) rename modules/{test-node.nix => private-testnet-node.nix} (94%) rename tests/{node.nix => private-testnet-node.nix} (96%) diff --git a/modules/default.nix b/modules/default.nix index 1ce4d00..59b7eaf 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -24,10 +24,10 @@ ]; }; - test-node = { + private-testnet-node = { imports = [ config.flake.nixosModules.node - ./test-node.nix + ./private-testnet-node.nix ]; }; diff --git a/modules/node.nix b/modules/node.nix index ebf80bb..ee1e9c4 100644 --- a/modules/node.nix +++ b/modules/node.nix @@ -64,7 +64,7 @@ in # Set convenience environment variables when interacting with the node # via `cardano-cli` in the machine. # In particular, see - # + # https://github.com/IntersectMBO/cardano-cli/blob/master/cardano-cli/src/Cardano/CLI/Environment.hs # for details on the environment variables it reads. CARDANO_NODE_SOCKET_PATH = cfg.socketPath; CARDANO_NODE_NETWORK_ID = if config.cardano.network == "mainnet" then "mainnet" else config.cardano.networkNumber; diff --git a/modules/test-node.nix b/modules/private-testnet-node.nix similarity index 94% rename from modules/test-node.nix rename to modules/private-testnet-node.nix index 9a1877f..1392087 100644 --- a/modules/test-node.nix +++ b/modules/private-testnet-node.nix @@ -5,7 +5,7 @@ ... }: let - cfg = config.cardano.test-node; + cfg = config.cardano.private-testnet-node; in { @@ -14,7 +14,7 @@ in ./node.nix ]; - options.cardano.test-node = { + options.cardano.private-testnet-node = { enable = lib.mkEnableOption '' cardano-devnet node (a private testnet node) which -- when enabled -- switches the system's cardano-node to a private testnet node (with its @@ -69,7 +69,6 @@ in }; # The following options are the genesis files for specific eras - ############################## genesisAlonzo = lib.mkOption { internal = true; type = lib.types.path; @@ -95,7 +94,6 @@ in }; # The following options are wrappers for the options provided by the cardano-node - ############################## nodeConfigFile = lib.mkOption { internal = true; type = lib.types.path; @@ -147,7 +145,7 @@ in cardano.network = lib.mkForce "private"; # Create a directory of the test node's config files - # Why don't we just link the Cardano node directly to the files in + # We don't just link the Cardano node directly to the files in # `./fixtures/test-node/`? This is because we need to dynamically fill some # values in when the system is running e.g. the system start time. systemd.services.cardano-node-config = { @@ -219,7 +217,7 @@ in # messes with things. Note that if `useSystemdReload` is true, it makes # the `cardano-node` go looking in `/etc/cardano-node/topology-0.yaml` # instead of whatever value we provide. See - # + # https://github.com/IntersectMBO/cardano-node/blob/aec56982f99a3e94d6cde969f666133ff2f68890/nix/nixos/cardano-node-service.nix#L586-L599 # for details. useSystemdReload = lib.mkForce false; }; @@ -255,8 +253,8 @@ in 1>&2 echo "Distributing initial funds." ${lib.attrsets.foldlAttrs ( acc: addr: amountOrAmounts: - # WARNING(jaredponn) April 22, 2025: probably terrible time complexity. - # NOTE(jaredponn) April 22, 2025: Loosely, this convoluted nix + # WARNING(jaredponn): probably terrible time complexity. + # NOTE(jaredponn): Loosely, this convoluted nix # expression builds a shell script like # ``` # request-from-faucet --address --amount @@ -321,16 +319,12 @@ in 1>&2 echo "Creating a UTxO for $ADDRESS with $AMOUNT lovelace from $FAUCET" # Temporary working directory - ############################# TMP="$(mktemp -d)" trap "rm -rf \$TMP" EXIT # Build and sign the tx from the faucet - ############################# - # NOTE(jaredponn) April 21, 2025: Most of the - # tx building follows from the following - # articles: + # NOTE(jaredponn) Most of the tx building follows from the following articles: # - https://developers.cardano.org/docs/get-started/create-simple-transaction/ # - https://github.com/cardano-scaling/hydra/blob/master/demo/seed-devnet.sh @@ -371,7 +365,6 @@ in 1>&2 echo "Finished building and signing transaction $TX_ID" # Await the tx - ############################# 1>&2 echo "Awaiting $TX_ID by waiting for tx-in $TX_IN" while test "$(cardano-cli query utxo --tx-in "$TX_IN" --output-json | jq length)" -eq 0; do @@ -395,7 +388,5 @@ in systemPackages = [ pkgs.request-from-faucet ]; }; - }; - } diff --git a/tests/default.nix b/tests/default.nix index 73975f3..2e7c11c 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -1,8 +1,8 @@ { imports = [ ./cardano-cli.nix - ./node.nix ./online-node.nix + ./private-testnet-node.nix ./ogmios.nix ./kupo.nix ./http.nix diff --git a/tests/node.nix b/tests/private-testnet-node.nix similarity index 96% rename from tests/node.nix rename to tests/private-testnet-node.nix index f032c99..1480d13 100644 --- a/tests/node.nix +++ b/tests/private-testnet-node.nix @@ -7,8 +7,8 @@ { cardano = { cli.enable = true; - test-node.enable = true; - test-node.initialFunds = { + private-testnet-node.enable = true; + private-testnet-node.initialFunds = { addr_test1vzrv7az4xq620y20pyn44yhvl89r7nwa7ga5ftn9rleenxqharu33 = [ 2000000 3000000