From 8f4e9d68d0852b99b57fceb96d499156fad8c418 Mon Sep 17 00:00:00 2001 From: ziggie Date: Tue, 24 Jan 2023 21:41:11 +0100 Subject: [PATCH 1/3] lnwire_test: fix BenchmarkReadMessage test The addition of AliasScid in the tlv_stream field of the funding_locked msg made the requirement for testdata of the ExtraOpaqueData part for the funding_locked msg type more strict. Now the input testdata for the funding_locked test is more specific and includes the new added AliasScid tlv record. --- lnwire/message_test.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lnwire/message_test.go b/lnwire/message_test.go index f39a88995..1df0b5c55 100644 --- a/lnwire/message_test.go +++ b/lnwire/message_test.go @@ -452,8 +452,20 @@ func newMsgChannelReady(t testing.TB, r io.Reader) *lnwire.ChannelReady { pubKey := randPubKey(t) - msg := lnwire.NewChannelReady(lnwire.ChannelID(c), pubKey) - msg.ExtraData = createExtraData(t, r) + // When testing the ChannelReady msg type in the WriteMessage + // function we need to populate the alias here to test the encoding + // of the TLV stream. + aliasScid := lnwire.NewShortChanIDFromInt(rand.Uint64()) + msg := &lnwire.ChannelReady{ + ChanID: lnwire.ChannelID(c), + NextPerCommitmentPoint: pubKey, + AliasScid: &aliasScid, + ExtraData: make([]byte, 0), + } + + // We do not include the TLV record (aliasScid) into the ExtraData + // because when the msg is encoded the ExtraData is overwritten + // with the current aliasScid value. return msg } From 469dfd5f42042cd70040027df9adf78df6f096db Mon Sep 17 00:00:00 2001 From: ziggie Date: Thu, 26 Jan 2023 20:03:03 +0100 Subject: [PATCH 2/3] make: add benchmark tests Add benchmark tests as a separate test run besides the current unit tests. --- Makefile | 4 ++++ make/testing_flags.mk | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Makefile b/Makefile index 8c08fd614..f5bf7289a 100644 --- a/Makefile +++ b/Makefile @@ -196,6 +196,10 @@ unit-race: @$(call print, "Running unit race tests.") env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(UNIT_RACE) +unit-bench: $(BTCD_BIN) + @$(call print, "Running benchmark tests.") + $(UNIT_BENCH) + # ============= # FLAKE HUNTING # ============= diff --git a/make/testing_flags.mk b/make/testing_flags.mk index b4109bb5c..218b37b62 100644 --- a/make/testing_flags.mk +++ b/make/testing_flags.mk @@ -100,12 +100,16 @@ ifeq ($(UNIT_TARGETED), yes) UNIT := $(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS) $(UNITPKG) UNIT_DEBUG := $(GOTEST) -v -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS) $(UNITPKG) UNIT_RACE := $(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS) lowscrypt" $(TEST_FLAGS) -race $(UNITPKG) +# NONE is a special value which selects no other tests but only executes the benchmark tests here. +UNIT_BENCH := $(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS)" -test.bench=. -test.run=NONE $(UNITPKG) endif ifeq ($(UNIT_TARGETED), no) UNIT := $(GOLIST) | $(XARGS) env $(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS) UNIT_DEBUG := $(GOLIST) | $(XARGS) env $(GOTEST) -v -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS) UNIT_RACE := $(UNIT) -race +# NONE is a special value which selects no other tests but only executes the benchmark tests here. +UNIT_BENCH := $(GOLIST) | $(XARGS) env $(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS)" -test.bench=. -test.run=NONE endif From 0c31eb72e7926a69dafddd5c49a004cc41af5920 Mon Sep 17 00:00:00 2001 From: ziggie Date: Tue, 9 May 2023 16:53:30 +0200 Subject: [PATCH 3/3] docs: add release notes for 0.17.0 --- docs/release-notes/release-notes-0.17.0.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/release-notes/release-notes-0.17.0.md b/docs/release-notes/release-notes-0.17.0.md index 7ae6f4200..fead4d626 100644 --- a/docs/release-notes/release-notes-0.17.0.md +++ b/docs/release-notes/release-notes-0.17.0.md @@ -17,6 +17,9 @@ * [Ensure that both the byte and string form of a TXID is populated in the lnrpc.Outpoint message](https://github.com/lightningnetwork/lnd/pull/7624). + +* [Fix Benchmark Test (BenchmarkReadMessage/Channel_Ready) in the lnwire +package](https://github.com/lightningnetwork/lnd/pull/7356) ## RPC @@ -49,3 +52,4 @@ unlock or create. * Erik Arvstedt * hieblmi * Jordi Montes +* ziggie1984