Skip to content

test: Add LiveHash unit tests - #1719

Merged
Dosik13 merged 3 commits into
hiero-ledger:mainfrom
Mounil2005:add-livehash-unit-tests
May 22, 2026
Merged

test: Add LiveHash unit tests#1719
Dosik13 merged 3 commits into
hiero-ledger:mainfrom
Mounil2005:add-livehash-unit-tests

Conversation

@Mounil2005

@Mounil2005 Mounil2005 commented May 17, 2026

Copy link
Copy Markdown
Contributor

Description:
Add comprehensive unit test coverage for LiveHash type

The LiveHash struct required additional test coverage for serialization, deserialization, and error handling paths. This PR adds five unit tests covering:

  • Bytes round-trip serialization and deserialization
  • Nil protobuf parameter handling with appropriate error returns
  • Nil byte array parameter handling with appropriate error returns
  • Protobuf conversion with nil KeyList handling
  • Deprecated Duration field exclusion from serialization (only LiveHashDuration is serialized)

Related issue(s):

Fixes #1713

Notes for reviewer:
All tests pass successfully:

  • TestUnitLiveHash_BytesRoundTrip (0.00s)
  • TestUnitLiveHash_FromProtobufNil (0.00s)
  • TestUnitLiveHash_FromBytesNil (0.00s)
  • TestUnitLiveHash_ProtobufRoundTripNilKeys (0.00s)
  • TestUnitLiveHash_DeprecatedDurationNotSerialised (0.00s)

The deprecated duration test confirms the invariant is properly wired in the codebase - the deprecated Duration field (time.Time) is not serialized, only LiveHashDuration (time.Duration) is used.

Checklist

  • Documented (Code uses clear test names and assertions)
  • Tested (All 5 unit tests pass; go build and go vet pass)

@lfdt-bot

lfdt-bot commented May 17, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@codecov

codecov Bot commented May 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
see 5 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Mounil2005
Mounil2005 marked this pull request as ready for review May 18, 2026 09:31
@Mounil2005
Mounil2005 requested review from a team as code owners May 18, 2026 09:31
Comment thread CHANGELOG.md Outdated

@Dosik13 Dosik13 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for the PR! Left some suggestions

Comment thread sdk/live_hash_unit_test.go
Comment thread sdk/live_hash_unit_test.go Outdated
Comment thread sdk/live_hash_unit_test.go Outdated
Comment thread sdk/live_hash_unit_test.go Outdated
@Mounil2005
Mounil2005 force-pushed the add-livehash-unit-tests branch from 31d8dfb to 3ee4f2d Compare May 21, 2026 21:42
Signed-off-by: Mounil Kanakhara <mounilkankhara@gmail.com>
Signed-off-by: Mounil Kanakhara <mounilkankhara@gmail.com>
Signed-off-by: Mounil Kanakhara <mounilkankhara@gmail.com>
@Mounil2005
Mounil2005 force-pushed the add-livehash-unit-tests branch from 3ee4f2d to 39455d8 Compare May 21, 2026 21:49
@Mounil2005

Mounil2005 commented May 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the suggestions @Dosik13! I've addressed all points:

  • Added // SPDX-License-Identifier: Apache-2.0 after package hiero to be consistent with the other files.
  • Added an Ed25519 key to the KeyList in TestUnitLiveHash_BytesRoundTrip and added an assertion to verify the key survives the round-trip.
  • Replaced assert.Equal(t, errXxx, err) with require.ErrorIs(t, err, errXxx) in both nil-input tests (TestUnitLiveHash_FromProtobufNil and TestUnitLiveHash_FromBytesNil)

@Dosik13 Dosik13 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm! Thank you for the great work!

@Dosik13
Dosik13 merged commit 1fcdb4c into hiero-ledger:main May 22, 2026
13 checks passed
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.

[Beginner]: Add unit tests for LiveHash

3 participants