diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.yml index 168f9d6..620debb 100644 --- a/.github/workflows/release-cli.yml +++ b/.github/workflows/release-cli.yml @@ -47,3 +47,92 @@ jobs: md5sum: false sha256sum: false compress_assets: false + smoke-test-linux-amd64: + runs-on: ubuntu-latest + needs: + - build-all-for-all + steps: + - name: download and smoke test latest binary + run: | + set -eo pipefail # exit on error, and on pipe failures + + echo "downloading nak binary from releases" + RELEASE_URL="https://api.github.com/repos/fiatjaf/nak/releases/latest" + wget $(wget -q -O - ${RELEASE_URL} | jq -r '.assets[] | select(.name | contains("linux-amd64")) | .browser_download_url') -O nak -nv + chmod +x nak + + echo "printing version..." + ./nak --version + + # generate and manipulate keys + echo "testing key operations..." + SECRET_KEY=$(./nak key generate) + PUBLIC_KEY=$(echo $SECRET_KEY | ./nak key public) + echo "generated key pair: $SECRET_KEY => $PUBLIC_KEY" + + # create events + echo "testing event creation..." + ./nak event -c "hello world" + HELLOWORLD=$(./nak event -c "hello world") + echo " hello world again: $HELLOWORLD" + ./nak event --ts "2 days ago" -c "event with timestamp" + ./nak event -k 1 -t "t=test" -c "event with tag" + + # test NIP-19 encoding/decoding + echo "testing NIP-19 encoding/decoding..." + NSEC=$(echo $SECRET_KEY | ./nak encode nsec) + echo "encoded nsec: $NSEC" + ./nak encode npub 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 + EVENT_ID="5ae731bbc7711f78513da14927c48cc7143a91e6cad0565fdc4d73b8967a7d59" + NEVENT1=$(./nak encode nevent $EVENT_ID) + echo "encoded nevent1: $NEVENT1" + ./nak decode $NEVENT1 + ./nak decode npub180cvv07tjdrrgpa0j7j7tmnyl2yr6yr7l8j4s3evf6u64th6gkwsyjh6w6 + + # test event verification + echo "testing event verification..." + # create an event and verify it + VERIFY_EVENT=$(./nak event -c "verify me") + echo $VERIFY_EVENT | ./nak verify + + # test PoW + echo "testing pow..." + ./nak event -c "testing pow" --pow 8 + + # test NIP-49 key encryption/decryption + echo "testing NIP-49 key encryption/decryption..." + ENCRYPTED_KEY=$(./nak key encrypt $SECRET_KEY "testpassword") + echo "encrypted key: ${ENCRYPTED_KEY:0:20}..." + DECRYPTED_KEY=$(./nak key decrypt $ENCRYPTED_KEY "testpassword") + if [ "$DECRYPTED_KEY" != "$SECRET_KEY" ]; then + echo "nip-49 encryption/decryption test failed!" + exit 1 + fi + + # test multi-value tags + echo "testing multi-value tags..." + ./nak event --ts "yesterday" -t "e=f59911b561c37c90b01e9e5c2557307380835c83399756f4d62d8167227e420a;wss://relay.example.com;root" -c "testing multi-value tags" + + # test relay operations (with a public relay) + echo "testing publishing..." + # publish a simple event to a public relay + EVENT_JSON=$(./nak event --sec $SECRET_KEY -c "test from nak smoke test" nos.lol) + EVENT_ID=$(echo $EVENT_JSON | jq -r .id) + echo "published event ID: $EVENT_ID" + + # wait a moment for propagation + sleep 2 + + # fetch the event we just published + ./nak req -i $EVENT_ID nos.lol + + # test serving (just start and immediately kill) + echo "testing serve command..." + timeout 2s ./nak serve || true + + # test filesystem mount (just start and immediately kill) + echo "testing fs mount command..." + mkdir -p /tmp/nostr-mount + timeout 2s ./nak fs --sec $SECRET_KEY /tmp/nostr-mount || true + + echo "all tests passed" diff --git a/.github/workflows/smoke-test-release.yml b/.github/workflows/smoke-test-release.yml deleted file mode 100644 index 6b6ebba..0000000 --- a/.github/workflows/smoke-test-release.yml +++ /dev/null @@ -1,97 +0,0 @@ -name: Smoke test the binary - -on: - workflow_run: - workflows: ["build cli for all platforms"] - types: - - completed - branches: - - master - -jobs: - smoke-test-linux-amd64: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} - steps: - - name: Download and smoke test latest binary - run: | - set -eo pipefail # Exit on error, and on pipe failures - - echo "Downloading nak binary from releases" - RELEASE_URL="https://api.github.com/repos/fiatjaf/nak/releases/latest" - wget $(wget -q -O - ${RELEASE_URL} | jq -r '.assets[] | select(.name | contains("linux-amd64")) | .browser_download_url') -O nak -nv - chmod +x nak - - echo "Running basic tests..." - ./nak --version - - # Generate and manipulate keys - echo "Testing key operations..." - SECRET_KEY=$(./nak key generate) - PUBLIC_KEY=$(echo $SECRET_KEY | ./nak key public) - echo "Generated key pair: $PUBLIC_KEY" - - # Create events - echo "Testing event creation..." - ./nak event -c "hello world" - ./nak event --ts "2 days ago" -c "event with timestamp" - ./nak event -k 1 -t "t=test" -c "event with tag" - - # Test NIP-19 encoding/decoding - echo "Testing NIP-19 encoding/decoding..." - NSEC=$(echo $SECRET_KEY | ./nak encode nsec) - echo "Encoded nsec: $NSEC" - ./nak encode npub 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 - NOTE_ID="5ae731bbc7711f78513da14927c48cc7143a91e6cad0565fdc4d73b8967a7d59" - NOTE1=$(./nak encode note $NOTE_ID) - echo "Encoded note1: $NOTE1" - ./nak decode $NOTE1 - ./nak decode npub180cvv07tjdrrgpa0j7j7tmnyl2yr6yr7l8j4s3evf6u64th6gkwsyjh6w6 - - # Test event verification - echo "Testing event verification..." - # Create an event and verify it - VERIFY_EVENT=$(./nak event -c "verify me") - echo $VERIFY_EVENT | ./nak verify - - # Test PoW - echo "Testing PoW..." - ./nak event -c "testing pow" --pow 8 - - # Test NIP-49 key encryption/decryption - echo "Testing NIP-49 key encryption/decryption..." - ENCRYPTED_KEY=$(./nak key encrypt $SECRET_KEY "testpassword") - echo "Encrypted key: ${ENCRYPTED_KEY:0:20}..." - DECRYPTED_KEY=$(./nak key decrypt $ENCRYPTED_KEY "testpassword") - if [ "$DECRYPTED_KEY" != "$SECRET_KEY" ]; then - echo "NIP-49 encryption/decryption test failed!" - exit 1 - fi - - # Test multi-value tags - echo "Testing multi-value tags..." - ./nak event --ts "yesterday" -t "e=f59911b561c37c90b01e9e5c2557307380835c83399756f4d62d8167227e420a;wss://relay.example.com;root" -c "Testing multi-value tags" - - # Test relay operations (with a public relay) - echo "Testing relay operations..." - # Publish a simple event to a public relay - EVENT_JSON=$(./nak event --sec $SECRET_KEY -c "Test from nak smoke test" nos.lol) - EVENT_ID=$(echo $EVENT_JSON | jq -r .id) - echo "Published event ID: $EVENT_ID" - - # Wait a moment for propagation - sleep 2 - - # Fetch the event we just published - ./nak req -i $EVENT_ID nos.lol - - # Test serving (just start and immediately kill) - echo "Testing serve command..." - timeout 2s ./nak serve || true - - # Test filesystem mount (just start and immediately kill) - echo "Testing fs mount command..." - mkdir -p /tmp/nostr-mount - timeout 2s ./nak fs --sec $SECRET_KEY /tmp/nostr-mount || true - - echo "All tests passed"