Skip to content

TransactionId.equals()/hashCode() violate the contract #2549

@OlegMazurov

Description

@OlegMazurov

Description

Two TransactionId instances with different hash codes must not be equal.
Violation of the contract breaks HashMap with TransactionId as key.

Steps to reproduce

This test fails:

    @Test
    void testTransactionIdEquals() {
        AccountId accountId = new AccountId(0, 0, 1000);
        Instant now = Instant.now();
        TransactionId txnId1 = TransactionId.withValidStart(accountId, now);
        TransactionId txnId2 = TransactionId.withValidStart(accountId, now);
        txnId2.setNonce(0);
        assertFalse(txnId1.equals(txnId2) && txnId1.hashCode() != txnId2.hashCode());
    }

Additional context

No response

Hedera network

No response

Version

2.65.0

Operating system

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions