47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
const { io } = require("socket.io-client");
|
|
|
|
const socket = io("http://localhost:3000");
|
|
|
|
const walletAddress = "8vRn2vQb3RsDw2yNtyQESodn7Tr6THzgAgn1ai7srdvM"; // Use the one from logs
|
|
const username = "TestUser";
|
|
|
|
console.log("Connecting to server...");
|
|
|
|
socket.on("connect", () => {
|
|
console.log("Connected:", socket.id);
|
|
socket.emit("join", { walletAddress, username });
|
|
});
|
|
|
|
socket.on("balanceUpdated", (data) => {
|
|
console.log("Joined successfully, balance:", data.balance);
|
|
console.log("Requesting profile...");
|
|
socket.emit("getProfile", walletAddress);
|
|
});
|
|
|
|
socket.on("profileData", (data) => {
|
|
console.log("SUCCESS: Profile data received!");
|
|
console.log("Username:", data.username);
|
|
console.log("Comment Count Type:", typeof data.posts[0]?.comment_count); // Should be number/string, not BigInt (object in JS if not serialized)
|
|
|
|
// Check if serialization worked (BigInts become strings usually)
|
|
// But data over JSON is already parsed.
|
|
console.log("Data sample:", JSON.stringify(data, null, 2));
|
|
|
|
process.exit(0);
|
|
});
|
|
|
|
socket.on("error", (err) => {
|
|
console.error("Error received:", err);
|
|
process.exit(1);
|
|
});
|
|
|
|
socket.on("disconnect", () => {
|
|
console.log("Disconnected from server");
|
|
});
|
|
|
|
// Timeout
|
|
setTimeout(() => {
|
|
console.error("Timeout waiting for profile data");
|
|
process.exit(1);
|
|
}, 5000);
|