Search in sources :

Example 11 with ItemResult

use of com.icodici.universa.node.ItemResult in project universa by UniversaBlockchain.

the class ItemNotificationTest method packUnpack.

@Test
public void packUnpack() throws Exception {
    NodeInfo ni = new NodeInfo(TestKeys.publicKey(0), 1, "test1", "localhost", 17101, 17102, 17104);
    HashId id1 = HashId.createRandom();
    ZonedDateTime now = ZonedDateTime.now().truncatedTo(ChronoUnit.SECONDS);
    ZonedDateTime expiresAt = now.plusDays(30);
    ItemResult ir1 = new ItemResult(ItemState.PENDING, false, now, expiresAt);
    ItemResult ir2 = new ItemResult(ItemState.REVOKED, true, now, expiresAt);
    ItemNotification n1 = new ItemNotification(ni, id1, ir1, true);
    ItemNotification n2 = new ItemNotification(ni, id1, ir1, false);
    ItemNotification n3 = new ItemNotification(ni, id1, ir1, true);
    byte[] packed = Notification.pack(asList(n1, n2, n3));
    List<Notification> l = Notification.unpack(ni, packed);
    assertEquals(3, l.size());
    ItemNotification n = (ItemNotification) l.get(0);
    assertEquals(n, n1);
    n = (ItemNotification) l.get(1);
    assertEquals(n, n2);
    n = (ItemNotification) l.get(2);
    assertEquals(n, n3);
}
Also used : HashId(com.icodici.universa.HashId) ItemResult(com.icodici.universa.node.ItemResult) ZonedDateTime(java.time.ZonedDateTime) Test(org.junit.Test)

Example 12 with ItemResult

use of com.icodici.universa.node.ItemResult in project universa by UniversaBlockchain.

the class ItemNotification method readFrom.

@Override
protected void readFrom(Boss.Reader br) throws IOException {
    itemId = HashId.withDigest(br.readBinary());
    itemResult = new ItemResult(br);
    requestResult = br.read();
}
Also used : ItemResult(com.icodici.universa.node.ItemResult)

Aggregations

ItemResult (com.icodici.universa.node.ItemResult)12 IOException (java.io.IOException)5 Contract (com.icodici.universa.contract.Contract)4 PrivateKey (com.icodici.crypto.PrivateKey)3 Parcel (com.icodici.universa.contract.Parcel)3 Instant (java.time.Instant)3 Binder (net.sergeych.tools.Binder)3 Test (org.junit.Test)3 ErrorRecord (com.icodici.universa.ErrorRecord)2 HashId (com.icodici.universa.HashId)2 KeyRecord (com.icodici.universa.contract.KeyRecord)2 SimpleRole (com.icodici.universa.contract.roles.SimpleRole)2 ConnectException (java.net.ConnectException)2 SocketTimeoutException (java.net.SocketTimeoutException)2 EncryptionError (com.icodici.crypto.EncryptionError)1 PublicKey (com.icodici.crypto.PublicKey)1 Approvable (com.icodici.universa.Approvable)1 ItemState (com.icodici.universa.node.ItemState)1 com.icodici.universa.node2 (com.icodici.universa.node2)1 HttpURLConnection (java.net.HttpURLConnection)1