use of com.iota.iri.hash.Curl 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());
}
Aggregations