diff --git a/.github/workflows/nix-jobs-test.yaml b/.github/workflows/nix-jobs-test.yaml new file mode 100644 index 0000000..17978a0 --- /dev/null +++ b/.github/workflows/nix-jobs-test.yaml @@ -0,0 +1,81 @@ +on: + pull_request: + +jobs: + nix-jobs-test: + name: "Test nix jobs" + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: "${{github.head_ref || github.ref_name}}" + - name: Install Nix + uses: cachix/install-nix-action@v27 + with: + extra_nix_config: | + accept-flake-config = true + experimental-features = fetch-closure flakes nix-command + substituters = https://cache.iog.io https://cache.nixos.org/ + trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= + - name: Test + run: | + nix --version + + # Enable tracing + export DEBUG="true" + + # Default base paths + export GENESIS_DIR="workbench/custom" + export KEY_DIR="workbench/envs/custom" + export DATA_DIR="workbench/rundir" + + # Fake testing UTxOs + export BYRON_UTXO='{"txin":"1e6f026dfa9aa3deb43a7a4c64d9e002d3224ce707e2a4bb45b0a93e465a4e20#0","address":"2657WMsDfac6yNxPyqZPCamHhH8pfYAaMgXFTxsag4n3ttWqVAz2gxRMomvJJMyF4","amount":30000000000000000}' + export UTXO='{"txin":"cde023e0da05739ebcfeb7ab3ffaa467fa38fb508eddcc2c10a78bf06ff23f2b#0","address":"addr_test1vzyhu8wp6sx85dukujyuk0ltvqzjfx6vlpvwdf9dla9zg8qlez2ut","amount":30000000000000000}' + + # Other params + export BYRON_SIGNING_KEY="$KEY_DIR/utxo-keys/shelley.000.skey" + export ERA_CMD="alonzo" + export MAJOR_VERSION="7" + export PAYMENT_KEY="$KEY_DIR/utxo-keys/rich-utxo" + export POOL_NAMES="sp-1 sp-2 sp-3" + export STAKE_POOL_DIR="workbench/custom/groups/stake-pools" + export SUBMIT_TX="false" + export TESTNET_MAGIC="42" + export UNSTABLE="false" + export UNSTABLE_LIB="false" + export USE_ENCRYPTION="false" + export USE_DECRYPTION="false" + export USE_NODE_CONFIG_BP="false" + + JOBS=( + "job-gen-custom-node-config-data" + "job-create-stake-pool-keys" + "job-move-genesis-utxo" + "job-register-stake-pools" + "job-delegate-rewards-stake-key" + "job-update-proposal-hard-fork" + ) + + RUN_TESTS() { + echo "Running legacy nix job .#job-gen-custom-node-config" + nix run .#job-gen-custom-node-config + rm -rf workbench + + for i in ${JOBS[@]}; do + echo "Running nix job .#$i" + nix run ".#$i" + done + } + + echo + echo "Run nix job tests with release versioning..." + RUN_TESTS + echo + + echo "Now run nix job tests again with pre-release versioning..." + export UNSTABLE="true" + export UNSTABLE_LIB="true" + rm -rf workbench + RUN_TESTS diff --git a/flakeModules/jobs.nix b/flakeModules/jobs.nix index 1480fd0..f439fec 100644 --- a/flakeModules/jobs.nix +++ b/flakeModules/jobs.nix @@ -109,6 +109,7 @@ in { # [$UNSTABLE] # [$USE_DECRYPTION] # [$USE_SHELL_BINS] + # [$UTXO] if [ -z "''${FEE:-}" ]; then echo "Fee for update proposal tx is defaulting to 500000 lovelace" @@ -121,20 +122,22 @@ in { --testnet-magic "$TESTNET_MAGIC" ) - UTXO=$( - "''${CARDANO_CLI[@]}" query utxo \ - --address "$CHANGE_ADDRESS" \ - --testnet-magic "$TESTNET_MAGIC" \ - --out-file /dev/stdout \ - | jq -r --arg fee "$FEE" 'to_entries - | - [ - sort_by(.value.value.lovelace)[] - | select(.value.value > ($fee | tonumber)) - | {"txin": .key, "address": .value.address, "amount": .value.value.lovelace} - ] - [0]' - ) + if [ -z "''${UTXO:-}" ]; then + UTXO=$( + "''${CARDANO_CLI[@]}" query utxo \ + --address "$CHANGE_ADDRESS" \ + --testnet-magic "$TESTNET_MAGIC" \ + --out-file /dev/stdout \ + | jq -r --arg fee "$FEE" 'to_entries + | + [ + sort_by(.value.value.lovelace)[] + | select(.value.value > ($fee | tonumber)) + | {"txin": .key, "address": .value.address, "amount": .value.value.lovelace} + ] + [0]' + ) + fi TXIN=$(jq -r '.txin' <<< "$UTXO") TXVAL=$(jq -r '.amount' <<< "$UTXO") @@ -366,6 +369,7 @@ in { fi # Use the new create-testnet-data cli cmd + mkdir -p "$GENESIS_DIR" "''${CARDANO_CLI[@]}" genesis create-testnet-data \ --genesis-keys "$NUM_GENESIS_KEYS" \ --utxo-keys 1 \ @@ -660,6 +664,7 @@ in { # [$USE_DECRYPTION] # [$USE_ENCRYPTION] # [$USE_SHELL_BINS] + # [$UTXO] [ -n "''${DEBUG:-}" ] && set -x @@ -712,20 +717,22 @@ in { --out-file "$POOL_NAME"-reward-delegation.cert # Generate transaction - UTXO=$( - "''${CARDANO_CLI[@]}" query utxo \ - --address "$CHANGE_ADDRESS" \ - --testnet-magic "$TESTNET_MAGIC" \ - --out-file /dev/stdout \ - | jq -r --arg fee "$FEE" 'to_entries - | - [ - sort_by(.value.value.lovelace)[] - | select(.value.value > ($fee | tonumber)) - | {"txin": .key, "address": .value.address, "amount": .value.value.lovelace} - ] - [0]' - ) + if [ -z "''${UTXO:-}" ]; then + UTXO=$( + "''${CARDANO_CLI[@]}" query utxo \ + --address "$CHANGE_ADDRESS" \ + --testnet-magic "$TESTNET_MAGIC" \ + --out-file /dev/stdout \ + | jq -r --arg fee "$FEE" 'to_entries + | + [ + sort_by(.value.value.lovelace)[] + | select(.value.value > ($fee | tonumber)) + | {"txin": .key, "address": .value.address, "amount": .value.value.lovelace} + ] + [0]' + ) + fi TXIN=$(jq -r '.txin' <<< "$UTXO") TXVAL=$(jq -r '.amount' <<< "$UTXO") @@ -784,6 +791,7 @@ in { # [$USE_DECRYPTION] # [$USE_ENCRYPTION] # [$USE_SHELL_BINS] + # [$UTXO] [ -n "''${DEBUG:-}" ] && set -x @@ -893,20 +901,22 @@ in { encrypt_check "$NO_DEPLOY_FILE"-reward-payment-stake.addr # Generate transaction - UTXO=$( - "''${CARDANO_CLI[@]}" query utxo \ - --address "$CHANGE_ADDRESS" \ - --testnet-magic "$TESTNET_MAGIC" \ - --out-file /dev/stdout \ - | jq -r --arg fee "$FEE" 'to_entries - | - [ - sort_by(.value.value.lovelace)[] - | select(.value.value > ($fee | tonumber)) - | {"txin": .key, "address": .value.address, "amount": .value.value.lovelace} - ] - [0]' - ) + if [ -z "''${UTXO:-}" ]; then + UTXO=$( + "''${CARDANO_CLI[@]}" query utxo \ + --address "$CHANGE_ADDRESS" \ + --testnet-magic "$TESTNET_MAGIC" \ + --out-file /dev/stdout \ + | jq -r --arg fee "$FEE" 'to_entries + | + [ + sort_by(.value.value.lovelace)[] + | select(.value.value > ($fee | tonumber)) + | {"txin": .key, "address": .value.address, "amount": .value.value.lovelace} + ] + [0]' + ) + fi TXIN=$(jq -r '.txin' <<< "$UTXO") TXVAL=$(jq -r '.amount' <<< "$UTXO") @@ -1050,6 +1060,7 @@ in { text = '' # Inputs: # $BYRON_SIGNING_KEY + # [$BYRON_UTXO] # [$DEBUG] # [$ERA] (deprecated `--$ERA-era` flag) # [$ERA_CMD] @@ -1065,20 +1076,24 @@ in { ${secretsFns} ${selectCardanoCli} - BYRON_UTXO=$( - "''${CARDANO_CLI[@]}" query utxo \ - --whole-utxo \ - --testnet-magic "$TESTNET_MAGIC" \ - --out-file /dev/stdout \ - | jq ' - to_entries[] - | {"txin": .key, "address": .value.address, "amount": .value.value.lovelace} - | select(.amount > 0) - ' - ) + if [ -z "''${BYRON_UTXO:-}" ]; then + BYRON_UTXO=$( + "''${CARDANO_CLI[@]}" query utxo \ + --whole-utxo \ + --testnet-magic "$TESTNET_MAGIC" \ + --out-file /dev/stdout \ + | jq ' + to_entries[] + | {"txin": .key, "address": .value.address, "amount": .value.value.lovelace} + | select(.amount > 0) + ' + ) + fi + FEE=200000 SUPPLY=$(echo "$BYRON_UTXO" | jq -r '.amount - 200000') BYRON_ADDRESS=$(echo "$BYRON_UTXO" | jq -r '.address') + ls -laR workspace PAYMENT_ADDRESS=$( "''${CARDANO_CLI[@]}" address build \ --payment-verification-key-file "$(decrypt_check "$PAYMENT_KEY".vkey)" \