Search in sources :

Example 1 with EntityNumPair

use of com.hedera.services.utils.EntityNumPair in project hedera-services by hashgraph.

the class MerkleTokenRelStatusTest method deserializeWorksForPre0180.

@Test
void deserializeWorksForPre0180() throws IOException {
    final var in = mock(SerializableDataInputStream.class);
    final var defaultSubject = new MerkleTokenRelStatus();
    given(in.readLong()).willReturn(balance);
    given(in.readBoolean()).willReturn(frozen).willReturn(kycGranted).willReturn(automaticAssociation);
    defaultSubject.deserialize(in, MerkleTokenRelStatus.RELEASE_090_VERSION);
    assertNotEquals(subject, defaultSubject);
    // and when:
    defaultSubject.setKey(new EntityNumPair(numbers));
    // then:
    assertEquals(subject, defaultSubject);
}
Also used : EntityNumPair(com.hedera.services.utils.EntityNumPair) Test(org.junit.jupiter.api.Test)

Example 2 with EntityNumPair

use of com.hedera.services.utils.EntityNumPair in project hedera-services by hashgraph.

the class MerkleTokenRelStatusTest method deserializeWorksFor0180PreSdk.

@Test
void deserializeWorksFor0180PreSdk() throws IOException {
    final var in = mock(SerializableDataInputStream.class);
    final var defaultSubject = new MerkleTokenRelStatus();
    given(in.readLong()).willReturn(balance);
    given(in.readBoolean()).willReturn(frozen).willReturn(kycGranted).willReturn(automaticAssociation);
    defaultSubject.deserialize(in, MerkleTokenRelStatus.RELEASE_0180_PRE_SDK_VERSION);
    // then:
    assertNotEquals(subject, defaultSubject);
    // and when:
    defaultSubject.setKey(new EntityNumPair(numbers));
    // then:
    assertEquals(subject, defaultSubject);
}
Also used : EntityNumPair(com.hedera.services.utils.EntityNumPair) Test(org.junit.jupiter.api.Test)

Example 3 with EntityNumPair

use of com.hedera.services.utils.EntityNumPair in project hedera-services by hashgraph.

the class MerkleUniqueTokenTest method setup.

@BeforeEach
void setup() {
    owner = new EntityId(0, 0, 3);
    otherOwner = new EntityId(0, 0, 4);
    metadata = "Test NFT".getBytes();
    otherMetadata = "Test NFT2".getBytes();
    timestamp = RichInstant.fromJava(Instant.ofEpochSecond(timestampL));
    otherTimestamp = RichInstant.fromJava(Instant.ofEpochSecond(1_234_568L));
    subject = new MerkleUniqueToken(owner, metadata, timestamp);
    subject.setKey(new EntityNumPair(numbers));
}
Also used : EntityId(com.hedera.services.state.submerkle.EntityId) EntityNumPair(com.hedera.services.utils.EntityNumPair) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with EntityNumPair

use of com.hedera.services.utils.EntityNumPair in project hedera-services by hashgraph.

the class MerkleUniqueTokenTest method hashCodeWorks.

@Test
void hashCodeWorks() {
    // given:
    var identical = new MerkleUniqueToken(owner, metadata, timestamp);
    identical.setKey(new EntityNumPair(numbers));
    var other = new MerkleUniqueToken(otherOwner, otherMetadata, otherTimestamp);
    // expect:
    assertNotEquals(subject.hashCode(), other.hashCode());
    assertEquals(subject.hashCode(), identical.hashCode());
}
Also used : EntityNumPair(com.hedera.services.utils.EntityNumPair) Test(org.junit.jupiter.api.Test)

Example 5 with EntityNumPair

use of com.hedera.services.utils.EntityNumPair in project hedera-services by hashgraph.

the class MerkleUniqueTokenTest method deserializeWorksPre0180.

@Test
void deserializeWorksPre0180() throws IOException {
    // setup:
    SerializableDataInputStream in = mock(SerializableDataInputStream.class);
    // and:
    final var packedTime = packedTime(timestamp.getSeconds(), timestamp.getNanos());
    given(in.readByteArray(anyInt())).willReturn(metadata);
    given(in.readLong()).willReturn(packedTime);
    given(in.readInt()).willReturn(owner.identityCode());
    // and:
    var read = new MerkleUniqueToken();
    // when:
    read.deserialize(in, MerkleUniqueToken.PRE_RELEASE_0180_VERSION);
    // then:
    assertNotEquals(subject, read);
    // and when:
    read.setKey(new EntityNumPair(numbers));
    // then:
    assertEquals(subject, read);
}
Also used : EntityNumPair(com.hedera.services.utils.EntityNumPair) SerializableDataInputStream(com.swirlds.common.io.SerializableDataInputStream) Test(org.junit.jupiter.api.Test)

Aggregations

EntityNumPair (com.hedera.services.utils.EntityNumPair)6 Test (org.junit.jupiter.api.Test)5 EntityId (com.hedera.services.state.submerkle.EntityId)1 SerializableDataInputStream (com.swirlds.common.io.SerializableDataInputStream)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1