Easter cleaning

This commit is contained in:
Willem Cazander 2025-05-07 21:46:32 +02:00
commit 9e36078b2e
1862 changed files with 270281 additions and 0 deletions

View file

@ -0,0 +1,53 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.nx01.no2all.nostr.model;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import love.distributedrebirth.nx01.no2all.nostr.model.NoStrIdentity;
import love.distributedrebirth.nx01.no2all.nostr.model.NoStrIdentityPrivateKey;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class NoStrIdentityTest {
@Test
public void testNotEqualKeys() {
NoStrIdentity user = new NoStrIdentity(NoStrIdentityPrivateKey.ofRandom());
Assertions.assertNotEquals(user.getPrivateKey().getHex(), user.getPublicKey().getHex());
}
@Test
public void testRandom() {
NoStrIdentity user1 = new NoStrIdentity(NoStrIdentityPrivateKey.ofRandom());
NoStrIdentity user2 = new NoStrIdentity(NoStrIdentityPrivateKey.ofRandom());
Assertions.assertNotEquals(user1.getPrivateKey().getHex(), user2.getPrivateKey().getHex());
Assertions.assertNotEquals(user1.getPublicKey().getHex(), user2.getPublicKey().getHex());
}
}

View file

@ -0,0 +1,60 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.nx01.no2all.nostr.model;
import java.io.StringReader;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import jakarta.json.Json;
import jakarta.json.JsonObject;
import jakarta.json.JsonReader;
import love.distributedrebirth.nx01.no2all.nostr.model.NoStrProfileMetaData;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class NoStrProfileMetaDataTest {
@Test
public void testUnknownKeys() {
JsonObject json = Json.createObjectBuilder()
.add("display_name", "junit")
.add("foo", "bar")
.build();
NoStrProfileMetaData profileData = new NoStrProfileMetaData(json);
String jsonStr = profileData.toBible().toString();
try (JsonReader read = Json.createReader(new StringReader(jsonStr))) {
JsonObject jsonResult = read.readObject();
NoStrProfileMetaData profileDataResult = new NoStrProfileMetaData(jsonResult);
Assertions.assertEquals("junit", profileDataResult.getDisplayName());
Assertions.assertEquals("bar", jsonResult.getString("foo"));
}
}
}

View file

@ -0,0 +1,65 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.nx01.no2all.nostr.model;
import java.io.InputStreamReader;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import jakarta.json.Json;
import jakarta.json.JsonReader;
import love.distributedrebirth.nx01.no2all.nostr.model.NoStrRelayInfo;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class NoStrRelayInfoTest {
// For Example wss://relay.snort.social
//{
// "id": "wss://relay.snort.social/",
// "name": "Snort Relay",
//etc
@Test
public void testRead() throws Exception {
try (JsonReader read = Json.createReader(new InputStreamReader(getClass().getResourceAsStream("relay-info.json")))) {
NoStrRelayInfo relayInfo = new NoStrRelayInfo(read.readObject());
Assertions.assertEquals("eden.nostr.land", relayInfo.getName());
Assertions.assertEquals("1.22.6", relayInfo.getVersion());
Assertions.assertTrue(relayInfo.getSupportedNips().contains(11));
Assertions.assertTrue(relayInfo.getSupportedNips().contains(40));
Assertions.assertNotNull(relayInfo.getLimitation());
Assertions.assertEquals(10, relayInfo.getLimitation().getMaxSubscriptions());
Assertions.assertEquals(256, relayInfo.getLimitation().getMaxSubIdLength());
Assertions.assertTrue(relayInfo.getFeesPublication().isEmpty());
Assertions.assertFalse(relayInfo.getFeesAdmission().isEmpty());
Assertions.assertEquals("msats", relayInfo.getFeesAdmission().get(0).getUnit());
}
}
}

View file

