diff --git a/backend-mock/index.js b/backend-mock/index.js index 46772c92..620f1511 100644 --- a/backend-mock/index.js +++ b/backend-mock/index.js @@ -19,7 +19,7 @@ require("dotenv").config(); const app = express(); const server = createServer(app); -const wss = new WebSocket.Server({ server, path: "/websocket" }); +const wss = new WebSocket.Server({ server, path: "/ws" }); app.use( cors({ credentials: true, origin: "http://localhost:3000" }), @@ -38,9 +38,7 @@ const PORT = 8000; server.listen(PORT, () => { console.info(`Server listening on http://localhost:${PORT}`); - console.info( - `WebSocket server is running on ws://localhost:${PORT}/websocket`, - ); + console.info(`WebSocket server is running on ws://localhost:${PORT}/ws`); }); /** @@ -48,7 +46,7 @@ server.listen(PORT, () => { */ wss.on("connection", (ws) => { - console.info("WebSocket connection established on /websocket"); + console.info("WebSocket connection established on /ws"); // Handle incoming messages ws.on("message", (message) => { diff --git a/backend-mock/lightning.js b/backend-mock/lightning.js index ee3994fe..1813c026 100644 --- a/backend-mock/lightning.js +++ b/backend-mock/lightning.js @@ -3,7 +3,7 @@ const router = express.Router(); const transactions = require("./transactions"); const util = require("./sse/util"); -let WALLET_LOCKED = false; +let WALLET_LOCKED = true; router.post("/add-invoice", (req, res) => { console.info( diff --git a/src/hooks/use-ws.tsx b/src/hooks/use-ws.tsx index 378c6aaf..3e3e071c 100644 --- a/src/hooks/use-ws.tsx +++ b/src/hooks/use-ws.tsx @@ -15,7 +15,7 @@ import { useCallback, useContext, useEffect } from "react"; import { useTranslation } from "react-i18next"; import { toast } from "react-toastify"; -const WEBSOCKET_URL = "/websocket"; +const WEBSOCKET_URL = "/ws"; function useWebSocket() { const { t } = useTranslation(); diff --git a/src/pages/Home/index.tsx b/src/pages/Home/index.tsx index d2bb67d9..5fa3a739 100644 --- a/src/pages/Home/index.tsx +++ b/src/pages/Home/index.tsx @@ -105,7 +105,7 @@ const Home: FC = () => { } } catch (err: any) { if (err.response.status === HttpStatusCode.Locked) { - setWalletLocked(false); + setWalletLocked(true); } else { setTxError(checkError(err)); } diff --git a/src/utils/test-utils.tsx b/src/utils/test-utils.tsx index 9b75fe7c..6077740b 100644 --- a/src/utils/test-utils.tsx +++ b/src/utils/test-utils.tsx @@ -4,10 +4,10 @@ import { AppContextType, } from "@/context/app-context"; import { - SSEContext, - sseContextDefault, - SSEContextType, -} from "@/context/sse-context"; + WebSocketContext, + websocketContextDefault, + WebSocketContextType, +} from "@/context/ws-context"; import i18n from "@/i18n/test_config"; import { render, RenderOptions } from "@testing-library/react"; import { FC, PropsWithChildren, ReactElement } from "react"; @@ -15,7 +15,7 @@ import { I18nextProvider } from "react-i18next"; import { BrowserRouter } from "react-router-dom"; type Props = { - sseProps: SSEContextType; + sseProps: WebSocketContextType; appProps: AppContextType; }; @@ -26,9 +26,9 @@ const AllTheProviders: FC> = ({ }) => { return ( - @@ -40,7 +40,7 @@ const AllTheProviders: FC> = ({ > {children} - + ); }; @@ -49,7 +49,7 @@ const customRender = ( ui: ReactElement, options?: Omit & { providerOptions?: { - sseProps?: Partial; + sseProps?: Partial; appProps?: Partial; }; }, diff --git a/vite.config.ts b/vite.config.ts index 351acc68..a6479dbd 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -32,7 +32,7 @@ export default defineConfig({ changeOrigin: true, secure: false, }, - "/websocket": { + "/ws": { target: "ws://localhost:8000", changeOrigin: true, secure: false,