Skip to content

test(tlv): add unit tests and refactor tlv.go#284

Open
watal wants to merge 36 commits intodevelopfrom
test/pkg-packet
Open

test(tlv): add unit tests and refactor tlv.go#284
watal wants to merge 36 commits intodevelopfrom
test/pkg-packet

Conversation

@watal
Copy link
Member

@watal watal commented Feb 18, 2026

Description

  • Fixed SRPolicyCandidatePathIdentifier to comply with RFC 9862/9256 (correct Originator IPv4 handling)
  • Added missing TLV fields and MarshalLogObject implementations
  • Improved padding and slice handling
  • Enhanced JSON marshaling of (ts Psts) MarshalJSON()
  • Replaced magic numbers with constants
  • Consolidated common TLV decoding into decodeTLVLength
  • Added error checks

Type of change

  • New features (added TLV tests)
  • Refactoring (improved TLV Serialize/Decode, helper functions)

Motivation and Context

To increase test coverage and improve readability and maintainability of TLV handling code.

How is This Tested?

  • Verified TLV Serialize/Decode/MarshalLogObject using go test ./...
  • Scenario tests in the test/ directory

Other Information

No additional information.

@watal watal changed the base branch from main to develop February 18, 2026 11:41
@watal watal requested a review from Copilot February 18, 2026 11:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR expands and refactors PCEP TLV handling by introducing shared TLV parsing helpers, updating multiple TLV Encode/Decode implementations to use them, and adding extensive table-driven unit tests across TLV types.

Changes:

  • Added decodeTLVLength, paddedLength, and isIPv4Bytes helpers and corresponding unit tests.
  • Refactored multiple TLV DecodeFromBytes / Serialize / Len / MarshalLogObject implementations to use shared offsets/constants and stricter length validation.
  • Greatly expanded TLV unit tests (decode/serialize/len/logging + DecodeTLV/DecodeTLVs cases) and added a capability test case for skipping LSPDBVersion.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pkg/packet/pcep/tlv.go Refactors TLV parsing/serialization, adds offsets/alignment constants, updates TLV map, and modifies DecodeTLVs logic.
pkg/packet/pcep/tlv_common.go Introduces shared TLV helper utilities (length validation, padding, IPv4-bytes detection).
pkg/packet/pcep/tlv_common_test.go Adds unit tests for the new TLV helper utilities.
pkg/packet/pcep/tlv_test.go Reworks TLV tests into table-driven helpers and adds broad coverage across TLV types and TLV decoding.
pkg/packet/pcep/capability_test.go Adds a test case asserting LSPDBVersion is skipped by PolaCapability.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@watal watal force-pushed the test/pkg-packet branch 2 times, most recently from c25c1ed to 2b4b27f Compare February 18, 2026 12:08
@watal watal requested a review from Copilot February 18, 2026 12:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@watal watal force-pushed the test/pkg-packet branch 5 times, most recently from 51c7ae2 to 05215d4 Compare February 19, 2026 00:17
@watal watal requested a review from Copilot February 19, 2026 00:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@watal watal force-pushed the test/pkg-packet branch 4 times, most recently from 7580e62 to 382e292 Compare February 19, 2026 02:25
@watal watal requested a review from Copilot February 19, 2026 02:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

watal and others added 18 commits February 19, 2026 16:12
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…atorAddr

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@tatfujiwara tatfujiwara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comment

watal and others added 2 commits March 11, 2026 17:27
Co-authored-by: tatfujiwara <162294605+tatfujiwara@users.noreply.github.com>
Co-authored-by: tatfujiwara <162294605+tatfujiwara@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants