Search in sources :

Example 6 with HashLockRepository

use of io.nem.symbol.sdk.api.HashLockRepository in project nem2-sdk-java by nemtech.

the class StateProofServiceTest method hashLock.

@Test
void hashLock() throws Exception {
    HashLockRepository repository = mock(HashLockRepository.class);
    when(factory.createHashLockRepository()).thenReturn(repository);
    String id = "hash";
    HashLockInfo state = Mockito.mock(HashLockInfo.class);
    when(state.getHash()).thenReturn(id);
    when(state.serialize()).thenReturn(ConvertUtils.fromHexToBytes(serialized));
    when(repository.getHashLock(eq(id))).thenReturn(Observable.just(state));
    when(repository.getHashLockMerkle(eq(id))).thenReturn(Observable.just(tree));
    StateMerkleProof<HashLockInfo> proof = service.hashLock(id).toFuture().get();
    Assertions.assertTrue(proof.isValid());
    Assertions.assertEquals(state, proof.getState());
}
Also used : HashLockRepository(io.nem.symbol.sdk.api.HashLockRepository) HashLockInfo(io.nem.symbol.sdk.model.transaction.HashLockInfo) Test(org.junit.jupiter.api.Test)

Aggregations

HashLockRepository (io.nem.symbol.sdk.api.HashLockRepository)6 HashLockSearchCriteria (io.nem.symbol.sdk.api.HashLockSearchCriteria)3 RepositoryCallException (io.nem.symbol.sdk.api.RepositoryCallException)3 HashLockInfo (io.nem.symbol.sdk.model.transaction.HashLockInfo)3 RepositoryFactory (io.nem.symbol.sdk.api.RepositoryFactory)2 Address (io.nem.symbol.sdk.model.account.Address)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 EnumSource (org.junit.jupiter.params.provider.EnumSource)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ExceptionUtils (io.nem.symbol.core.utils.ExceptionUtils)1 AccountRepository (io.nem.symbol.sdk.api.AccountRepository)1 Listener (io.nem.symbol.sdk.api.Listener)1 MultisigRepository (io.nem.symbol.sdk.api.MultisigRepository)1 Page (io.nem.symbol.sdk.api.Page)1 TransactionRepository (io.nem.symbol.sdk.api.TransactionRepository)1 TransactionService (io.nem.symbol.sdk.api.TransactionService)1 RepositoryFactoryOkHttpImpl (io.nem.symbol.sdk.infrastructure.okhttp.RepositoryFactoryOkHttpImpl)1 JsonHelperJackson2 (io.nem.symbol.sdk.infrastructure.vertx.JsonHelperJackson2)1 RepositoryFactoryVertxImpl (io.nem.symbol.sdk.infrastructure.vertx.RepositoryFactoryVertxImpl)1 Stored (io.nem.symbol.sdk.model.Stored)1