Massive refactoring of Quartz to:
- Define each tag in their own class. - Allow extension functions to additional responsibilities to other classes - Migrate from hardcoded tag filters in events to the Tag's parser and assemble functions. - Migrate hardcoded event.create to builders that use extension functions - Restructures threading infrastructure for NIP-10 - Decouple the event signing from the Event building functions via event templates - Create classes to represent Tags and TagArrays and use extension functions to add domain-related methods to the tag array of each nip. - Uses external functions on event template builders to better point to which functions and which tags can be used in which event kinds. - Separates Event kinds in packages inside each nip. - Improves support for NIP-89 - Correctly establishes which imeta params can be used in each nip (video, picture, files) - Decouples the iMeta builder from any nip. - Fixes mute list word and user removal when inserted from a different client. - Migrates the Account class to avoiding having to build each Event inside of it
This commit is contained in:
+1
-1
@@ -48,7 +48,7 @@ class RichTextParserBenchmark {
|
||||
assertNull(
|
||||
RichTextParser().createMediaContent(
|
||||
"https://github.com/vitorpamplona/amethyst/releases/download/v0.83.10/amethyst-googleplay-universal-v0.83.10.apk",
|
||||
EmptyTagList,
|
||||
emptyMap(),
|
||||
null,
|
||||
),
|
||||
)
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import androidx.benchmark.junit4.BenchmarkRule
|
||||
import androidx.benchmark.junit4.measureRepeated
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.vitorpamplona.quartz.CryptoUtils
|
||||
import com.vitorpamplona.quartz.nip01Core.KeyPair
|
||||
import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair
|
||||
import junit.framework.TestCase.assertNotNull
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
@@ -24,8 +24,8 @@ import androidx.benchmark.junit4.BenchmarkRule
|
||||
import androidx.benchmark.junit4.measureRepeated
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.vitorpamplona.quartz.EventFactory
|
||||
import com.vitorpamplona.quartz.nip01Core.hasValidSignature
|
||||
import com.vitorpamplona.quartz.nip01Core.jackson.EventMapper
|
||||
import com.vitorpamplona.quartz.nip01Core.verify
|
||||
import com.vitorpamplona.quartz.utils.TimeUtils
|
||||
import junit.framework.TestCase.assertTrue
|
||||
import org.junit.Rule
|
||||
@@ -60,7 +60,7 @@ class EventBenchmark {
|
||||
val event = EventMapper.fromJson(msg[2])
|
||||
benchmarkRule.measureRepeated {
|
||||
// Should pass
|
||||
assertTrue(event.hasValidSignature())
|
||||
assertTrue(event.verify())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -25,8 +25,8 @@ import androidx.benchmark.junit4.measureRepeated
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||
import com.vitorpamplona.quartz.nip01Core.generateId
|
||||
import com.vitorpamplona.quartz.nip01Core.hasCorrectIDHash
|
||||
import com.vitorpamplona.quartz.nip01Core.jackson.EventMapper
|
||||
import com.vitorpamplona.quartz.nip01Core.verifyId
|
||||
import junit.framework.TestCase.assertNotNull
|
||||
import junit.framework.TestCase.assertTrue
|
||||
import org.junit.Rule
|
||||
@@ -49,7 +49,7 @@ class EventCmdHasherBenchmark {
|
||||
|
||||
benchmarkRule.measureRepeated {
|
||||
// Should pass
|
||||
assertTrue(event.hasCorrectIDHash())
|
||||
assertTrue(event.verifyId())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class EventCmdHasherBenchmark {
|
||||
val event = Event.fromJson(largeKind1Event)
|
||||
benchmarkRule.measureRepeated {
|
||||
// Should pass
|
||||
assertTrue(event.hasCorrectIDHash())
|
||||
assertTrue(event.verifyId())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+15
-9
@@ -24,13 +24,15 @@ import androidx.benchmark.junit4.BenchmarkRule
|
||||
import androidx.benchmark.junit4.measureRepeated
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.vitorpamplona.quartz.CryptoUtils
|
||||
import com.vitorpamplona.quartz.nip01Core.KeyPair
|
||||
import com.vitorpamplona.quartz.nip01Core.checkSignature
|
||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||
import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair
|
||||
import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.people.PTag
|
||||
import com.vitorpamplona.quartz.nip17Dm.NIP17Factory
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
|
||||
import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealedRumorEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent
|
||||
import junit.framework.TestCase
|
||||
import org.junit.Assert
|
||||
import org.junit.Assert.assertTrue
|
||||
@@ -60,9 +62,11 @@ class GiftWrapBenchmark {
|
||||
var events: NIP17Factory.Result? = null
|
||||
val countDownLatch = CountDownLatch(1)
|
||||
|
||||
NIP17Factory().createMsgNIP17(
|
||||
message,
|
||||
listOf(receiver.pubKey),
|
||||
NIP17Factory().createMessageNIP17(
|
||||
ChatMessageEvent.build(
|
||||
message,
|
||||
listOf(PTag(receiver.pubKey)),
|
||||
),
|
||||
sender,
|
||||
) {
|
||||
events = it
|
||||
@@ -110,9 +114,11 @@ class GiftWrapBenchmark {
|
||||
var giftWrap: GiftWrapEvent? = null
|
||||
val countDownLatch = CountDownLatch(1)
|
||||
|
||||
NIP17Factory().createMsgNIP17(
|
||||
message,
|
||||
listOf(receiver.pubKey),
|
||||
NIP17Factory().createMessageNIP17(
|
||||
ChatMessageEvent.build(
|
||||
message,
|
||||
listOf(PTag(receiver.pubKey)),
|
||||
),
|
||||
sender,
|
||||
) {
|
||||
giftWrap = it.wraps.first()
|
||||
|
||||
+37
-33
@@ -24,17 +24,21 @@ import androidx.benchmark.junit4.BenchmarkRule
|
||||
import androidx.benchmark.junit4.measureRepeated
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.vitorpamplona.quartz.CryptoUtils
|
||||
import com.vitorpamplona.quartz.nip01Core.KeyPair
|
||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||
import com.vitorpamplona.quartz.nip01Core.hasCorrectIDHash
|
||||
import com.vitorpamplona.quartz.nip01Core.hasVerifiedSignature
|
||||
import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair
|
||||
import com.vitorpamplona.quartz.nip01Core.hexToByteArray
|
||||
import com.vitorpamplona.quartz.nip01Core.signers.NostrSigner
|
||||
import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal
|
||||
import com.vitorpamplona.quartz.nip17Dm.ChatMessageEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.Rumor
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.people.PTag
|
||||
import com.vitorpamplona.quartz.nip01Core.verifyId
|
||||
import com.vitorpamplona.quartz.nip01Core.verifySignature
|
||||
import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent
|
||||
import com.vitorpamplona.quartz.nip17Dm.messages.changeSubject
|
||||
import com.vitorpamplona.quartz.nip36SensitiveContent.contentWarning
|
||||
import com.vitorpamplona.quartz.nip57Zaps.zapraiser.zapraiser
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.rumors.Rumor
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealedRumorEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent
|
||||
import junit.framework.TestCase.assertNotNull
|
||||
import junit.framework.TestCase.assertTrue
|
||||
import org.junit.Rule
|
||||
@@ -60,18 +64,18 @@ class GiftWrapReceivingBenchmark {
|
||||
val countDownLatch = CountDownLatch(1)
|
||||
var wrap: GiftWrapEvent? = null
|
||||
|
||||
ChatMessageEvent.create(
|
||||
msg = "Hi there! This is a test message",
|
||||
to = listOf(receiver.pubKey),
|
||||
subject = "Party Tonight",
|
||||
replyTos = emptyList(),
|
||||
mentions = emptyList(),
|
||||
zapReceiver = null,
|
||||
markAsSensitive = true,
|
||||
zapRaiserAmount = 10000,
|
||||
geohash = null,
|
||||
isDraft = true,
|
||||
signer = sender,
|
||||
sender.sign(
|
||||
ChatMessageEvent.build(
|
||||
msg = "Hi there! This is a test message",
|
||||
to =
|
||||
listOf(
|
||||
PTag(receiver.pubKey),
|
||||
),
|
||||
) {
|
||||
changeSubject("Party Tonight")
|
||||
zapraiser(10000)
|
||||
contentWarning("nsfw")
|
||||
},
|
||||
) {
|
||||
SealedRumorEvent.create(
|
||||
event = it,
|
||||
@@ -100,18 +104,18 @@ class GiftWrapReceivingBenchmark {
|
||||
val countDownLatch = CountDownLatch(1)
|
||||
var seal: SealedRumorEvent? = null
|
||||
|
||||
ChatMessageEvent.create(
|
||||
msg = "Hi there! This is a test message",
|
||||
to = listOf(receiver.pubKey),
|
||||
subject = "Party Tonight",
|
||||
replyTos = emptyList(),
|
||||
mentions = emptyList(),
|
||||
zapReceiver = null,
|
||||
markAsSensitive = true,
|
||||
zapRaiserAmount = 10000,
|
||||
geohash = null,
|
||||
isDraft = true,
|
||||
signer = sender,
|
||||
sender.sign(
|
||||
ChatMessageEvent.build(
|
||||
msg = "Hi there! This is a test message",
|
||||
to =
|
||||
listOf(
|
||||
PTag(receiver.pubKey),
|
||||
),
|
||||
) {
|
||||
changeSubject("Party Tonight")
|
||||
zapraiser(10000)
|
||||
contentWarning("nsfw")
|
||||
},
|
||||
) {
|
||||
SealedRumorEvent.create(
|
||||
event = it,
|
||||
@@ -145,7 +149,7 @@ class GiftWrapReceivingBenchmark {
|
||||
|
||||
val wrap = createWrap(sender, receiver)
|
||||
|
||||
benchmarkRule.measureRepeated { wrap.hasCorrectIDHash() }
|
||||
benchmarkRule.measureRepeated { wrap.verifyId() }
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -155,7 +159,7 @@ class GiftWrapReceivingBenchmark {
|
||||
|
||||
val wrap = createWrap(sender, receiver)
|
||||
|
||||
benchmarkRule.measureRepeated { wrap.hasVerifiedSignature() }
|
||||
benchmarkRule.measureRepeated { wrap.verifySignature() }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+56
-52
@@ -23,11 +23,15 @@ package com.vitorpamplona.quartz.benchmark
|
||||
import androidx.benchmark.junit4.BenchmarkRule
|
||||
import androidx.benchmark.junit4.measureRepeated
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.vitorpamplona.quartz.nip01Core.KeyPair
|
||||
import com.vitorpamplona.quartz.nip01Core.crypto.KeyPair
|
||||
import com.vitorpamplona.quartz.nip01Core.signers.NostrSignerInternal
|
||||
import com.vitorpamplona.quartz.nip17Dm.ChatMessageEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.GiftWrapEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.SealedRumorEvent
|
||||
import com.vitorpamplona.quartz.nip01Core.tags.people.PTag
|
||||
import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent
|
||||
import com.vitorpamplona.quartz.nip17Dm.messages.changeSubject
|
||||
import com.vitorpamplona.quartz.nip36SensitiveContent.contentWarning
|
||||
import com.vitorpamplona.quartz.nip57Zaps.zapraiser.zapraiser
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.seals.SealedRumorEvent
|
||||
import com.vitorpamplona.quartz.nip59Giftwrap.wraps.GiftWrapEvent
|
||||
import junit.framework.TestCase.assertTrue
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
@@ -53,18 +57,18 @@ class GiftWrapSigningBenchmark {
|
||||
benchmarkRule.measureRepeated {
|
||||
val countDownLatch = CountDownLatch(1)
|
||||
|
||||
ChatMessageEvent.create(
|
||||
msg = "Hi there! This is a test message",
|
||||
to = listOf(receiver.pubKey),
|
||||
subject = "Party Tonight",
|
||||
replyTos = emptyList(),
|
||||
mentions = emptyList(),
|
||||
zapReceiver = null,
|
||||
markAsSensitive = true,
|
||||
zapRaiserAmount = 10000,
|
||||
geohash = null,
|
||||
isDraft = false,
|
||||
signer = sender,
|
||||
sender.sign(
|
||||
ChatMessageEvent.build(
|
||||
msg = "Hi there! This is a test message",
|
||||
to =
|
||||
listOf(
|
||||
PTag(receiver.pubKey),
|
||||
),
|
||||
) {
|
||||
changeSubject("Party Tonight")
|
||||
zapraiser(10000)
|
||||
contentWarning("nsfw")
|
||||
},
|
||||
) {
|
||||
countDownLatch.countDown()
|
||||
}
|
||||
@@ -82,18 +86,18 @@ class GiftWrapSigningBenchmark {
|
||||
|
||||
var msg: ChatMessageEvent? = null
|
||||
|
||||
ChatMessageEvent.create(
|
||||
msg = "Hi there! This is a test message",
|
||||
to = listOf(receiver.pubKey),
|
||||
subject = "Party Tonight",
|
||||
replyTos = emptyList(),
|
||||
mentions = emptyList(),
|
||||
zapReceiver = null,
|
||||
markAsSensitive = true,
|
||||
zapRaiserAmount = 10000,
|
||||
geohash = null,
|
||||
isDraft = false,
|
||||
signer = sender,
|
||||
sender.sign(
|
||||
ChatMessageEvent.build(
|
||||
msg = "Hi there! This is a test message",
|
||||
to =
|
||||
listOf(
|
||||
PTag(receiver.pubKey),
|
||||
),
|
||||
) {
|
||||
changeSubject("Party Tonight")
|
||||
zapraiser(10000)
|
||||
contentWarning("nsfw")
|
||||
},
|
||||
) {
|
||||
msg = it
|
||||
countDownLatch.countDown()
|
||||
@@ -124,18 +128,18 @@ class GiftWrapSigningBenchmark {
|
||||
|
||||
var seal: SealedRumorEvent? = null
|
||||
|
||||
ChatMessageEvent.create(
|
||||
msg = "Hi there! This is a test message",
|
||||
to = listOf(receiver.pubKey),
|
||||
subject = "Party Tonight",
|
||||
replyTos = emptyList(),
|
||||
mentions = emptyList(),
|
||||
zapReceiver = null,
|
||||
markAsSensitive = true,
|
||||
zapRaiserAmount = 10000,
|
||||
geohash = null,
|
||||
isDraft = false,
|
||||
signer = sender,
|
||||
sender.sign(
|
||||
ChatMessageEvent.build(
|
||||
msg = "Hi there! This is a test message",
|
||||
to =
|
||||
listOf(
|
||||
PTag(receiver.pubKey),
|
||||
),
|
||||
) {
|
||||
changeSubject("Party Tonight")
|
||||
zapraiser(10000)
|
||||
contentWarning("nsfw")
|
||||
},
|
||||
) {
|
||||
SealedRumorEvent.create(
|
||||
event = it,
|
||||
@@ -170,18 +174,18 @@ class GiftWrapSigningBenchmark {
|
||||
|
||||
var wrap: GiftWrapEvent? = null
|
||||
|
||||
ChatMessageEvent.create(
|
||||
msg = "Hi there! This is a test message",
|
||||
to = listOf(receiver.pubKey),
|
||||
subject = "Party Tonight",
|
||||
replyTos = emptyList(),
|
||||
mentions = emptyList(),
|
||||
zapReceiver = null,
|
||||
markAsSensitive = true,
|
||||
zapRaiserAmount = 10000,
|
||||
geohash = null,
|
||||
isDraft = false,
|
||||
signer = sender,
|
||||
sender.sign(
|
||||
ChatMessageEvent.build(
|
||||
msg = "Hi there! This is a test message",
|
||||
to =
|
||||
listOf(
|
||||
PTag(receiver.pubKey),
|
||||
),
|
||||
) {
|
||||
changeSubject("Party Tonight")
|
||||
zapraiser(10000)
|
||||
contentWarning("nsfw")
|
||||
},
|
||||
) {
|
||||
SealedRumorEvent.create(
|
||||
event = it,
|
||||
|
||||
Reference in New Issue
Block a user