Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Benchmark Test (BenchmarkReadMessage/Funding_Locked) in the lnwire package #7356

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
# =============
Expand Down
4 changes: 4 additions & 0 deletions docs/release-notes/release-notes-0.17.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -49,3 +52,4 @@ unlock or create.
* Erik Arvstedt
* hieblmi
* Jordi Montes
* ziggie1984
16 changes: 14 additions & 2 deletions lnwire/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 4 additions & 0 deletions make/testing_flags.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down