@ -0,0 +1,220 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.nx01.no2all.nostr.model.event;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.time.Duration;
import java.time.Instant;
import java.util.Optional;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import jakarta.json.Json;
import jakarta.json.JsonReader;
import love.distributedrebirth.nx01.no2all.nostr.model.NoStrIdentity;
import love.distributedrebirth.nx01.no2all.nostr.model.NoStrIdentityPrivateKey;
import love.distributedrebirth.nx01.no2all.nostr.model.event.NoStrEvent;
import love.distributedrebirth.nx01.no2all.nostr.model.event.NoStrEventPayload;
import love.distributedrebirth.nx01.no2all.nostr.model.event.NoStrEventSignature;
import love.distributedrebirth.nx01.no2all.nostr.model.event.NoStrEventTag;
import love.distributedrebirth.nx01.no2all.nostr.model.tag.NoStrTagNonce;
import love.distributedrebirth.nx01.no2all.nostr.nip.NoStrImplEventTag;
import love.distributedrebirth.nx01.no2all.nostr.nip.tag.NoStrImplTagNonce;
import love.distributedrebirth.nx01.no2all.nostr.octo.OctoBitFormat;
import love.distributedrebirth.nx01.no2all.nostr.octo.trust.OctoTrust;
import love.distributedrebirth.nx01.no2all.nostr.octo.trust.OctoTrustHash;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class NoStrEventSignatureTest {
@Test
public void testReadEventVerifyOk() throws Exception {
try (JsonReader reader = Json.createReader(new InputStreamReader(getClass().getResourceAsStream("note-text-simple.json")))) {
NoStrEvent event = new NoStrEvent(reader.readObject());
Assertions.assertTrue(NoStrEventSignature.verify(event));
}
}
@Test
public void testReadEventVerifyFail() throws Exception {
try (JsonReader reader = Json.createReader(new InputStreamReader(getClass().getResourceAsStream("note-text-sign-error.json")))) {
NoStrEvent event = new NoStrEvent(reader.readObject());
Assertions.assertFalse(NoStrEventSignature.verify(event));
}
}
@Test
public void testMining() throws Exception {
Duration maxMining = Duration.ofSeconds(360);
int maxDifficulty = (OctoTrust.KEY_LENGTH * 8) / 2; // is 128 thus 50% of bits are zero
NoStrIdentity nid = new NoStrIdentity(NoStrIdentityPrivateKey.ofRandom());
try (JsonReader reader = Json.createReader(new InputStreamReader(getClass().getResourceAsStream("note-text-simple.json")))) {
NoStrEvent event = new NoStrEvent(reader.readObject());
Assertions.assertTrue(NoStrEventSignature.verify(event));
int testOffsetDifficulty = 10; // +12 from note-text-simple.json
// use test public key and copy others
NoStrEventPayload payload = new NoStrEventPayload(nid.getPublicKey(), event.getPayload().getCreatedAt(), event.getPayload().getKind(), event.getPayload().getTags(), event.getPayload().getContent());
Optional<NoStrEventTag> nonceTagOpt = payload.findFirstByQName(NoStrImplEventTag.NONCE);
if (nonceTagOpt.isEmpty()) {
return; // no mining requested
}
// replace X NoStrEventTag impl or NoStrEventTagCustom or NoStrTagNonce with local tag for setter access
NoStrTagNonce nonceTag = new NoStrTagNonce(Integer.parseInt(nonceTagOpt.get().getMetaArgument(NoStrImplTagNonce.DIFFICULTY).get()) + testOffsetDifficulty);
int nonceTagIdx = payload.getTags().indexOf(nonceTagOpt.get());
payload.getTags().set(nonceTagIdx, nonceTag);
int targetDifficulty = nonceTag.getDifficulty();
if (targetDifficulty > maxDifficulty) {
throw new IllegalArgumentException("Target difficulty can't be larger than " + maxDifficulty);
}
int mineCnt = 0;
byte[] eventId = null;
int leadingZeroBits = 0;
byte[] nowStr = Long.toString(payload.getCreatedAt().getEpochSecond()).getBytes(StandardCharsets.UTF_8);
byte[] payloadStr = NoStrEventSignature.generateEventIdJsonString(payload).getBytes(StandardCharsets.UTF_8);
int createdAtLength = nowStr.length;
int createdAtIdx = indexOf(payloadStr, nowStr, indexOf(payloadStr, new byte[]{'\"'}, 5));
int nonceProofIdx = indexOf(payloadStr, "\"nonce\"".getBytes(StandardCharsets.UTF_8), 0) + 9;// ["nonce","7539","12"]],
int nonceProofLength = Integer.toString(nonceTag.getBearerProof()).getBytes(StandardCharsets.UTF_8).length;
long createdAtTime = System.currentTimeMillis();
long maxMiningTime = createdAtTime + maxMining.toMillis();
MessageDigest sha256 = OctoTrustHash.sha256Algorithm();
while (leadingZeroBits < targetDifficulty) {
mineCnt++;
createdAtTime = System.currentTimeMillis();
if (createdAtTime > maxMiningTime) {
throw new IllegalStateException("Mining resource limit exceeded");
}
long createdAtTimeSecs = createdAtTime / 1000;
int createdAtTimeDigits = numDigits(createdAtTimeSecs);
if (createdAtLength != createdAtTimeDigits) {
createdAtLength = createdAtTimeDigits;
payloadStr = growBySplit(payloadStr, createdAtIdx);
}
writeDigits(createdAtTimeSecs, createdAtTimeDigits, payloadStr, createdAtIdx);
int nonceProofDigits = numDigits(mineCnt);
if (nonceProofLength != nonceProofDigits) {
nonceProofLength = nonceProofDigits;
payloadStr = growBySplit(payloadStr, nonceProofIdx);
}
writeDigits(mineCnt, nonceProofDigits, payloadStr, nonceProofIdx);
eventId = sha256.digest(payloadStr);
leadingZeroBits = 0;
for (int i = 0; i < eventId.length; i++) {
int step = eventId[i] & 0xFF; // force unsigned
if (step == 0) {
leadingZeroBits += 8;
continue;
}
leadingZeroBits += Integer.numberOfLeadingZeros(step) - 24;
break;
}
}
payload.setCreatedAt(Instant.ofEpochMilli(createdAtTime));
nonceTag.setBearerProof(mineCnt);
NoStrEvent eventMined = NoStrEventSignature.sign(payload, nid.getPrivateKey(), eventId);
System.out.println("idOrg=" + event.getId().getHex());
System.out.println("idHex=" + eventMined.getId().getHex());
System.out.println("idStr=" + NoStrEventSignature.generateEventIdJsonString(payload));
System.out.println("leadZero=" + leadingZeroBits);
System.out.println("mineCnt=" + mineCnt);
System.out.println("idStrHex=" + OctoBitFormat.HEX.fromBytes(NoStrEventSignature.generateEventIdJsonString(payload).getBytes(StandardCharsets.UTF_8)));
System.out.println("idStrArr=" + OctoBitFormat.HEX.fromBytes(payloadStr));
Assertions.assertTrue(NoStrEventSignature.verify(eventMined));
Assertions.assertEquals("" + mineCnt, eventMined.getPayload().findFirstByQName("nonce").get().getMetaArgument(0).get());
Assertions.assertEquals("" + targetDifficulty, eventMined.getPayload().findFirstByQName("nonce").get().getMetaArgument(1).get());
}
}
public byte[] growBySplit(byte[] src, int splitIdx) {
byte[] result = new byte[src.length + 1];
System.arraycopy(src, 0, result, 0, splitIdx);
System.arraycopy(src, splitIdx + 1, result, splitIdx + 2, src.length - splitIdx - 1);
return result;
}
public void writeDigits(long value, int digits, byte[] target, int off) {
int i = digits - 1;
while (value > 0) {
target[i+off] = (byte) ((value % 10) + '0');
value /= 10;
i--;
}
}
public int numDigits(long n) {
return (int) Math.log10(n) + 1;
}
public int indexOf(byte[] source, byte[] target, int fromIndex) {
return indexOf(source, 0, source.length, target, 0, target.length, fromIndex);
}
public int indexOf(byte[] source, int sourceOffset, int sourceCount, byte[] target, int targetOffset, int targetCount, int fromIndex) {
if (fromIndex >= sourceCount) {
return (targetCount == 0 ? sourceCount : -1);
}
if (fromIndex < 0) {
fromIndex = 0;
}
if (targetCount == 0) {
return fromIndex;
}
byte first = target[targetOffset];
int max = sourceOffset + (sourceCount - targetCount);
for (int i = sourceOffset + fromIndex; i <= max; i++) {
if (source[i] != first) { // search first
while (++i <= max && source[i] != first) {
;
}
}
if (i <= max) { // search left over
int j = i + 1;
int end = j + targetCount - 1;
for (int k = targetOffset + 1; j < end && source[j] == target[k]; j++, k++) {
;
}
if (j == end) {
return i - sourceOffset;
}
}
}
return -1;
}
}

