Search in sources :

Example 6 with Address

use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.

the class BlockInfoTest method createANewBlockInfo.

@Test
void createANewBlockInfo() {
    String proofGamma = "proofGamma";
    String proofScalar = "proofScalar";
    String proofVerificationHash = "proofVerificationHash";
    String hash = "24E92B511B54EDB48A4850F9B42485FDD1A30589D92C775632DDDD71D7D1D691";
    String generationHash = "57F7DA205008026C776CB6AED843393F04CD458E0AA2D9F1D5F31A402072B2D6";
    String signature = "37351C8244AC166BE6664E3FA954E99A3239AC46E51E2B32CEA1C72DD0851100A7731868E932E1A9BEF8A27D48E1" + "FFEE401E933EB801824373E7537E51733E0F";
    PublicAccount signer = Account.generateNewAccount(NetworkType.MIJIN_TEST).getPublicAccount();
    String previousBlockHash = "0000000000000000000000000000000000000000000000000000000000000000";
    String blockTransactionsHash = "702090BA31CEF9E90C62BBDECC0CCCC0F88192B6625839382850357F70DD68A0";
    String blockReceiptsHash = "702090BA31CEF9E90C62BBDECC0CCCC0F88192B6625839382850357F70DD68A0";
    String stateHash = "702090BA31CEF9E90C62BBDECC0CCCC0F88192B6625839382850357F70DD68A0";
    List<String> subCacheMerkleRoots = new ArrayList<>();
    Address beneficiaryAddress = Account.generateNewAccount(NetworkType.MIJIN_TEST).getAddress();
    String id = "abc";
    List<String> stateHashSubCacheMerkleRoots = Arrays.asList("abc");
    BlockInfo blockInfo = new BlockInfo(id, 10L, hash, generationHash, BigInteger.ZERO, stateHashSubCacheMerkleRoots, 25, 20, 35, subCacheMerkleRoots, signature, signer, NetworkType.MIJIN_TEST, 1, BlockType.NORMAL_BLOCK, BigInteger.ONE, BigInteger.ZERO, BigInteger.valueOf(276447232L), 1L, previousBlockHash, blockTransactionsHash, blockReceiptsHash, stateHash, proofGamma, proofScalar, proofVerificationHash, beneficiaryAddress);
    assertEquals(hash, blockInfo.getHash());
    assertEquals(generationHash, blockInfo.getGenerationHash());
    assertEquals(BigInteger.valueOf(0), blockInfo.getTotalFee());
    assertEquals(10L, blockInfo.getSize());
    assertEquals(25, blockInfo.getTransactionsCount());
    assertEquals(20, blockInfo.getTotalTransactionsCount());
    assertEquals(35, blockInfo.getStatementsCount());
    assertEquals(signature, blockInfo.getSignature());
    Assertions.assertEquals(signer, blockInfo.getSignerPublicAccount());
    assertEquals(NetworkType.MIJIN_TEST, blockInfo.getNetworkType());
    assertEquals(1, (int) blockInfo.getVersion());
    assertEquals(BlockType.NORMAL_BLOCK, blockInfo.getType());
    assertEquals(BigInteger.valueOf(1), blockInfo.getHeight());
    assertEquals(BigInteger.valueOf(0), blockInfo.getTimestamp());
    assertEquals(BigInteger.valueOf(276447232), blockInfo.getDifficulty());
    assertEquals(1, blockInfo.getFeeMultiplier());
    assertEquals(previousBlockHash, blockInfo.getPreviousBlockHash());
    assertEquals(blockTransactionsHash, blockInfo.getBlockTransactionsHash());
    assertEquals(blockReceiptsHash, blockInfo.getBlockReceiptsHash());
    assertEquals(stateHash, blockInfo.getStateHash());
    assertEquals(beneficiaryAddress, blockInfo.getBeneficiaryAddress());
    assertEquals(proofGamma, blockInfo.getProofGamma());
    assertEquals(proofScalar, blockInfo.getProofScalar());
    assertEquals(proofVerificationHash, blockInfo.getProofVerificationHash());
    assertEquals("abc", blockInfo.getRecordId().get());
    assertEquals(stateHashSubCacheMerkleRoots, blockInfo.getStateHashSubCacheMerkleRoots());
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) PublicAccount(io.nem.symbol.sdk.model.account.PublicAccount) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 7 with Address

