use of com.hedera.mirror.common.domain.entity.EntityId in project hedera-mirror-node by hashgraph.
the class EntityIdServiceImplTest method lookupAccountsReturnsFirst.
@Test
void lookupAccountsReturnsFirst() {
AccountID accountId1 = AccountID.newBuilder().setAccountNum(100).build();
AccountID accountId2 = AccountID.newBuilder().setAccountNum(101).build();
EntityId entityId = entityIdService.lookup(accountId1, accountId2);
assertThat(entityId).isEqualTo(EntityId.of(accountId1));
}
use of com.hedera.mirror.common.domain.entity.EntityId in project hedera-mirror-node by hashgraph.
the class EntityIdServiceImplTest method lookupAccounts.
@Test
void lookupAccounts() {
AccountID nullAccountId = null;
AccountID accountId = AccountID.newBuilder().setAccountNum(100).build();
AccountID accountIdInvalid = AccountID.newBuilder().setRealmNum(1).build();
Entity accountDeleted = domainBuilder.entity().customize(e -> e.deleted(true)).persist();
EntityId entityId = entityIdService.lookup(nullAccountId, AccountID.getDefaultInstance(), getProtoAccountId(accountDeleted), accountIdInvalid, accountId);
assertThat(entityId).isEqualTo(EntityId.of(accountId));
}
use of com.hedera.mirror.common.domain.entity.EntityId in project hedera-mirror-node by hashgraph.
the class NodeSignatureVerifierTest method testVerifiedWithFullConsensusRequired.
@Test
void testVerifiedWithFullConsensusRequired() throws GeneralSecurityException {
Map<String, PublicKey> nodeAccountIDPubKeyMap = new HashMap();
nodeAccountIDPubKeyMap.put("0.0.3", publicKey);
nodeAccountIDPubKeyMap.put("0.0.4", publicKey);
nodeAccountIDPubKeyMap.put("0.0.5", publicKey);
when(currentAddressBook.getNodeAccountIDPubKeyMap()).thenReturn(nodeAccountIDPubKeyMap);
when(commonDownloaderProperties.getConsensusRatio()).thenReturn(1f);
byte[] fileHash = TestUtils.generateRandomByteArray(48);
byte[] fileHashSignature = signHash(fileHash);
FileStreamSignature fileStreamSignatureNode3 = buildFileStreamSignature(fileHash, fileHashSignature, null, null);
fileStreamSignatureNode3.setNodeAccountId(new EntityId(0L, 0L, 3L, EntityType.ACCOUNT));
FileStreamSignature fileStreamSignatureNode4 = buildFileStreamSignature(fileHash, fileHashSignature, null, null);
fileStreamSignatureNode4.setNodeAccountId(new EntityId(0L, 0L, 4L, EntityType.ACCOUNT));
FileStreamSignature fileStreamSignatureNode5 = buildFileStreamSignature(fileHash, fileHashSignature, null, null);
fileStreamSignatureNode5.setNodeAccountId(new EntityId(0L, 0L, 5L, EntityType.ACCOUNT));
nodeSignatureVerifier.verify(Arrays.asList(fileStreamSignatureNode3, fileStreamSignatureNode4, fileStreamSignatureNode5));
}
use of com.hedera.mirror.common.domain.entity.EntityId in project hedera-mirror-node by hashgraph.
the class NodeSignatureVerifierTest method testVerifiedWithOneThirdConsensusWithMissingSignatures.
@Test
void testVerifiedWithOneThirdConsensusWithMissingSignatures() throws GeneralSecurityException {
Map<String, PublicKey> nodeAccountIDPubKeyMap = new HashMap();
nodeAccountIDPubKeyMap.put("0.0.3", publicKey);
nodeAccountIDPubKeyMap.put("0.0.4", publicKey);
nodeAccountIDPubKeyMap.put("0.0.5", publicKey);
when(currentAddressBook.getNodeAccountIDPubKeyMap()).thenReturn(nodeAccountIDPubKeyMap);
byte[] fileHash = TestUtils.generateRandomByteArray(48);
byte[] fileHashSignature = signHash(fileHash);
FileStreamSignature fileStreamSignatureNode3 = buildFileStreamSignature(fileHash, fileHashSignature, null, null);
// Node 4 and 5 will not verify due to missing signature, but 1/3 verified will confirm consensus reached
FileStreamSignature fileStreamSignatureNode4 = buildFileStreamSignature(fileHash, null, null, null);
fileStreamSignatureNode4.setNodeAccountId(new EntityId(0L, 0L, 4L, EntityType.ACCOUNT));
FileStreamSignature fileStreamSignatureNode5 = buildFileStreamSignature(fileHash, null, null, null);
fileStreamSignatureNode5.setNodeAccountId(new EntityId(0L, 0L, 5L, EntityType.ACCOUNT));
nodeSignatureVerifier.verify(Arrays.asList(fileStreamSignatureNode3, fileStreamSignatureNode4, fileStreamSignatureNode5));
}
use of com.hedera.mirror.common.domain.entity.EntityId in project hedera-mirror-node by hashgraph.
the class AddressBookServiceImplTest method isAddressBook.
@Test
void isAddressBook() {
EntityId fileID = EntityId.of(0, 0, 234, EntityType.FILE);
boolean isAddressBook = addressBookService.isAddressBook(fileID);
assertThat(isAddressBook).isFalse();
fileID = EntityId.of(0, 0, 101, EntityType.FILE);
isAddressBook = addressBookService.isAddressBook(fileID);
assertThat(isAddressBook).isTrue();
fileID = EntityId.of(0, 0, 102, EntityType.FILE);
isAddressBook = addressBookService.isAddressBook(fileID);
assertThat(isAddressBook).isTrue();
}
Aggregations