/ teleport_test.sh
teleport_test.sh
 1  #!/bin/bash
 2  echo "๐Ÿงน CLEANING UP..."
 3  pkill -9 -f abzu
 4  rm -rf .library_data .seeker_data cid.txt
 5  
 6  echo "๐Ÿ“š STARTING NODE A (The Library)..."
 7  # We wait slightly longer to ensure full boot
 8  ./target/debug/abzu --listen 9000 --rpc 9001 --data-dir .library_data > library.log 2>&1 &
 9  PID_A=$!
10  sleep 3
11  
12  echo "fw UPLOADING CONTENT..."
13  # Upload content and capture the JSON response
14  RESPONSE=$(curl -s -X POST -H "Content-Type: application/json" \
15    -d '{"jsonrpc":"2.0","method":"upload_content","params":["VEhFX0VBR0xFX0hBU19MQU5ERUQ="],"id":1}' \
16    http://127.0.0.1:9001)
17  
18  # Parse CID using Python
19  CID=$(echo $RESPONSE | python3 -c "import sys, json; print(json.load(sys.stdin)['result']['cid'])")
20  echo "๐Ÿ”‘ CID CAPTURED: $CID"
21  
22  echo "๐Ÿ”ญ STARTING NODE B (The Seeker)..."
23  # Connect Node B to Node A
24  ./target/debug/abzu --listen 9002 --rpc 9003 --data-dir .seeker_data --peer 127.0.0.1:9000 > seeker.log 2>&1 &
25  PID_B=$!
26  sleep 3
27  
28  echo "โšก๏ธ TELEPORTING CONTENT..."
29  # Ask Node B (9003) for the content
30  DOWNLOAD=$(curl -s -X POST -H "Content-Type: application/json" \
31    -d "{\"jsonrpc\":\"2.0\",\"method\":\"download_content\",\"params\":[\"$CID\"],\"id\":1}" \
32    http://127.0.0.1:9003)
33  
34  echo "๐Ÿ“ฅ DOWNLOAD RESULT: $DOWNLOAD"
35  
36  # Verification
37  if [[ "$DOWNLOAD" == *"VEhFX0VBR0xFX0hBU19MQU5ERUQ="* ]]; then
38    echo ""
39    echo "โœ… โœ… โœ… TELEPORTATION SUCCESSFUL โœ… โœ… โœ…"
40  else
41    echo ""
42    echo "โŒ TEST FAILED"
43    echo "Check library.log and seeker.log"
44  fi
45  
46  # Cleanup
47  kill $PID_A $PID_B