View file

@ -0,0 +1,51 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.nx01.no2all.nostr.model.event;
import java.util.Optional;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import love.distributedrebirth.nx01.no2all.nostr.model.event.NoStrEventTag;
import love.distributedrebirth.nx01.no2all.nostr.nip.NoStrImplEventTag;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class NoStrEventTagTest {
@Test
public void testArgumentResult() {
NoStrEventTag tag = NoStrEventTag.valueOfArgs(NoStrImplEventTag.CLIENT, "0", "1");
Assertions.assertEquals(2, tag.getMetaArguments().length);
Assertions.assertEquals(Optional.empty(), tag.getMetaArgument(-1));
Assertions.assertEquals(Optional.empty(), tag.getMetaArgument(2));
Assertions.assertTrue(tag.getMetaArgument(0).isPresent());
Assertions.assertEquals("1", tag.getMetaArgument(1).get());
}
}

View file

@ -0,0 +1,96 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.nx01.no2all.nostr.model.event;
import java.io.InputStreamReader;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import jakarta.json.Json;
import jakarta.json.JsonReader;
import jakarta.json.JsonWriter;
import jakarta.json.JsonWriterFactory;
import jakarta.json.stream.JsonGenerator;
import love.distributedrebirth.nx01.no2all.nostr.model.event.NoStrEvent;
import love.distributedrebirth.nx01.no2all.nostr.model.event.NoStrEventPayload;
import love.distributedrebirth.nx01.no2all.nostr.model.event.NoStrEventTag;
import love.distributedrebirth.nx01.no2all.nostr.nip.NoStrImplEventTag;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class NoStrEventTest {
@Test
public void testReadEvent() throws Exception {
try (JsonReader reader = Json.createReader(new InputStreamReader(getClass().getResourceAsStream("note-text-sign-error.json")))) {
NoStrEvent event = new NoStrEvent(reader.readObject());
NoStrEventPayload payload = event.getPayload();
Assertions.assertEquals("000c5b8f354d200abd7dc0bc81bd35153aebe72824c23e834db5feb83591c20d", event.getId().getHex());
Assertions.assertEquals(1, payload.getKind().getNumber());
Optional<NoStrEventTag> clientTag = payload.findFirstByQName(NoStrImplEventTag.CLIENT);
Assertions.assertTrue(clientTag.isPresent());
Assertions.assertEquals("more-speech", clientTag.get().getMetaArgument(0).get().split(" ")[0]);
Assertions.assertEquals(13, payload.findByQName(NoStrImplEventTag.P).size());
Optional<NoStrEventTag> eTag = payload.findFirstByQName(NoStrImplEventTag.E);
Assertions.assertTrue(eTag.isPresent());
Assertions.assertEquals("d54e918e87b55253315df49cc44e60ca551b9124c2a3dc1b4d68c57e13ba8422", eTag.get().getMetaArgument(0).get());
Assertions.assertEquals("reply", eTag.get().getMetaArgument(2).get());
}
}
@Test
public void testReadEventPritty() throws Exception {
Map<String, Object> config = new HashMap<>();
config.put(JsonGenerator.PRETTY_PRINTING, true);
JsonWriterFactory prittyFactory = Json.createWriterFactory(config);
try (JsonReader reader = Json.createReader(new InputStreamReader(getClass().getResourceAsStream("note-text-sign-error.json")))) {
NoStrEvent event = new NoStrEvent(reader.readObject());
StringWriter jsonStr = new StringWriter();
try (JsonWriter writer = prittyFactory.createWriter(jsonStr)) {
writer.write(event.toBible());
}
System.out.println(jsonStr.getBuffer());
}
}
@Test
public void testEmptyTags() throws Exception {
try (JsonReader reader = Json.createReader(new InputStreamReader(getClass().getResourceAsStream("note-empty-tags.json")))) {
NoStrEvent event = new NoStrEvent(reader.readObject());
NoStrEventPayload payload = event.getPayload();
Assertions.assertEquals("fc7f200c5bed175702bd06c7ca5dba90d3497e827350b42fc99c3a4fa276a712", event.getId().getHex());
Assertions.assertEquals(1, payload.getKind().getNumber());
Assertions.assertTrue(payload.getTags().isEmpty());
}
}
}