use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.

the class MosaicInfoTest method toNetworkCurrency.

@Test
void toNetworkCurrency() {
    MosaicFlags mosaicFlags = MosaicFlags.create(true, true, true);
    MosaicId mosaicId = new MosaicId(new BigInteger("-3087871471161192663"));
    Address address = Account.generateNewAccount(NetworkType.MIJIN_TEST).getAddress();
    MosaicInfo mosaicInfo = new MosaicInfo("abc", 1, mosaicId, new BigInteger("100"), new BigInteger("0"), address, 1L, mosaicFlags, 3, BigInteger.valueOf(10));
    Currency currency = mosaicInfo.toCurrency();
    assertEquals(mosaicId, currency.getMosaicId().get());
    assertFalse(currency.getNamespaceId().isPresent());
    assertTrue(currency.isSupplyMutable());
    assertTrue(currency.isTransferable());
    assertEquals(3, currency.getDivisibility());
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) BigInteger(java.math.BigInteger) Test(org.junit.jupiter.api.Test)

Example 8 with Address

use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.

the class ResolutionStatementTest method setup.

@BeforeAll
public static void setup() {
    address = new Address("SDZWZJUAYNOWGBTCUDBY3SE5JF4NCC2RDM6SIGQ", networkType);
    mosaicId = new MosaicId("85BBEA6CC462B244");
    namespaceId = NamespaceId.createFromName("money");
    receiptSource = new ReceiptSource(1, 1);
    addressResolutionEntry = new ResolutionEntry<>(address, receiptSource, ReceiptType.ADDRESS_ALIAS_RESOLUTION);
    mosaicResolutionEntry = new ResolutionEntry<>(mosaicId, receiptSource, ReceiptType.MOSAIC_ALIAS_RESOLUTION);
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 9 with Address

use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.

the class MosaicInfoTest method createAMosaicInfoViaConstructor.

@Test
void createAMosaicInfoViaConstructor() {
    MosaicFlags mosaicFlags = MosaicFlags.create(true, true, true);
    MosaicId mosaicId = new MosaicId(new BigInteger("-3087871471161192663"));
    Address address = Address.createFromRawAddress("SDY3NFHBQAPO7ZBII3USHG2UZHJYD7G7FICKIII");
    MosaicInfo info = new MosaicInfo("abc", 1, mosaicId, new BigInteger("100"), new BigInteger("200"), address, 1L, mosaicFlags, 3, BigInteger.valueOf(10));
    assertEquals(mosaicId, info.getMosaicId());
    assertEquals(new BigInteger("100"), info.getSupply());
    assertEquals(new BigInteger("200"), info.getStartHeight());
    assertEquals(address, info.getOwnerAddress());
    assertTrue(info.isSupplyMutable());
    assertTrue(info.isTransferable());
    assertTrue(info.isTransferable());
    assertEquals(1L, info.getRevision());
    assertEquals(3, info.getDivisibility());
    assertEquals(BigInteger.valueOf(10), info.getDuration());
    assertEquals("abc", info.getRecordId().get());
    byte[] serializedState = info.serialize();
    String expectedHex = "010029CF5FD941AD25D56400000000000000C80000000000000090F1B694E1801EEFE42846E9239B54C9D381FCDF2A04A4210100000007030A00000000000000";
    Assertions.assertEquals(expectedHex, ConvertUtils.toHex(serializedState));
    MosaicEntryBuilder builder = MosaicEntryBuilder.loadFromBinary(SerializationUtils.toDataInput(serializedState));
    Assertions.assertEquals(expectedHex, ConvertUtils.toHex(builder.serialize()));
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) MosaicEntryBuilder(io.nem.symbol.catapult.builders.MosaicEntryBuilder) BigInteger(java.math.BigInteger) Test(org.junit.jupiter.api.Test)

Example 10 with Address

use of io.nem.symbol.sdk.model.account.Address in project nem2-sdk-java by nemtech.

the class NamespaceInfoTest method createANamespaceInfoViaConstructor.

@Test
void createANamespaceInfoViaConstructor() {
    NamespaceId namespaceId = NamespaceId.createFromId(new BigInteger("-8884663987180930485"));
    Address address = Address.createFromRawAddress("SDXK5NYCKOSAT2NCIPYIEYN57N5XEVNCZ5AIAOI");
    NamespaceInfo namespaceInfo = new NamespaceInfo("abc", 1, true, 0, NamespaceRegistrationType.ROOT_NAMESPACE, 1, Arrays.asList(namespaceId), NamespaceId.createFromId(new BigInteger("0")), address, new BigInteger("1"), new BigInteger("-1"), new MosaicAlias(new MosaicId(new BigInteger("100"))));
    assertEquals("abc", namespaceInfo.getRecordId().get());
    assertTrue(namespaceInfo.isActive());
    assertEquals(0, (int) namespaceInfo.getIndex());
    assertSame(namespaceInfo.getRegistrationType(), NamespaceRegistrationType.ROOT_NAMESPACE);
    assertEquals(1, (int) namespaceInfo.getDepth());
    assertEquals(namespaceId, namespaceInfo.getLevels().get(0));
    Assertions.assertEquals(address, namespaceInfo.getOwnerAddress());
    assertEquals(new BigInteger("1"), namespaceInfo.getStartHeight());
    assertEquals(new BigInteger("-1"), namespaceInfo.getEndHeight());
    assertEquals(AliasType.MOSAIC, namespaceInfo.getAlias().getType());
    assertEquals(new BigInteger("100"), ((MosaicId) namespaceInfo.getAlias().getAliasValue()).getId());
    byte[] serialize = namespaceInfo.serialize(Arrays.asList(createSubNamespaceInfo(namespaceId)));
    assertEquals("01004BFA5F372D55B38490EEAEB70253A409E9A243F08261BDFB7B7255A2CF4080390100000000000000FFFFFFFFFFFFFFFF01640000000000000001000000000000000129CF2728A91AE7F0016400000000000000", ConvertUtils.toHex(serialize));
}
Also used : Address(io.nem.symbol.sdk.model.account.Address) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) BigInteger(java.math.BigInteger) Test(org.junit.jupiter.api.Test)

