Skip to content

Commit ae30581

Browse files
authored
Merge pull request #7356 from ziggie1984/benchmarking-fundinglocked
Fix Benchmark Test (BenchmarkReadMessage/Funding_Locked) in the lnwire package
2 parents 8df4ede + 0c31eb7 commit ae30581

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ unit-race:
196196
@$(call print, "Running unit race tests.")
197197
env CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1" $(UNIT_RACE)
198198

199+
unit-bench: $(BTCD_BIN)
200+
@$(call print, "Running benchmark tests.")
201+
$(UNIT_BENCH)
202+
199203
# =============
200204
# FLAKE HUNTING
201205
# =============

docs/release-notes/release-notes-0.17.0.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717

1818
* [Ensure that both the byte and string form of a TXID is populated in the
1919
lnrpc.Outpoint message](https://github.com/lightningnetwork/lnd/pull/7624).
20+
21+
* [Fix Benchmark Test (BenchmarkReadMessage/Channel_Ready) in the lnwire
22+
package](https://github.com/lightningnetwork/lnd/pull/7356)
2023

2124
## RPC
2225

@@ -49,3 +52,4 @@ unlock or create.
4952
* Erik Arvstedt
5053
* hieblmi
5154
* Jordi Montes
55+
* ziggie1984

lnwire/message_test.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,20 @@ func newMsgChannelReady(t testing.TB, r io.Reader) *lnwire.ChannelReady {
452452

453453
pubKey := randPubKey(t)
454454

455-
msg := lnwire.NewChannelReady(lnwire.ChannelID(c), pubKey)
456-
msg.ExtraData = createExtraData(t, r)
455+
// When testing the ChannelReady msg type in the WriteMessage
456+
// function we need to populate the alias here to test the encoding
457+
// of the TLV stream.
458+
aliasScid := lnwire.NewShortChanIDFromInt(rand.Uint64())
459+
msg := &lnwire.ChannelReady{
460+
ChanID: lnwire.ChannelID(c),
461+
NextPerCommitmentPoint: pubKey,
462+
AliasScid: &aliasScid,
463+
ExtraData: make([]byte, 0),
464+
}
465+
466+
// We do not include the TLV record (aliasScid) into the ExtraData
467+
// because when the msg is encoded the ExtraData is overwritten
468+
// with the current aliasScid value.
457469

458470
return msg
459471
}

make/testing_flags.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,16 @@ ifeq ($(UNIT_TARGETED), yes)
100100
UNIT := $(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS) $(UNITPKG)
101101
UNIT_DEBUG := $(GOTEST) -v -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS) $(UNITPKG)
102102
UNIT_RACE := $(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS) lowscrypt" $(TEST_FLAGS) -race $(UNITPKG)
103+
# NONE is a special value which selects no other tests but only executes the benchmark tests here.
104+
UNIT_BENCH := $(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS)" -test.bench=. -test.run=NONE $(UNITPKG)
103105
endif
104106

105107
ifeq ($(UNIT_TARGETED), no)
106108
UNIT := $(GOLIST) | $(XARGS) env $(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS)
107109
UNIT_DEBUG := $(GOLIST) | $(XARGS) env $(GOTEST) -v -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS)
108110
UNIT_RACE := $(UNIT) -race
111+
# NONE is a special value which selects no other tests but only executes the benchmark tests here.
112+
UNIT_BENCH := $(GOLIST) | $(XARGS) env $(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS)" -test.bench=. -test.run=NONE
109113
endif
110114

111115

0 commit comments

Comments
 (0)