View file

@ -0,0 +1,59 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.nx01.no2all.nostr.model.share;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import love.distributedrebirth.nx01.no2all.nostr.model.event.NoStrEventId;
import love.distributedrebirth.nx01.no2all.nostr.model.share.NoStrShareLinkEvent;
import love.distributedrebirth.nx01.no2all.nostr.model.share.NoStrShareLinkNote;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class NoStrShareLinkEventTest {
@Test
public void testToObject() {
NoStrEventId key1 = NoStrShareLinkEvent.ofB32("nevent1qqsqqrzm3u656gq2h47up0yph5632whtuu5zfs37sdxmtl4cxkguyrgvg94ye").getEventId();
Assertions.assertEquals("000c5b8f354d200abd7dc0bc81bd35153aebe72824c23e834db5feb83591c20d", key1.getHex());
}
@Test
public void testToString() {
NoStrEventId eventId1 = NoStrEventId.ofHex("000c5b8f354d200abd7dc0bc81bd35153aebe72824c23e834db5feb83591c20d");
NoStrShareLinkEvent linkEvent1 = new NoStrShareLinkEvent(eventId1);
NoStrShareLinkNote linkNote1 = new NoStrShareLinkNote(eventId1);
Assertions.assertEquals("nevent1qqsqqrzm3u656gq2h47up0yph5632whtuu5zfs37sdxmtl4cxkguyrgvg94ye", linkEvent1.toShareLink());
Assertions.assertEquals("note1qqx9hre4f5sq40tacz7gr0f4z5awheegynpraq6dkhltsdv3cgxszha4k8", linkNote1.toShareLink());
NoStrEventId eventId2 = NoStrEventId.ofHex("d94a3f4dd87b9a3b0bed183b32e916fa29c8020107845d1752d72697fe5309a5");
NoStrShareLinkNote link2 = new NoStrShareLinkNote(eventId2);
Assertions.assertEquals("note1m99r7nwc0wdrkzldrqan96gklg5usqspq7z9696j6unf0ljnpxjspqfw99", link2.toShareLink());
}
}

View file

@ -0,0 +1,55 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.nx01.no2all.nostr.model.share;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import love.distributedrebirth.nx01.no2all.nostr.model.NoStrIdentityPrivateKey;
import love.distributedrebirth.nx01.no2all.nostr.model.share.NoStrShareLinkPrivateKey;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class NoStrShareLinkPrivateKeyTest {
@Test
public void testToObject() {
NoStrIdentityPrivateKey key1 = NoStrShareLinkPrivateKey.ofB32("nsec1j4c6269y9w0q2er2xjw8sv2ehyrtfxq3jwgdlxj6qfn8z4gjsq5qfvfk99").getPrivateKey();
Assertions.assertEquals("9571a568a42b9e05646a349c783159b906b498119390df9a5a02667155128028", key1.getHex());
NoStrIdentityPrivateKey key2 = NoStrShareLinkPrivateKey.ofB32("nsec1vl029mgpspedva04g90vltkh6fvh240zqtv9k0t9af8935ke9laqsnlfe5").getPrivateKey();
Assertions.assertEquals("67dea2ed018072d675f5415ecfaed7d2597555e202d85b3d65ea4e58d2d92ffa", key2.getHex());
}
@Test
public void testToString() {
NoStrIdentityPrivateKey key1 = NoStrIdentityPrivateKey.ofHex("9571a568a42b9e05646a349c783159b906b498119390df9a5a02667155128028");
NoStrShareLinkPrivateKey keyLink1 = new NoStrShareLinkPrivateKey(key1);
Assertions.assertEquals("nsec1j4c6269y9w0q2er2xjw8sv2ehyrtfxq3jwgdlxj6qfn8z4gjsq5qfvfk99", keyLink1.toShareLink());
}
}

View file

