Skip to content

Add unit tests for SDK v3 client and transaction packages#2

Merged
kyonRay merged 5 commits intorelease-3.9.0from
copilot/add-unit-tests-fisco-bcos-sdk
Nov 4, 2025
Merged

Add unit tests for SDK v3 client and transaction packages#2
kyonRay merged 5 commits intorelease-3.9.0from
copilot/add-unit-tests-fisco-bcos-sdk

Conversation

Copy link

Copilot AI commented Nov 4, 2025

Increases test coverage for org.fisco.bcos.sdk.v3.client and org.fisco.bcos.sdk.v3.transaction packages. The project uses JDK 8 and Jacoco for coverage measurement.

Changes

Client Package (10 test classes)

  • Protocol request/response: DefaultBlockParameter*, LogFilterRequest, BlockNumber, BlockHash, PendingTxSize
  • Protocol model: GroupStatus, TransactionAttribute
  • Exceptions: ClientException

Transaction Package (15 test classes)

  • Model exceptions: TransactionException, JsonException, ContractException
  • Model DTOs: CommonResponse, CallResponse, CallRequest, ResultCodeEnum
  • Model objects: CommonConstant, AbiInfo, BinInfo
  • Gas providers: EIP1559Struct, DefaultGasProvider, StaticGasProvider
  • Utilities: Convert (Wei/Ether conversion), JsonUtils

Coverage Focus

Tests cover constructors, accessors, equals/hashCode, edge cases (null, empty, boundary values), and business logic:

// Example: Convert utility test
@Test
public void testConversionRoundTrip() {
    String originalEther = "2.5";
    BigDecimal wei = Convert.toWei(originalEther, Convert.Unit.ETHER);
    BigDecimal backToEther = Convert.fromWei(wei, Convert.Unit.ETHER);
    Assert.assertEquals(new BigDecimal("2.5"), backToEther);
}

All tests use existing infrastructure (JUnit 4, Mockito 4.8.0) and maintain JDK 8 compatibility.

Original prompt

当前项目是兼容jdk8,是用jacoco作为测试覆盖组件。请在本项目上继续添加更多的UT来增加覆盖率,特别增加org.fisco.bcos.sdk.v3.client和org.fisco.bcos.sdk.v3.transaction两个package的测试覆盖率,允许添加mock相关的测试组件。

CHAT SUMMARY

TITLE: Add Unit Tests to Increase Code Coverage for FISCO BCOS SDK v3

USER INTENT: The user wants to add more unit tests (UT) to increase test coverage for a JDK8-compatible project that uses Jacoco as the test coverage component, with specific focus on improving coverage for the org.fisco.bcos.sdk.v3.client and org.fisco.bcos.sdk.v3.transaction packages. The user is open to adding mock-related testing components.

TASK DESCRIPTION:

  • Add comprehensive unit tests to increase overall test coverage in a FISCO BCOS SDK v3 project
  • Focus specifically on two main packages:
    • org.fisco.bcos.sdk.v3.client
    • org.fisco.bcos.sdk.v3.transaction
  • Ensure compatibility with JDK 8
  • Use Jacoco for test coverage measurement
  • Implement mocking frameworks as needed (likely Mockito for JDK8 compatibility)

EXISTING:

  • Project is already configured with Jacoco for test coverage
  • Project is JDK8 compatible
  • The two target packages (org.fisco.bcos.sdk.v3.client and org.fisco.bcos.sdk.v3.transaction) exist and need coverage improvements

PENDING:

  • Analyze current test coverage for the target packages
  • Identify untested or under-tested classes and methods in:
    • org.fisco.bcos.sdk.v3.client
    • org.fisco.bcos.sdk.v3.transaction
  • Design and implement unit tests with appropriate mocking strategies
  • Add mock framework dependencies if not already present (e.g., Mockito, PowerMock for JDK8)
  • Achieve higher coverage metrics through comprehensive test cases
  • Handle edge cases, error conditions, and various code paths

CODE STATE:
No specific files were discussed or modified in this initial request.

RELEVANT CODE/DOCUMENTATION SNIPPETS:
None provided in the conversation.

OTHER NOTES:

  • The project appears to be related to FISCO BCOS blockchain SDK (Software Development Kit) version 3
  • JDK 8 compatibility constraint is important and will affect choice of testing frameworks and approaches
  • Mockito is typically the preferred mocking framework for JDK8 projects
  • The user has explicitly authorized the addition of mocking components, indicating complex dependencies may exist in the target packages that require mocking for effective unit testing
  • Both target packages (client and transaction) suggest core SDK functionality that likely involves blockchain client operations and transaction handling

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits November 4, 2025 07:58
Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>
…classes

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>
Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>
Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>
Copilot AI changed the title [WIP] Add unit tests to increase coverage for FISCO BCOS SDK v3 Add unit tests for SDK v3 client and transaction packages Nov 4, 2025
Copilot AI requested a review from kyonRay November 4, 2025 08:12
@kyonRay kyonRay marked this pull request as ready for review November 4, 2025 08:13
@kyonRay kyonRay merged commit 00392dc into release-3.9.0 Nov 4, 2025
kyonRay added a commit that referenced this pull request Nov 13, 2025
…S#945)

* <fix>(build): update dependencies version, add UT with AI.

* Add unit tests to increase JaCoCo coverage from 30.1% to 30.7% (#1)

* Initial plan

* Initial setup: Upgrade Gradle to 7.6.4 for Java 17 compatibility and fix duplicate resources handling

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* Add unit tests for model classes and exceptions to improve coverage

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* Add more unit tests for model and enum classes to increase coverage

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* Add unit tests for crypto exception classes to increase coverage

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* Downgrade Gradle version to 6.3

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* Add unit tests for SDK v3 client and transaction packages (#2)

* Initial plan

* Add unit tests for client and transaction packages - part 1

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* Add more unit tests for client protocol response and transaction dto classes

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* Add unit tests for LogFilterRequest, model BO classes and CommonConstant

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* Fix ResultCodeEnumTest to avoid mutating enum state in tests

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* <fix>(test): fixed tests path.

* Add comprehensive test coverage for uncovered utility, protocol, and codec classes (#4)

* Initial plan

* Add comprehensive tests for ByteUtils, ThreadPoolService, SystemInformation, SecureRandomUtils, and LinuxSecureRandom

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* Add comprehensive tests for JsonRpcRequest and TopicTools

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* Address code review feedback - fix resource cleanup and remove redundant tests

Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: kyonRay <32325790+kyonRay@users.noreply.github.com>

* <fix>(CI): fix windows ci version to 2025.

* <fix>(build): update publish url to central.sonatype.

---------

Co-authored-by: Copilot <198982749+Copilot@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.

2 participants