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));
}
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));
}
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;
}
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;
}
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);
}
Aggregations