From 82b569dca684cfe8ac5bd313a47ef6416a6cce8a Mon Sep 17 00:00:00 2001 From: Jonathan Harvey-Buschel Date: Fri, 23 Aug 2024 16:49:58 -0400 Subject: [PATCH 1/8] make: separate rebuilding itest litd and itest run --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 648adf0bd..31184ab37 100644 --- a/Makefile +++ b/Makefile @@ -217,11 +217,12 @@ build-itest: app-build CGO_ENABLED=0 $(GOBUILD) -tags="$(ITEST_TAGS)" -o itest/btcd-itest -ldflags "$(ITEST_LDFLAGS)" $(BTCD_PKG) CGO_ENABLED=0 $(GOBUILD) -tags="$(ITEST_TAGS)" -o itest/lnd-itest -ldflags "$(ITEST_LDFLAGS)" $(LND_PKG)/cmd/lnd -itest-only: +build-itest-litd: @$(call print, "Building itest binary.") CGO_ENABLED=0 $(GOBUILD) -tags="$(ITEST_TAGS)" -o itest/litd-itest -ldflags "$(ITEST_LDFLAGS)" $(PKG)/cmd/litd CGO_ENABLED=0 $(GOTEST) -v ./itest -tags="$(DEV_TAGS) $(ITEST_TAGS)" -c -o itest/itest.test +itest-only: build-itest-litd @$(call print, "Running integration tests.") rm -rf itest/*.log itest/.logs*; date scripts/itest_part.sh $(ITEST_FLAGS) From 30b3065995cb024ace1afb90c2affd552067f690 Mon Sep 17 00:00:00 2001 From: Jonathan Harvey-Buschel Date: Fri, 23 Aug 2024 16:51:25 -0400 Subject: [PATCH 2/8] chore: add vscode tasks to mirror make itest setup --- .vscode/tasks.json | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 000000000..fb3493644 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,62 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "shell", + "label": "build itest all", + "command": "make build-itest; make build-itest-litd", + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared", + "clear": false + }, + "problemMatcher": [] + }, + { + "type": "shell", + "label": "build itest litd", + "command": "make build-itest-litd", + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared", + "clear": false + }, + "problemMatcher": [] + }, + { + "type": "shell", + "label": "clear itest logs", + "options": { + "cwd": "${workspaceFolder}/itest" + }, + "command": "rm -rf ./*.log .logs*", + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared", + "clear": false + }, + "problemMatcher": [] + }, + { + "label": "reset before itest", + "dependsOn": [ + "build itest litd", + "clear itest logs" + ], + "presentation": { + "echo": true, + "reveal": "always", + "focus": false, + "panel": "shared", + "clear": false + }, + "problemMatcher": [] + } + ] +} \ No newline at end of file From f9939deabbc8e68422b8dd342c54c374d4373740 Mon Sep 17 00:00:00 2001 From: Jonathan Harvey-Buschel Date: Fri, 23 Aug 2024 16:52:30 -0400 Subject: [PATCH 3/8] chore: add vscode debug target for specific itest --- .vscode/launch.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.vscode/launch.json b/.vscode/launch.json index 6e0f47159..94cc25dd2 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,6 +4,22 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + "name": "Debug itest", + "type": "go", + "request": "launch", + "mode": "exec", + "preLaunchTask": "reset before itest", + "program": "itest/itest.test", + "args": [ + "-test.v", + "-test.run=TestLightningTerminal/test_custom_channels", + "-logoutput", + "-logdir=${workspaceFolder}/itest/.logs", + "-litdexec=${workspaceFolder}/itest/litd-itest", + "-btcdexec=${workspaceFolder}/itest/btcd-itest", + ] + }, { "name": "Debug Tests", "type": "node", From bb21c3c49e84353826de9e99670416db2bfa6c35 Mon Sep 17 00:00:00 2001 From: Gijs van Dam Date: Thu, 7 Nov 2024 15:03:54 +0100 Subject: [PATCH 4/8] chore: preferable setup with test-mode This commit changes the mode of itest configuration in `launch.json` to test-mode. It also removes the unused flag `btcdexec`. The binary is expected by lnd though, so it still needs to be built. --- .vscode/launch.json | 27 ++++++++++++++++++++------- .vscode/tasks.json | 21 ++++----------------- Makefile | 3 +-- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 94cc25dd2..39758196a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,30 +8,43 @@ "name": "Debug itest", "type": "go", "request": "launch", - "mode": "exec", + "mode": "test", "preLaunchTask": "reset before itest", - "program": "itest/itest.test", + "program": "${workspaceFolder}/itest", + "env": { + "CGO_ENABLED": "0", + }, "args": [ "-test.v", "-test.run=TestLightningTerminal/test_custom_channels", "-logoutput", "-logdir=${workspaceFolder}/itest/.logs", "-litdexec=${workspaceFolder}/itest/litd-itest", - "-btcdexec=${workspaceFolder}/itest/btcd-itest", - ] + ], + "buildFlags": [ + "-ldflags=-X github.com/lightningnetwork/lnd/build.RawTags=chainrpc,walletrpc,signrpc,invoicesrpc,autopilotrpc,watchtowerrpc,twclientrpc -X github.com/lightningnetwork/lnd/build.Commit=lightning-terminal-v0.4.0-alpha -X github.com/lightninglabs/loop.Commit=localbuild -X github.com/lightninglabs/pool.Commit=localbuild -X github.com/lightninglabs/lightning-terminal.Commit=localbuild", + "-tags=dev integration itest lowscrypt litd autopilotrpc signrpc walletrpc chainrpc invoicesrpc watchtowerrpc neutrinorpc peersrpc", + ], }, { "name": "Debug Tests", "type": "node", "request": "launch", "runtimeExecutable": "${workspaceRoot}/app/node_modules/.bin/react-scripts", - "args": ["test", "--runInBand", "--no-cache", "--watchAll=false"], + "args": [ + "test", + "--runInBand", + "--no-cache", + "--watchAll=false" + ], "cwd": "${workspaceRoot}/app/", "protocol": "inspector", "console": "integratedTerminal", "internalConsoleOptions": "neverOpen", - "env": { "CI": "true" }, + "env": { + "CI": "true" + }, "disableOptimisticBPs": true } ] -} +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index fb3493644..3a0d6e6d6 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,23 +1,10 @@ { - "version": "2.0.0", + "version": "2.0.0", "tasks": [ { "type": "shell", - "label": "build itest all", - "command": "make build-itest; make build-itest-litd", - "presentation": { - "echo": true, - "reveal": "always", - "focus": false, - "panel": "shared", - "clear": false - }, - "problemMatcher": [] - }, - { - "type": "shell", - "label": "build itest litd", - "command": "make build-itest-litd", + "label": "build itest", + "command": "make build-itest", "presentation": { "echo": true, "reveal": "always", @@ -46,7 +33,7 @@ { "label": "reset before itest", "dependsOn": [ - "build itest litd", + "build itest", "clear itest logs" ], "presentation": { diff --git a/Makefile b/Makefile index 31184ab37..648adf0bd 100644 --- a/Makefile +++ b/Makefile @@ -217,12 +217,11 @@ build-itest: app-build CGO_ENABLED=0 $(GOBUILD) -tags="$(ITEST_TAGS)" -o itest/btcd-itest -ldflags "$(ITEST_LDFLAGS)" $(BTCD_PKG) CGO_ENABLED=0 $(GOBUILD) -tags="$(ITEST_TAGS)" -o itest/lnd-itest -ldflags "$(ITEST_LDFLAGS)" $(LND_PKG)/cmd/lnd -build-itest-litd: +itest-only: @$(call print, "Building itest binary.") CGO_ENABLED=0 $(GOBUILD) -tags="$(ITEST_TAGS)" -o itest/litd-itest -ldflags "$(ITEST_LDFLAGS)" $(PKG)/cmd/litd CGO_ENABLED=0 $(GOTEST) -v ./itest -tags="$(DEV_TAGS) $(ITEST_TAGS)" -c -o itest/itest.test -itest-only: build-itest-litd @$(call print, "Running integration tests.") rm -rf itest/*.log itest/.logs*; date scripts/itest_part.sh $(ITEST_FLAGS) From 2fa35f0c351ac166bec29250caf60bedb9c57c06 Mon Sep 17 00:00:00 2001 From: ZZiigguurraatt Date: Thu, 27 Feb 2025 13:02:05 -0500 Subject: [PATCH 5/8] better document `launch.json` --- .vscode/launch.json | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 39758196a..c84f7efc7 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,8 +4,12 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + + //////////////////////////////// + // golang itest example + //////////////////////////////// { - "name": "Debug itest", + "name": "single itest example (test_custom_channels)", "type": "go", "request": "launch", "mode": "test", @@ -16,7 +20,16 @@ }, "args": [ "-test.v", + + // Find test names to run in `itest/litd_test_list_on_test.go` and + // then replace ` ` (spaces) with `_` (underscores). + // i.e. "test custom channels" --> "test_custom_channels" + // Some related examples of how to choose multiple tests to run at the + // same time as well as how to run tests outside of vscode can be + // found at: + // https://github.com/lightningnetwork/lnd/blob/master/itest/README.md "-test.run=TestLightningTerminal/test_custom_channels", + "-logoutput", "-logdir=${workspaceFolder}/itest/.logs", "-litdexec=${workspaceFolder}/itest/litd-itest", @@ -26,8 +39,14 @@ "-tags=dev integration itest lowscrypt litd autopilotrpc signrpc walletrpc chainrpc invoicesrpc watchtowerrpc neutrinorpc peersrpc", ], }, + + + //////////////////////////////// + // react GUI tests + //////////////////////////////// + { - "name": "Debug Tests", + "name": "react Debug Tests", "type": "node", "request": "launch", "runtimeExecutable": "${workspaceRoot}/app/node_modules/.bin/react-scripts", From 25ad9ec173e49d0323c16c5ba46af6d7d009a168 Mon Sep 17 00:00:00 2001 From: ZZiigguurraatt Date: Thu, 27 Feb 2025 14:22:41 -0500 Subject: [PATCH 6/8] rename .vscode to .vscode-samples --- {.vscode => .vscode-samples}/launch.json | 0 {.vscode => .vscode-samples}/settings.json | 0 {.vscode => .vscode-samples}/tasks.json | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename {.vscode => .vscode-samples}/launch.json (100%) rename {.vscode => .vscode-samples}/settings.json (100%) rename {.vscode => .vscode-samples}/tasks.json (100%) diff --git a/.vscode/launch.json b/.vscode-samples/launch.json similarity index 100% rename from .vscode/launch.json rename to .vscode-samples/launch.json diff --git a/.vscode/settings.json b/.vscode-samples/settings.json similarity index 100% rename from .vscode/settings.json rename to .vscode-samples/settings.json diff --git a/.vscode/tasks.json b/.vscode-samples/tasks.json similarity index 100% rename from .vscode/tasks.json rename to .vscode-samples/tasks.json From cda0c2b7aa8962a682990c864ede0c8b34df4e60 Mon Sep 17 00:00:00 2001 From: ZZiigguurraatt Date: Thu, 27 Feb 2025 14:23:23 -0500 Subject: [PATCH 7/8] add `itest/README.md` --- itest/README.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 itest/README.md diff --git a/itest/README.md b/itest/README.md new file mode 100644 index 000000000..8a0ea687b --- /dev/null +++ b/itest/README.md @@ -0,0 +1,7 @@ +## itest ## + +itests are Integration Tests for Lightning Terminal. + +For more information see +- https://github.com/lightningnetwork/lnd/blob/master/itest/README.md for an overview of the itest framework used by all Lightning Labs products. +- `./.vscode-samples/` for example files for configuring vscode to run itests with the debugger. From c0e009742d539dc9c63086e9e1a378fe656c0cf5 Mon Sep 17 00:00:00 2001 From: ZZiigguurraatt Date: Fri, 28 Feb 2025 10:58:01 -0500 Subject: [PATCH 8/8] launch.json: add "run all itests" --- .vscode-samples/launch.json | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/.vscode-samples/launch.json b/.vscode-samples/launch.json index c84f7efc7..5c50b4efc 100644 --- a/.vscode-samples/launch.json +++ b/.vscode-samples/launch.json @@ -21,11 +21,11 @@ "args": [ "-test.v", - // Find test names to run in `itest/litd_test_list_on_test.go` and + // Find itest names to run in `itest/litd_test_list_on_test.go` and // then replace ` ` (spaces) with `_` (underscores). // i.e. "test custom channels" --> "test_custom_channels" - // Some related examples of how to choose multiple tests to run at the - // same time as well as how to run tests outside of vscode can be + // Some related examples of how to choose multiple itests to run at the + // same time as well as how to run itests outside of vscode can be // found at: // https://github.com/lightningnetwork/lnd/blob/master/itest/README.md "-test.run=TestLightningTerminal/test_custom_channels", @@ -42,9 +42,34 @@ //////////////////////////////// - // react GUI tests + // run all golang itests //////////////////////////////// + { + "name": "run all itests", + "type": "go", + "request": "launch", + "mode": "test", + "preLaunchTask": "reset before itest", + "program": "${workspaceFolder}/itest", + "env": { + "CGO_ENABLED": "0", + }, + "args": [ + "-test.v", + "-logoutput", + "-logdir=${workspaceFolder}/itest/.logs", + "-litdexec=${workspaceFolder}/itest/litd-itest", + ], + "buildFlags": [ + "-ldflags=-X github.com/lightningnetwork/lnd/build.RawTags=chainrpc,walletrpc,signrpc,invoicesrpc,autopilotrpc,watchtowerrpc,twclientrpc -X github.com/lightningnetwork/lnd/build.Commit=lightning-terminal-v0.4.0-alpha -X github.com/lightninglabs/loop.Commit=localbuild -X github.com/lightninglabs/pool.Commit=localbuild -X github.com/lightninglabs/lightning-terminal.Commit=localbuild", + "-tags=dev integration itest lowscrypt litd autopilotrpc signrpc walletrpc chainrpc invoicesrpc watchtowerrpc neutrinorpc peersrpc", + ], + }, + + //////////////////////////////// + // react GUI tests + //////////////////////////////// { "name": "react Debug Tests", "type": "node",