@ -0,0 +1,84 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.nx01.no2all.nostr.model.share;
import java.util.Base64;
import java.util.List;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import love.distributedrebirth.nx01.no2all.nostr.model.NoStrIdentityPublicKey;
import love.distributedrebirth.nx01.no2all.nostr.model.share.NoStrShareLinkProfile;
import love.distributedrebirth.nx01.no2all.nostr.octo.OctoBitFormat;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class NoStrShareLinkProfileTest {
@Test
public void testToObject() {
NoStrShareLinkProfile profile = NoStrShareLinkProfile.ofB32("nprofile1qqsrhuxx8l9ex335q7he0f09aej04zpazpl0ne2cgukyawd24mayt8gpp4mhxue69uhhytnc9e3k7mgpz4mhxue69uhkg6nzv9ejuumpv34kytnrdaksjlyr9p");
Assertions.assertEquals("3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d", profile.getPublicKey().getHex());
Assertions.assertEquals(2, profile.getRelays().size());
Assertions.assertEquals("wss://r.x.com", profile.getRelays().get(0));
Assertions.assertEquals("wss://djbas.sadkb.com", profile.getRelays().get(1));
}
@Test
public void testToString() {
List<String> relays = List.of("wss://r.x.com", "wss://djbas.sadkb.com");
NoStrShareLinkProfile profile = new NoStrShareLinkProfile(NoStrIdentityPublicKey.ofHex("3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d"), relays);
Assertions.assertEquals("nprofile1qqsrhuxx8l9ex335q7he0f09aej04zpazpl0ne2cgukyawd24mayt8gpp4mhxue69uhhytnc9e3k7mgpz4mhxue69uhkg6nzv9ejuumpv34kytnrdaksjlyr9p", profile.toShareLink());
}
@Test
public void testRelayUrls() {
//https://en.wikipedia.org/wiki/Internationalized_domain_name
List<String> relays = List.of("wss://仙上主天.中国", "wss://ουτοπία.δπθ.gr", "wss://ԝԝԝ.facebook.com", "wss://😉.tld");
NoStrShareLinkProfile profile = new NoStrShareLinkProfile(NoStrIdentityPublicKey.ofHex("3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d"), relays);
byte[] data = profile.getTapeDeck().chain.dataWriteArray();
String b64 = Base64.getEncoder().encodeToString(data);
System.out.println("hex_h16="+OctoBitFormat.HEX.fromBytes(data));
System.out.println("hex_ccp="+OctoBitFormat.HEX_CCP.fromBytes(data));
System.out.println("hex_lrp="+OctoBitFormat.HEX_DIPAVALI.fromBytes(data));
System.out.println("b64="+b64);
System.out.println("b32="+profile.toShareLink());
System.out.println("----------");
byte[] linkData = profile.toShareLink().getBytes();
System.out.println("ccp="+OctoBitFormat.HEX_CCP.fromBytes(linkData));
System.out.println("c6p="+Base64.getEncoder().encodeToString(linkData));
NoStrShareLinkProfile profileWire = NoStrShareLinkProfile.ofB32(profile.toShareLink());
Assertions.assertEquals(relays.get(0), profileWire.getRelays().get(0));
Assertions.assertEquals(relays.get(1), profileWire.getRelays().get(1));
Assertions.assertEquals(relays.get(2), profileWire.getRelays().get(2));
Assertions.assertEquals(relays.get(3), profileWire.getRelays().get(3));
}
}

View file

@ -0,0 +1,54 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.nx01.no2all.nostr.model.share;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import love.distributedrebirth.nx01.no2all.nostr.model.NoStrIdentityPublicKey;
import love.distributedrebirth.nx01.no2all.nostr.model.share.NoStrShareLinkPublicKey;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class NoStrShareLinkPublicKeyTest {
@Test
public void testToObject() {
NoStrIdentityPublicKey key1 = NoStrShareLinkPublicKey.ofB32("npub10elfcs4fr0l0r8af98jlmgdh9c8tcxjvz9qkw038js35mp4dma8qzvjptg").getPublicKey();
Assertions.assertEquals("7e7e9c42a91bfef19fa929e5fda1b72e0ebc1a4c1141673e2794234d86addf4e", key1.getHex());
}
@Test
public void testToString() {
NoStrShareLinkPublicKey key1 = new NoStrShareLinkPublicKey(NoStrIdentityPublicKey.ofHex("aa4fc8665f5696e33db7e1a572e3b0f5b3d615837b0f362dcb1c8068b098c7b4"));
Assertions.assertEquals("npub14f8usejl26twx0dhuxjh9cas7keav9vr0v8nvtwtrjqx3vycc76qqh9nsy", key1.toShareLink());
NoStrShareLinkPublicKey key2 = new NoStrShareLinkPublicKey(NoStrIdentityPublicKey.ofHex("3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d"));
Assertions.assertEquals("npub180cvv07tjdrrgpa0j7j7tmnyl2yr6yr7l8j4s3evf6u64th6gkwsyjh6w6", key2.toShareLink());
}
}

View file

@ -0,0 +1,52 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.nx01.no2all.nostr.model.tag;
import java.util.Optional;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import love.distributedrebirth.nx01.no2all.nostr.model.event.NoStrEventId;
import love.distributedrebirth.nx01.no2all.nostr.model.tag.NoStrTagE;
import love.distributedrebirth.nx01.no2all.nostr.nip.tag.NoStrImplTagEMarker;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class NoStrTagETest {
@Test
public void testOptionalRelayUrl() {
NoStrTagE tag1 = new NoStrTagE(new String[4]);
Assertions.assertTrue(tag1.getRelayUrl().isEmpty());
NoStrEventId eventId = NoStrEventId.ofHex("c99ba1058a872e10343820357506f546410fe5d1318eb0fbb6f352d823fa83d4");
NoStrImplTagEMarker eventMarker = NoStrImplTagEMarker.ROOT;
NoStrTagE tag2 = new NoStrTagE(eventId, Optional.empty(), Optional.of(eventMarker));
Assertions.assertEquals("[\"e\",\"c99ba1058a872e10343820357506f546410fe5d1318eb0fbb6f352d823fa83d4\",\"\",\"root\"]", tag2.toBible().toString());
}
}

View file