Aggregations

Address (io.nem.symbol.sdk.model.account.Address)172 Test (org.junit.jupiter.api.Test)124 MosaicId (io.nem.symbol.sdk.model.mosaic.MosaicId)53 BigInteger (java.math.BigInteger)36 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)34 ArrayList (java.util.ArrayList)28 PlainMessage (io.nem.symbol.sdk.model.message.PlainMessage)27 EnumSource (org.junit.jupiter.params.provider.EnumSource)26 Account (io.nem.symbol.sdk.model.account.Account)20 PublicAccount (io.nem.symbol.sdk.model.account.PublicAccount)19 UnresolvedAddress (io.nem.symbol.sdk.model.account.UnresolvedAddress)19 Transaction (io.nem.symbol.sdk.model.transaction.Transaction)16 TransferTransaction (io.nem.symbol.sdk.model.transaction.TransferTransaction)16 ListenerSubscribeMessage (io.nem.symbol.sdk.infrastructure.ListenerSubscribeMessage)15 Mosaic (io.nem.symbol.sdk.model.mosaic.Mosaic)14 AggregateTransaction (io.nem.symbol.sdk.model.transaction.AggregateTransaction)13 CosignatureSignedTransaction (io.nem.symbol.sdk.model.transaction.CosignatureSignedTransaction)13 Observable (io.reactivex.Observable)13 NamespaceId (io.nem.symbol.sdk.model.namespace.NamespaceId)12 SignedTransaction (io.nem.symbol.sdk.model.transaction.SignedTransaction)10