multi: move itest out of lntest

This commit moves all the test cases living in `itest` out of `lntest`,
further making `lntest` an independent package for general testing.
This commit is contained in:
yyforyongyu 2022-08-11 19:39:40 +08:00
parent 142b00711f
commit 0bc86a3b4b
No known key found for this signature in database
GPG key ID: 9BCD95C4FF296868
59 changed files with 19 additions and 19 deletions

12
.gitignore vendored
View file

@ -32,12 +32,12 @@ _testmain.go
/lncli-itest /lncli-itest
# Integration test log files # Integration test log files
lntest/itest/*.log itest/*.log
lntest/itest/.backendlogs itest/.backendlogs
lntest/itest/.minerlogs itest/.minerlogs
lntest/itest/lnd-itest itest/lnd-itest
lntest/itest/btcd-itest itest/btcd-itest
lntest/itest/.logs-* itest/.logs-*
cmd/cmd cmd/cmd
*.key *.key

View file

@ -93,19 +93,19 @@ build:
build-itest: build-itest:
@$(call print, "Building itest btcd and lnd.") @$(call print, "Building itest btcd and lnd.")
CGO_ENABLED=0 $(GOBUILD) -tags="rpctest" -o lntest/itest/btcd-itest$(EXEC_SUFFIX) $(DEV_LDFLAGS) $(BTCD_PKG) CGO_ENABLED=0 $(GOBUILD) -tags="rpctest" -o itest/btcd-itest$(EXEC_SUFFIX) $(DEV_LDFLAGS) $(BTCD_PKG)
CGO_ENABLED=0 $(GOBUILD) -tags="$(ITEST_TAGS)" -o lntest/itest/lnd-itest$(EXEC_SUFFIX) $(DEV_LDFLAGS) $(PKG)/cmd/lnd CGO_ENABLED=0 $(GOBUILD) -tags="$(ITEST_TAGS)" -o itest/lnd-itest$(EXEC_SUFFIX) $(DEV_LDFLAGS) $(PKG)/cmd/lnd
@$(call print, "Building itest binary for ${backend} backend.") @$(call print, "Building itest binary for ${backend} backend.")
CGO_ENABLED=0 $(GOTEST) -v ./lntest/itest -tags="$(DEV_TAGS) $(RPC_TAGS) rpctest $(backend)" -c -o lntest/itest/itest.test$(EXEC_SUFFIX) CGO_ENABLED=0 $(GOTEST) -v ./itest -tags="$(DEV_TAGS) $(RPC_TAGS) rpctest $(backend)" -c -o itest/itest.test$(EXEC_SUFFIX)
build-itest-race: build-itest-race:
@$(call print, "Building itest btcd and lnd with race detector.") @$(call print, "Building itest btcd and lnd with race detector.")
CGO_ENABLED=0 $(GOBUILD) -tags="rpctest" -o lntest/itest/btcd-itest$(EXEC_SUFFIX) $(DEV_LDFLAGS) $(BTCD_PKG) CGO_ENABLED=0 $(GOBUILD) -tags="rpctest" -o itest/btcd-itest$(EXEC_SUFFIX) $(DEV_LDFLAGS) $(BTCD_PKG)
CGO_ENABLED=1 $(GOBUILD) -race -tags="$(ITEST_TAGS)" -o lntest/itest/lnd-itest$(EXEC_SUFFIX) $(DEV_LDFLAGS) $(PKG)/cmd/lnd CGO_ENABLED=1 $(GOBUILD) -race -tags="$(ITEST_TAGS)" -o itest/lnd-itest$(EXEC_SUFFIX) $(DEV_LDFLAGS) $(PKG)/cmd/lnd
@$(call print, "Building itest binary for ${backend} backend.") @$(call print, "Building itest binary for ${backend} backend.")
CGO_ENABLED=0 $(GOTEST) -v ./lntest/itest -tags="$(DEV_TAGS) $(RPC_TAGS) rpctest $(backend)" -c -o lntest/itest/itest.test$(EXEC_SUFFIX) CGO_ENABLED=0 $(GOTEST) -v ./itest -tags="$(DEV_TAGS) $(RPC_TAGS) rpctest $(backend)" -c -o itest/itest.test$(EXEC_SUFFIX)
install: install:
@$(call print, "Installing lnd and lncli.") @$(call print, "Installing lnd and lncli.")
@ -164,7 +164,7 @@ endif
itest-only: db-instance itest-only: db-instance
@$(call print, "Running integration tests with ${backend} backend.") @$(call print, "Running integration tests with ${backend} backend.")
rm -rf lntest/itest/*.log lntest/itest/.logs-*; date rm -rf itest/*.log itest/.logs-*; date
EXEC_SUFFIX=$(EXEC_SUFFIX) scripts/itest_part.sh 0 1 $(TEST_FLAGS) $(ITEST_FLAGS) EXEC_SUFFIX=$(EXEC_SUFFIX) scripts/itest_part.sh 0 1 $(TEST_FLAGS) $(ITEST_FLAGS)
itest: build-itest itest-only itest: build-itest itest-only
@ -173,7 +173,7 @@ itest-race: build-itest-race itest-only
itest-parallel: build-itest db-instance itest-parallel: build-itest db-instance
@$(call print, "Running tests") @$(call print, "Running tests")
rm -rf lntest/itest/*.log lntest/itest/.logs-*; date rm -rf itest/*.log itest/.logs-*; date
EXEC_SUFFIX=$(EXEC_SUFFIX) echo "$$(seq 0 $$(expr $(ITEST_PARALLELISM) - 1))" | xargs -P $(ITEST_PARALLELISM) -n 1 -I {} scripts/itest_part.sh {} $(NUM_ITEST_TRANCHES) $(TEST_FLAGS) $(ITEST_FLAGS) EXEC_SUFFIX=$(EXEC_SUFFIX) echo "$$(seq 0 $$(expr $(ITEST_PARALLELISM) - 1))" | xargs -P $(ITEST_PARALLELISM) -n 1 -I {} scripts/itest_part.sh {} $(NUM_ITEST_TRANCHES) $(TEST_FLAGS) $(ITEST_FLAGS)
itest-clean: itest-clean:

View file

@ -155,7 +155,7 @@ A quick summary of test practices follows:
or RPC's will need to be accompanied by integration tests which use the or RPC's will need to be accompanied by integration tests which use the
[`networkHarness`framework](https://github.com/lightningnetwork/lnd/blob/master/lntest/harness.go) [`networkHarness`framework](https://github.com/lightningnetwork/lnd/blob/master/lntest/harness.go)
contained within `lnd`. For example integration tests, see contained within `lnd`. For example integration tests, see
[`lnd_test.go`](https://github.com/lightningnetwork/lnd/blob/master/lntest/itest/lnd_test.go). [`lnd_test.go`](https://github.com/lightningnetwork/lnd/blob/master/itest/lnd_test.go).
- The itest log files are automatically scanned for `[ERR]` lines. There - The itest log files are automatically scanned for `[ERR]` lines. There
shouldn't be any of those in the logs, see [Use of Log Levels](#use-of-log-levels). shouldn't be any of those in the logs, see [Use of Log Levels](#use-of-log-levels).

View file

@ -44,7 +44,7 @@ to test the RPCs and to showcase the different use cases.
### 3-of-3 Taproot key spend path (BIP-0086) ### 3-of-3 Taproot key spend path (BIP-0086)
See `testTaprootMuSig2KeySpendBip86` in See `testTaprootMuSig2KeySpendBip86` in
[`lntest/itest/lnd_taproot_test.go`](../lntest/itest/lnd_taproot_test.go) to see [`itest/lnd_taproot_test.go`](../itest/lnd_taproot_test.go) to see
the full code. the full code.
This example uses combines the public keys of 3 participants into a shared This example uses combines the public keys of 3 participants into a shared
@ -73,7 +73,7 @@ the `MuSig2CreateSession` RPC call:
### 3-of-3 Taproot key spend path with root hash commitment ### 3-of-3 Taproot key spend path with root hash commitment
See `testTaprootMuSig2KeySpendRootHash` in See `testTaprootMuSig2KeySpendRootHash` in
[`lntest/itest/lnd_taproot_test.go`](../lntest/itest/lnd_taproot_test.go) to see [`itest/lnd_taproot_test.go`](../itest/lnd_taproot_test.go) to see
the full code. the full code.
This is very similar to the above example but with the main difference that the This is very similar to the above example but with the main difference that the
@ -101,7 +101,7 @@ the `MuSig2CreateSession` RPC call:
### 3-of-3 `OP_CHECKSIG` in Taproot script spend path ### 3-of-3 `OP_CHECKSIG` in Taproot script spend path
See `testTaprootMuSig2CombinedLeafKeySpend` in See `testTaprootMuSig2CombinedLeafKeySpend` in
[`lntest/itest/lnd_taproot_test.go`](../lntest/itest/lnd_taproot_test.go) to see [`itest/lnd_taproot_test.go`](../itest/lnd_taproot_test.go) to see
the full code. the full code.
This example is definitely the most involved one. To be able to use a MuSig2 This example is definitely the most involved one. To be able to use a MuSig2

View file

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Let's work with absolute paths only, we run in the itest directory itself. # Let's work with absolute paths only, we run in the itest directory itself.
WORKDIR=$(pwd)/lntest/itest WORKDIR=$(pwd)/itest
TRANCHE=$1 TRANCHE=$1
NUM_TRANCHES=$2 NUM_TRANCHES=$2