use of com.swirlds.common.crypto.RunningHash in project hedera-services by hashgraph.
the class RecordsRunningHashLeafTest method updateRunningHashInvalidateHashTest.
@Test
void updateRunningHashInvalidateHashTest() {
final var runningHash = new RunningHash();
// sets Hash for the RunningHash
runningHash.setHash(new Hash(RandomUtils.nextBytes(DigestType.SHA_384.digestLength())));
// initializes a leaf with a RunningHash
final var leafForTestingRunningHash = new RecordsRunningHashLeaf(runningHash);
// digest this leaf
CryptoFactory.getInstance().digestSync(leafForTestingRunningHash, DigestType.SHA_384);
assertNotNull(leafForTestingRunningHash.getHash());
// update runningHash object
final var newRunningHash = new RunningHash();
newRunningHash.setHash(new Hash(RandomUtils.nextBytes(DigestType.SHA_384.digestLength())));
leafForTestingRunningHash.setRunningHash(newRunningHash);
// the Leaf's Hash should be set to be null after updating the runningHash object
assertNull(leafForTestingRunningHash.getHash());
}
use of com.swirlds.common.crypto.RunningHash in project hedera-services by hashgraph.
the class RecordsRunningHashLeaf method deserialize.
@Override
public void deserialize(final SerializableDataInputStream in, final int version) throws IOException {
runningHash = new RunningHash();
runningHash.setHash(in.readSerializable());
}
Aggregations