use of com.iota.iri.model.Hash in project iri by iotaledger.
the class KerlTest method generateHashes.
// @Test
public void generateHashes() throws Exception {
// System.out.println("trytes,Kerl_hash");
for (int i = 0; i < 1_000_000; i++) {
Hash trytes = getRandomTransactionHash();
int[] initial_value = trytes.trits();
Sponge k = SpongeFactory.create(SpongeFactory.Mode.KERL);
k.absorb(initial_value, 0, initial_value.length);
int[] hash_value = new int[Curl.HASH_LENGTH];
k.squeeze(hash_value, 0, hash_value.length);
String hash = Converter.trytes(hash_value);
// System.out.println(String.format("%s,%s",trytes,hash));
System.out.println(String.format("%s", hash));
}
}
use of com.iota.iri.model.Hash in project iri by iotaledger.
the class MilestoneViewModelTest method latest.
@Test
public void latest() throws Exception {
int top = 100;
Hash milestoneHash = new Hash("ZBCDEFGHIJKLMNOPQRSTUVWXYZ9ABCDEFGHIJKLMNOPQRSTUVWXYZ9ABCDEFGHIJKLMNOPQRSTUV99999");
MilestoneViewModel milestoneViewModel = new MilestoneViewModel(top, milestoneHash);
milestoneViewModel.store(tangle);
assertTrue(top == MilestoneViewModel.latest(tangle).index());
}
use of com.iota.iri.model.Hash in project iri by iotaledger.
the class TangleTest method save.
@Test
public void save() throws Exception {
Transaction transaction = new Transaction();
Random r = new Random();
int[] hash = new int[Curl.HASH_LENGTH], trits = Arrays.stream(new int[TransactionViewModel.TRINARY_SIZE]).map(i -> r.nextInt(3) - 1).toArray();
Sponge curl = SpongeFactory.create(SpongeFactory.Mode.CURLP81);
curl.absorb(trits, 0, trits.length);
curl.squeeze(hash, 0, Curl.HASH_LENGTH);
transaction.bytes = Converter.allocateBytesForTrits(trits.length);
Converter.bytes(trits, transaction.bytes);
// assertTrue("Should be a new, unique transaction", !Tangle.instance().save(transaction).get());
}
use of com.iota.iri.model.Hash in project iri by iotaledger.
the class MilestoneViewModelTest method snapshot.
@Test
public void snapshot() throws Exception {
Hash milestoneHash = new Hash("BBCDEFGHIJKLMNOPQRSTUVWXYZ9ABCDEFGHIJKLMNOPQRSTUVWXYZ9ABCDEFGHIJKLMNOPQRSTUV99999");
long value = 3;
MilestoneViewModel milestoneViewModel = new MilestoneViewModel(++index, milestoneHash);
}
use of com.iota.iri.model.Hash in project iri by iotaledger.
the class MilestoneViewModelTest method first.
@Test
public void first() throws Exception {
int first = 1;
Hash milestoneHash = new Hash("99CDEFGHIJKLMNOPQRSTUVWXYZ9ABCDEFGHIJKLMNOPQRSTUVWXYZ9ABCDEFGHIJKLMNOPQRSTUV99999");
MilestoneViewModel milestoneViewModel = new MilestoneViewModel(first, milestoneHash);
milestoneViewModel.store(tangle);
assertTrue(first == MilestoneViewModel.first(tangle).index());
}
Aggregations