use of com.iota.iri.model.Hash in project iri by iotaledger.
the class TipsViewModelTest method totalCapacityLimited.
@Test
public void totalCapacityLimited() throws ExecutionException, InterruptedException {
TipsViewModel tipsVM = new TipsViewModel();
int capacity = TipsViewModel.MAX_TIPS;
// fill tips list
for (int i = 0; i <= capacity * 4; i++) {
Hash hash = TransactionViewModelTest.getRandomTransactionHash();
tipsVM.addTipHash(hash);
if (i % 2 == 1) {
tipsVM.setSolid(hash);
}
}
// check that limit wasn't breached
assertEquals(capacity * 2, tipsVM.size());
}
use of com.iota.iri.model.Hash in project iri by iotaledger.
the class ISSTest method addressGenerationISS.
@Test
public void addressGenerationISS() throws Exception {
int index = 0;
int nof = 2;
SpongeFactory.Mode[] modes = { SpongeFactory.Mode.CURLP81, SpongeFactory.Mode.KERL };
Hash[] hashes = { new Hash("D9XCNSCCAJGLWSQOQAQNFWANPYKYMCQ9VCOMROLDVLONPPLDFVPIZNAPVZLQMPFYJPAHUKIAEKNCQIYJZ"), new Hash("MDWYEJJHJDIUVPKDY9EACGDJUOP9TLYDWETUBOYCBLYXYYYJYUXYUTCTPTDGJYFKMQMCNZDQPTBE9AFIW") };
for (int i = 0; i < modes.length; i++) {
SpongeFactory.Mode mode = modes[i];
int[] seedTrits = Converter.allocateTritsForTrytes(seed.length());
Converter.trits(seed, seedTrits, 0);
int[] subseed = ISS.subseed(mode, seedTrits, index);
int[] key = ISS.key(mode, subseed, nof);
int[] digest = ISS.digests(mode, key);
int[] address = ISS.address(mode, digest);
Hash addressTrytes = new Hash(address);
assertEquals(hashes[i].toString(), addressTrytes.toString());
}
}
use of com.iota.iri.model.Hash in project iri by iotaledger.
the class PearlDiverTest method testNoRandomFail.
@Test
@Ignore("to test pearlDiver iteratively")
public void testNoRandomFail() {
for (int i = 0; i < 10000; i++) {
int[] trits = TransactionViewModelTest.getRandomTransactionTrits();
pearlDiver.search(trits, MIN_WEIGHT_MAGNITUDE, NUM_CORES);
Hash hash = Hash.calculate(SpongeFactory.Mode.CURLP81, trits);
for (int j = Hash.SIZE_IN_TRITS - 1; j > Hash.SIZE_IN_TRITS - MIN_WEIGHT_MAGNITUDE; j--) {
assertEquals(hash.trits()[j], 0);
}
if (i % 100 == 0) {
System.out.println(i + " successful hashes.");
}
}
}
use of com.iota.iri.model.Hash in project iri by iotaledger.
the class TransactionRequesterTest method milestoneCapacityNotLimited.
@Test
public void milestoneCapacityNotLimited() throws Exception {
TransactionRequester txReq = new TransactionRequester(tangle, mq);
int capacity = TransactionRequester.MAX_TX_REQ_QUEUE_SIZE;
// fill tips list
for (int i = 0; i < capacity * 2; i++) {
Hash hash = TransactionViewModelTest.getRandomTransactionHash();
txReq.requestTransaction(hash, true);
}
// check that limit was surpassed
assertEquals(capacity * 2, txReq.numberOfTransactionsToRequest());
}
use of com.iota.iri.model.Hash in project iri by iotaledger.
the class TransactionRequesterTest method mixedCapacityLimited.
@Test
public void mixedCapacityLimited() throws Exception {
TransactionRequester txReq = new TransactionRequester(tangle, mq);
int capacity = TransactionRequester.MAX_TX_REQ_QUEUE_SIZE;
// fill tips list
for (int i = 0; i < capacity * 4; i++) {
Hash hash = TransactionViewModelTest.getRandomTransactionHash();
txReq.requestTransaction(hash, (i % 2 == 1));
}
// check that limit wasn't breached
assertEquals(capacity + capacity * 2, txReq.numberOfTransactionsToRequest());
}
Aggregations