Search in sources :

Example 16 with TransactionViewModel

use of com.iota.iri.controllers.TransactionViewModel in project iri by iotaledger.

the class TransactionValidatorTest method verifyTxIsSolid.

@Test
public void verifyTxIsSolid() throws Exception {
    TransactionViewModel tx = getTxWithBranchAndTrunk();
    assertTrue(txValidator.checkSolidity(tx.getHash(), false));
    assertTrue(txValidator.checkSolidity(tx.getHash(), true));
}
Also used : TransactionViewModel(com.iota.iri.controllers.TransactionViewModel) Test(org.junit.Test)

Example 17 with TransactionViewModel

use of com.iota.iri.controllers.TransactionViewModel in project iri by iotaledger.

the class TransactionValidatorTest method verifyTxIsNotSolid.

@Test
public void verifyTxIsNotSolid() throws Exception {
    TransactionViewModel tx = getTxWithoutBranchAndTrunk();
    assertFalse(txValidator.checkSolidity(tx.getHash(), false));
    assertFalse(txValidator.checkSolidity(tx.getHash(), true));
}
Also used : TransactionViewModel(com.iota.iri.controllers.TransactionViewModel) Test(org.junit.Test)

Example 18 with TransactionViewModel

use of com.iota.iri.controllers.TransactionViewModel in project iri by iotaledger.

the class TransactionValidatorTest method getTxWithBranchAndTrunk.

private TransactionViewModel getTxWithBranchAndTrunk() throws Exception {
    TransactionViewModel tx, trunkTx, branchTx;
    String trytes = "999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999CFDEZBLZQYA9999999999999999999999999999999999999999999ZZWQHWD99C99999999C99999999CKWWDBWSCLMQULCTAAJGXDEMFJXPMGMAQIHDGHRBGEMUYNNCOK9YPHKEEFLFCZUSPMCJHAKLCIBQSGWAS999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999";
    int[] trits = Converter.allocateTritsForTrytes(trytes.length());
    Converter.trits(trytes, trits, 0);
    trunkTx = new TransactionViewModel(trits, Hash.calculate(SpongeFactory.Mode.CURLP81, trits));
    branchTx = new TransactionViewModel(trits, Hash.calculate(SpongeFactory.Mode.CURLP81, trits));
    int[] childTx = getRandomTransactionTrits();
    System.arraycopy(trunkTx.getHash().trits(), 0, childTx, TransactionViewModel.TRUNK_TRANSACTION_TRINARY_OFFSET, TransactionViewModel.TRUNK_TRANSACTION_TRINARY_SIZE);
    System.arraycopy(branchTx.getHash().trits(), 0, childTx, TransactionViewModel.BRANCH_TRANSACTION_TRINARY_OFFSET, TransactionViewModel.BRANCH_TRANSACTION_TRINARY_SIZE);
    tx = new TransactionViewModel(childTx, Hash.calculate(SpongeFactory.Mode.CURLP81, childTx));
    trunkTx.store(tangle);
    branchTx.store(tangle);
    tx.store(tangle);
    return tx;
}
Also used : TransactionViewModel(com.iota.iri.controllers.TransactionViewModel)

Example 19 with TransactionViewModel

use of com.iota.iri.controllers.TransactionViewModel in project iri by iotaledger.

the class TransactionValidatorTest method getTxWithoutBranchAndTrunk.

private TransactionViewModel getTxWithoutBranchAndTrunk() throws Exception {
    int[] trits = getRandomTransactionTrits();
    TransactionViewModel tx = new TransactionViewModel(trits, Hash.calculate(SpongeFactory.Mode.CURLP81, trits));
    tx.store(tangle);
    return tx;
}
Also used : TransactionViewModel(com.iota.iri.controllers.TransactionViewModel)

Example 20 with TransactionViewModel

use of com.iota.iri.controllers.TransactionViewModel in project iri by iotaledger.

the class TangleTest method getKeysStartingWithValue.

@Test
public void getKeysStartingWithValue() throws Exception {
    int[] trits = getRandomTransactionTrits();
    TransactionViewModel transactionViewModel = new TransactionViewModel(trits, Hash.calculate(SpongeFactory.Mode.CURLP81, trits));
    transactionViewModel.store(tangle);
    Set<Indexable> tag = tangle.keysStartingWith(Transaction.class, Arrays.copyOf(transactionViewModel.getTagValue().bytes(), 15));
// Assert.assertNotEquals(tag.length, 0);
}
Also used : TransactionViewModel(com.iota.iri.controllers.TransactionViewModel) Test(org.junit.Test)

Aggregations

TransactionViewModel (com.iota.iri.controllers.TransactionViewModel)23 Hash (com.iota.iri.model.Hash)14 Test (org.junit.Test)11 TransactionViewModelTest.getRandomTransactionHash (com.iota.iri.controllers.TransactionViewModelTest.getRandomTransactionHash)6 SpongeFactory (com.iota.iri.hash.SpongeFactory)3 Tangle (com.iota.iri.storage.Tangle)3 RocksDBPersistenceProvider (com.iota.iri.storage.rocksDB.RocksDBPersistenceProvider)3 Converter (com.iota.iri.utils.Converter)3 Arrays (java.util.Arrays)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 AfterClass (org.junit.AfterClass)3 BeforeClass (org.junit.BeforeClass)3 TemporaryFolder (org.junit.rules.TemporaryFolder)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)2 TransactionValidator (com.iota.iri.TransactionValidator)1 Transaction (com.iota.iri.model.Transaction)1 ByteBuffer (java.nio.ByteBuffer)1 MessageDigest (java.security.MessageDigest)1