@ -0,0 +1,71 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.nx01.no2all.nostr.nip;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import love.distributedrebirth.nx01.no2all.nostr.nip.NoStrImplEventKindRange;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class NoStrImplEventKindRangeTest {
@Test
public void testValueOfKindValid() {
Assertions.assertEquals(NoStrImplEventKindRange.CHAT, NoStrImplEventKindRange.valueOfKind(0));
Assertions.assertEquals(NoStrImplEventKindRange.CHAT, NoStrImplEventKindRange.valueOfKind(1));
Assertions.assertEquals(NoStrImplEventKindRange.CHAT, NoStrImplEventKindRange.valueOfKind(999));
Assertions.assertEquals(NoStrImplEventKindRange.REGULAR, NoStrImplEventKindRange.valueOfKind(1000));
Assertions.assertEquals(NoStrImplEventKindRange.REGULAR, NoStrImplEventKindRange.valueOfKind(1001));
Assertions.assertEquals(NoStrImplEventKindRange.REGULAR, NoStrImplEventKindRange.valueOfKind(9999));
Assertions.assertEquals(NoStrImplEventKindRange.REGULAR_REPL, NoStrImplEventKindRange.valueOfKind(10000));
Assertions.assertEquals(NoStrImplEventKindRange.REGULAR_REPL, NoStrImplEventKindRange.valueOfKind(10001));
Assertions.assertEquals(NoStrImplEventKindRange.REGULAR_REPL, NoStrImplEventKindRange.valueOfKind(19999));
Assertions.assertEquals(NoStrImplEventKindRange.EPHEMERAL, NoStrImplEventKindRange.valueOfKind(20000));
Assertions.assertEquals(NoStrImplEventKindRange.EPHEMERAL, NoStrImplEventKindRange.valueOfKind(20001));
Assertions.assertEquals(NoStrImplEventKindRange.EPHEMERAL, NoStrImplEventKindRange.valueOfKind(29999));
Assertions.assertEquals(NoStrImplEventKindRange.PARAM_REPL, NoStrImplEventKindRange.valueOfKind(30000));
Assertions.assertEquals(NoStrImplEventKindRange.PARAM_REPL, NoStrImplEventKindRange.valueOfKind(30001));
Assertions.assertEquals(NoStrImplEventKindRange.PARAM_REPL, NoStrImplEventKindRange.valueOfKind(39999));
}
@Test
public void testValueOfKindUnknown() {
Assertions.assertEquals(NoStrImplEventKindRange.UNKNOWN, NoStrImplEventKindRange.valueOfKind(40000));
Assertions.assertEquals(NoStrImplEventKindRange.UNKNOWN, NoStrImplEventKindRange.valueOfKind(40001));
Assertions.assertEquals(NoStrImplEventKindRange.UNKNOWN, NoStrImplEventKindRange.valueOfKind(49999));
Assertions.assertEquals(NoStrImplEventKindRange.UNKNOWN, NoStrImplEventKindRange.valueOfKind(-1));
Assertions.assertEquals(NoStrImplEventKindRange.UNKNOWN, NoStrImplEventKindRange.valueOfKind(-2));
}
}

View file

@ -0,0 +1,55 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.nx01.no2all.nostr.nip;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import love.distributedrebirth.nx01.no2all.nostr.nip.NoStrImpl;
import love.distributedrebirth.nx01.no2all.nostr.nip.NoStrImplEventKind;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class NoStrImplEventKindTest {
@Test
public void testValueOfKindValid() {
Assertions.assertEquals(NoStrImplEventKind.METADATA, NoStrImplEventKind.valueOfKind(0));
Assertions.assertEquals(NoStrImplEventKind.TEXT_NOTE, NoStrImplEventKind.valueOfKind(1));
Assertions.assertEquals(NoStrImplEventKind.CHANNEL_SEND_MSG, NoStrImplEventKind.valueOfKind(42));
Assertions.assertEquals(NoStrImplEventKind.LONG_FORM_CONTENT, NoStrImplEventKind.valueOfKind(30023));
}
@Test
public void testValueOfKindFeature() {
Assertions.assertEquals(NoStrImpl.NIP_1_BASE_PROTOCOL, NoStrImplEventKind.valueOfKind(0).getNip());
Assertions.assertEquals(NoStrImpl.NIP_1_BASE_PROTOCOL, NoStrImplEventKind.valueOfKind(1).getNip());
Assertions.assertEquals(NoStrImpl.NIP_28_PUBLIC_CHAT, NoStrImplEventKind.valueOfKind(42).getNip());
Assertions.assertEquals(NoStrImpl.NIP_23_LONG_FORM_CONTENT, NoStrImplEventKind.valueOfKind(30023).getNip());
}
}

View file

@ -0,0 +1,65 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.nx01.no2all.nostr.nip;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import love.distributedrebirth.nx01.no2all.nostr.nip.NoStrImplMessageOkReason;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class NoStrImplMessageOkReasonTest {
@Test
public void testValueOfPrefixDefault() {
Assertions.assertEquals(NoStrImplMessageOkReason.DEFAULT, NoStrImplMessageOkReason.valueOfPrefix(""));
Assertions.assertEquals(NoStrImplMessageOkReason.DEFAULT, NoStrImplMessageOkReason.valueOfPrefix("foo"));
Assertions.assertEquals(NoStrImplMessageOkReason.DEFAULT, NoStrImplMessageOkReason.valueOfPrefix("bar"));
}
@Test
public void testValueOfPrefixValid() {
Assertions.assertEquals(NoStrImplMessageOkReason.BLOCKED, NoStrImplMessageOkReason.valueOfPrefix("blocked: junit"));
Assertions.assertEquals(NoStrImplMessageOkReason.INVALID, NoStrImplMessageOkReason.valueOfPrefix("invalid: junit"));
Assertions.assertEquals(NoStrImplMessageOkReason.POW, NoStrImplMessageOkReason.valueOfPrefix("pow: junit"));
Assertions.assertEquals(NoStrImplMessageOkReason.RATE_LIMITED, NoStrImplMessageOkReason.valueOfPrefix("rate-limited: junit"));
Assertions.assertEquals(NoStrImplMessageOkReason.ERROR, NoStrImplMessageOkReason.valueOfPrefix("error: junit"));
}
@Test
public void testFormatDefault() {
Assertions.assertEquals("junit", NoStrImplMessageOkReason.DEFAULT.format("junit"));
Assertions.assertEquals("error: junit", NoStrImplMessageOkReason.DEFAULT.format("error: junit"));
}
@Test
public void testFormatError() {
Assertions.assertEquals("error: junit", NoStrImplMessageOkReason.ERROR.format("junit"));
}
}

