Improve test_blossom

This commit is contained in:
Mike Dilger 2024-12-10 09:40:06 +13:00
parent 3cacc4e963
commit 7d91a47ac2
No known key found for this signature in database
GPG Key ID: 47581A78D4329BA4
4 changed files with 12 additions and 6 deletions

BIN
test_blossom/Example.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -25,9 +25,9 @@ allow_scrape_if_max_seconds = 7200
max_subscriptions = 128
serve_ephemeral = true
serve_relay_lists = true
server_log_level = "Info"
library_log_level = "Info"
client_log_level = "Warn"
server_log_level = "Debug"
library_log_level = "Debug"
client_log_level = "Debug"
enable_ip_blocking = true
minimum_ban_seconds = 1
timeout_seconds = 60

View File

@ -20,20 +20,23 @@ fi
# UPLOAD TEST ------------
FILE="./avatar-placeholder.webp"
FILE="./Example.png"
HASH=$(sha256sum $FILE | awk '{print $1}')
# Generate nostr auth
AUTH=$(./create_auth.sh upload $HASH)
# Upload
DESCRIPTOR=$(curl -s --data-binary @"$FILE" -X PUT --header "$AUTH" http://127.0.0.1:8089/upload)
# Upload (note we clobber the content type)
DESCRIPTOR=$(curl -vfs --data-binary @"$FILE" -H "Content-Type: " -X PUT --header "$AUTH" http://127.0.0.1:8089/upload)
if [ $? -ne 0 ] ; then
echo "FAILED: Curl (uploading) exited with a non-zero status"
exit 1
fi
echo "PASS: FILE UPLOADED"
## FIXME check for 4xx and 5xx error codes
# Extract the sha256 and compare it
DHASH=$(echo "$DESCRIPTOR" | jq -r .sha256)
if [ $? -ne 0 ] ; then
@ -42,6 +45,7 @@ if [ $? -ne 0 ] ; then
fi
if [ "$HASH" != "$DHASH" ] ; then
echo "returned descriptor 'sha256' does not match the hash"
exit 1
fi
echo "PASS: DESCRIPTOR HASH MATCHES"
@ -52,6 +56,8 @@ if [ $? -ne 0 ] ; then
exit 1
fi
echo "Descriptor URL = $URL"
# DOWNLOAD TEST -----------
curl -s "$URL" > downloaded