Skip to content

Commit

Permalink
Test updating an IPNS value with the same expiry
Browse files Browse the repository at this point in the history
  • Loading branch information
ianopolous committed Dec 13, 2023
1 parent 457c7a6 commit f86c885
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/test/java/org/peergos/EmbeddedIpfsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void publishPresignedValue() throws Exception {
PrivKey publisher = Ed25519Kt.generateEd25519KeyPair().getFirst();
byte[] value = "This is a test".getBytes();
io.ipfs.multihash.Multihash pub = Multihash.deserialize(PeerId.fromPubKey(publisher.publicKey()).getBytes());
long hoursTtl = 24*2;
long hoursTtl = 24*365;
LocalDateTime expiry = LocalDateTime.now().plusHours(hoursTtl);
long ttlNanos = hoursTtl * 3600_000_000_000L;
byte[] signedRecord = IPNS.createSignedRecord(value, expiry, 1, ttlNanos, publisher);
Expand All @@ -76,6 +76,16 @@ public void publishPresignedValue() throws Exception {
byte[] res = node1.resolveValue(publisher.publicKey()).join();
Assert.assertTrue(Arrays.equals(res, value));

// publish an updated value with same expiry
byte[] value2 = "Updated value".getBytes();
byte[] signedRecord2 = IPNS.createSignedRecord(value2, expiry, 2, ttlNanos, publisher);
node1.publishPresignedRecord(pub, signedRecord2).join();
node1.publishPresignedRecord(pub, signedRecord2).join();
node1.publishPresignedRecord(pub, signedRecord2).join();

byte[] res2 = node1.resolveValue(publisher.publicKey()).join();
Assert.assertTrue(Arrays.equals(res2, value2));

node1.stop();
}

Expand Down

0 comments on commit f86c885

Please sign in to comment.