View file

@ -0,0 +1,61 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.nx01.no2all.nostr.nip;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import love.distributedrebirth.nx01.no2all.nostr.nip.NoStrImpl;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class NoStrImplTest {
@Test
public void testNumber() {
Assertions.assertEquals(0, NoStrImpl.NIP_0_UNKNOWN.getNumber());
Assertions.assertEquals(9, NoStrImpl.NIP_9_EVENT_DELETION.getNumber());
Assertions.assertEquals(10, NoStrImpl.NIP_10_CORRECT_BASE_TAGS.getNumber());
Assertions.assertEquals(33, NoStrImpl.NIP_33_PARA_REPLACEABLE_EVENTS.getNumber());
Assertions.assertEquals(94, NoStrImpl.NIP_94_FILE_METADATA.getNumber());
}
@Test
public void testValueOfNIP() {
Assertions.assertEquals(NoStrImpl.NIP_0_UNKNOWN, NoStrImpl.valueOfNIP(0));
Assertions.assertEquals(NoStrImpl.NIP_1_BASE_PROTOCOL, NoStrImpl.valueOfNIP(1));
}
@Test
public void testValueOfNIPValid() {
Assertions.assertTrue(NoStrImpl.valueOfNIPValid(0));
Assertions.assertTrue(NoStrImpl.valueOfNIPValid(13));
Assertions.assertFalse(NoStrImpl.valueOfNIPValid(-1));
Assertions.assertFalse(NoStrImpl.valueOfNIPValid(666));
}
}

View file

@ -0,0 +1,46 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.nx01.no2all.nostr.nip.tag;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import love.distributedrebirth.nx01.no2all.nostr.nip.tag.NoStrImplTagA;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class NoStrImplTagATest {
@Test
public void testSplitting() {
String test = "8:<pubkey>:<d-identifier>";
Assertions.assertEquals(8, NoStrImplTagA.splitToKind(test));
Assertions.assertEquals("<pubkey>", NoStrImplTagA.splitToPublicKey(test));
Assertions.assertEquals("<d-identifier>", NoStrImplTagA.splitToParameter(test));
}
}

View file

@ -0,0 +1,70 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.nx01.no2all.nostr.nip.tag;
import java.util.Optional;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import love.distributedrebirth.nx01.no2all.nostr.nip.tag.NoStrImplTagIClaim;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class NoStrImplTagIClaimTest {
private static final String TEST_FOOBAR = "foobar:junit";
private static final String TEST_GITHUB = "github:semisol";
private static final String TEST_TWITTER = "twitter:semisol_public";
private static final String TEST_MASTODON = "mastodon:bitcoinhackers.org/@semisol";
private static final String TEST_TELEGRAM = "telegram:1087295469";
@Test
public void testValueOfPrefix() {
Assertions.assertEquals(Optional.empty(), NoStrImplTagIClaim.valueOfPlatformIdentity(TEST_FOOBAR));
Assertions.assertEquals(NoStrImplTagIClaim.GITHUB, NoStrImplTagIClaim.valueOfPlatformIdentity(TEST_GITHUB).get());
Assertions.assertEquals(NoStrImplTagIClaim.TWITTER, NoStrImplTagIClaim.valueOfPlatformIdentity(TEST_TWITTER).get());
Assertions.assertEquals(NoStrImplTagIClaim.MASTODON, NoStrImplTagIClaim.valueOfPlatformIdentity(TEST_MASTODON).get());
Assertions.assertEquals(NoStrImplTagIClaim.TELEGRAM, NoStrImplTagIClaim.valueOfPlatformIdentity(TEST_TELEGRAM).get());
}
@Test
public void testSplitToIdentity() {
Assertions.assertEquals("junit", NoStrImplTagIClaim.splitFromPlatformIdentity(TEST_FOOBAR));
Assertions.assertEquals("semisol", NoStrImplTagIClaim.splitFromPlatformIdentity(TEST_GITHUB));
}
@Test
public void testSplitToIdentityInvalid() {
Assertions.assertEquals("", NoStrImplTagIClaim.splitFromPlatformIdentity(""));
Assertions.assertEquals("123", NoStrImplTagIClaim.splitFromPlatformIdentity("123"));
Assertions.assertEquals("", NoStrImplTagIClaim.splitFromPlatformIdentity("123:"));
Assertions.assertEquals("456", NoStrImplTagIClaim.splitFromPlatformIdentity("123:456"));
}
}

View file

@ -0,0 +1,9 @@
{
"content": "直んないわ。まあええか",
"created_at": 1686199583,
"id": "fc7f200c5bed175702bd06c7ca5dba90d3497e827350b42fc99c3a4fa276a712",
"kind": 1,
"pubkey": "8c59239319637f97e007dad0d681e65ce35b1ace333b629e2d33f9465c132608",
"sig": "9584afd231c52fcbcec6ce668a2cc4b6dc9b4d9da20510dcb9005c6844679b4844edb7a2e1e0591958b0295241567c774dbf7d39a73932877542de1a5f963f4b",
"tags": []
}

View file

