Search in sources :

Example 1 with ChainProperties

use of io.nem.symbol.sdk.model.network.ChainProperties in project nem2-sdk-java by nemtech.

the class CurrencyServiceTest method getNetworkCurrencies.

@Test
void getNetworkCurrencies() throws Exception {
    NetworkConfiguration networkConfiguration = Mockito.mock(NetworkConfiguration.class);
    ChainProperties chainProperties = Mockito.mock(ChainProperties.class);
    String currencyMosaicIdHex = "0x62EF'46FD'6555'AAAA";
    MosaicId currencyMosaicId = new MosaicId(FormatUtils.toSimpleHex(currencyMosaicIdHex));
    Mockito.when(chainProperties.getCurrencyMosaicId()).thenReturn(currencyMosaicIdHex);
    String harvestMosaicIdHex = "0x62EF'46FD'6555'BBBB";
    MosaicId harvestMosaicId = new MosaicId(FormatUtils.toSimpleHex(harvestMosaicIdHex));
    Mockito.when(chainProperties.getHarvestingMosaicId()).thenReturn(harvestMosaicIdHex);
    Mockito.when(networkConfiguration.getChain()).thenReturn(chainProperties);
    Mockito.when(networkRepository.getNetworkProperties()).thenReturn(Observable.just(networkConfiguration));
    Address account = Address.generateRandom(NetworkType.MIJIN_TEST);
    MosaicInfo currencyMosaicInfo = new MosaicInfo("abc", 1, currencyMosaicId, BigInteger.valueOf(100), BigInteger.ONE, account, 4L, MosaicFlags.create(false, true, false), 10, BigInteger.TEN);
    MosaicInfo harvestMosaicInfo = new MosaicInfo("abc", 1, harvestMosaicId, BigInteger.valueOf(200), BigInteger.ONE, account, 4L, MosaicFlags.create(true, false, true), 3, BigInteger.TEN);
    Mockito.when(mosaicRepository.getMosaics(Mockito.eq(Arrays.asList(currencyMosaicId, harvestMosaicId)))).thenReturn(Observable.just(Arrays.asList(currencyMosaicInfo, harvestMosaicInfo)));
    Mockito.when(namespaceRepository.getMosaicsNames(Mockito.eq(Arrays.asList(currencyMosaicId, harvestMosaicId)))).thenReturn(Observable.just(Collections.emptyList()));
    NetworkCurrencies networkCurrencies = service.getNetworkCurrencies().toFuture().get();
    Assertions.assertEquals(currencyMosaicInfo.toCurrency(), networkCurrencies.getCurrency());
    Assertions.assertEquals(harvestMosaicInfo.toCurrency(), networkCurrencies.getHarvest());
}
Also used : MosaicInfo(io.nem.symbol.sdk.model.mosaic.MosaicInfo) Address(io.nem.symbol.sdk.model.account.Address) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) ChainProperties(io.nem.symbol.sdk.model.network.ChainProperties) NetworkConfiguration(io.nem.symbol.sdk.model.network.NetworkConfiguration) NetworkCurrencies(io.nem.symbol.sdk.model.mosaic.NetworkCurrencies) Test(org.junit.jupiter.api.Test)

Aggregations

Address (io.nem.symbol.sdk.model.account.Address)1 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)1 MosaicInfo (io.nem.symbol.sdk.model.mosaic.MosaicInfo)1 NetworkCurrencies (io.nem.symbol.sdk.model.mosaic.NetworkCurrencies)1 ChainProperties (io.nem.symbol.sdk.model.network.ChainProperties)1 NetworkConfiguration (io.nem.symbol.sdk.model.network.NetworkConfiguration)1 Test (org.junit.jupiter.api.Test)1