@ -0,0 +1,81 @@
{
"content": "Arhythmia is an issue you should pay attention to...dead. #[9] #[10] #[11] #[12] #[13] #[14]",
"created_at": 1685743927,
"id": "000c5b8f354d200abd7dc0bc81bd35153aebe72824c23e834db5feb83591c20d",
"kind": 1,
"pubkey": "2ef93f01cd2493e04235a6b87b10d3c4a74e2a7eb7c3caf168268f6af73314b5",
"sig": "5aeeba7e11c4e32c42c219ff7286319e297ff997e2f683c588be5b78d946c6ebb8124e192bc0e9ace580f25b906ebaecb70adee1329a4b53ed4946fbac521076",
"tags": [
[
"e",
"d54e918e87b55253315df49cc44e60ca551b9124c2a3dc1b4d68c57e13ba8422",
"",
"reply"
],
[
"p",
"df0aed92dff00d4ffeda2f4cd88d967dc576b5549400b92afb98a419aa06e6f5"
],
[
"client",
"more-speech - 2023-05-23T09:23"
],
[
"p",
"52b4a076bcbbbdc3a1aefa3735816cf74993b1b8db202b01c883c58be7fad8bd"
],
[
"p",
"8fb140b4e8ddef97ce4b821d247278a1a4353362623f64021484b372f948000c"
],
[
"p",
"32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245"
],
[
"p",
"3f770d65d3a764a9c5cb503ae123e62ec7598ad035d836e2a810f3877a745b24"
],
[
"p",
"c48e29f04b482cc01ca1f9ef8c86ef8318c059e0e9353235162f080f26e14c11"
],
[
"p",
"bd1e19980e2c91e6dc657e92c25762ca882eb9272d2579e221f037f93788de91"
],
[
"p",
"3f770d65d3a764a9c5cb503ae123e62ec7598ad035d836e2a810f3877a745b24"
],
[
"p",
"32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245"
],
[
"p",
"52b4a076bcbbbdc3a1aefa3735816cf74993b1b8db202b01c883c58be7fad8bd"
],
[
"p",
"8fb140b4e8ddef97ce4b821d247278a1a4353362623f64021484b372f948000c"
],
[
"p",
"c48e29f04b482cc01ca1f9ef8c86ef8318c059e0e9353235162f080f26e14c11"
],
[
"p",
"bd1e19980e2c91e6dc657e92c25762ca882eb9272d2579e221f037f93788de91"
],
[
"nonce",
"800",
"12"
]
],
"seenOn": [
"wss://relay.damus.io/",
"wss://nostr.wine/"
]
}

View file

@ -0,0 +1,51 @@
{
"content": "Supreme Court Justice Louis Brandeis advised, in his famous Whitney v. California opinion in 1927, \"If there be time to expose through discussion the falsehood and fallacies, to avert the evil by the processes of education, the remedy to be applied is more speech, not enforced silence.\"\n\nFrom: elidy<-mazin at 06/04/23 12:52:05 on wss://relay.damus.io\nCC: #[4]\nCC: #[5]\n>---------------\n>I wonder whats the story behind the name more-speech #[6]",
"created_at": 1685973097,
"id": "00051b7a0388402920bb577c6755ea8fc154861490834937f5741d6c6f596204",
"kind": 1,
"pubkey": "2ef93f01cd2493e04235a6b87b10d3c4a74e2a7eb7c3caf168268f6af73314b5",
"sig": "a219b7d632129b8bbba94ed1d81aa8bef9297be9bd4d59bae826a865d47c3973dccda635665ae3cec18d8003aaa75f87326a8df3efbc9c7ac35617628829c919",
"tags": [
[
"e",
"56b37f3968849924859f91ed3d049587cb723745aaed6502a6a1bf1e3a671696",
"",
"root"
],
[
"e",
"8dad1493450b4c26d365bdc0946a7e7730efaa41f13a544b16664d33353f1425",
"",
"reply"
],
[
"p",
"efa6abd09142caf23dfb70ed3b9bd549042901caa66f686259a1cc55a4970369"
],
[
"client",
"more-speech - 2023-05-23T09:23"
],
[
"p",
"6e468422dfb74a5738702a8823b9b28168abab8655faacb6853cd0ee15deee93"
],
[
"p",
"2ef93f01cd2493e04235a6b87b10d3c4a74e2a7eb7c3caf168268f6af73314b5"
],
[
"p",
"2ef93f01cd2493e04235a6b87b10d3c4a74e2a7eb7c3caf168268f6af73314b5"
],
[
"nonce",
"3405",
"12"
]
],
"seenOn": [
"wss://relay.damus.io/",
"wss://nostr.wine/"
]
}

View file

@ -0,0 +1,22 @@
{"name":"eden.nostr.land",
"description":"Eden Nostr Land - Toronto 1-01",
"pubkey":"00000000827ffaa94bfea288c3dfce4422c794fbb96625b6b31e9049f729d700",
"contact":"me@ricardocabral.io",
"supported_nips":[1,2,4,9,11,12,15,16,20,22,26,28,33,40],
"supported_nip_extensions":["11a"],
"software":"git+https://github.com/Cameri/nostream.git",
"version":"1.22.6",
"limitation":{"max_message_length":1048576,
"max_subscriptions":10,
"max_filters":2500,
"max_limit":5000,
"max_subid_length":256,
"min_prefix":4,
"max_event_tags":2500,
"max_content_length":65536,
"min_pow_difficulty":0,
"auth_required":false,
"payment_required":true},
"payments_url":"https://eden.nostr.land/invoices",
"fees":{"admission":[{"amount":5000000,"unit":"msats"}],
"publication":[]}}