Shuffle send statuses for group sends so they're not all the same.

This commit is contained in:
Greyson Parrelli 2025-09-10 10:56:29 -04:00
parent be12e336d9
commit 6de66575b7
33 changed files with 156 additions and 144 deletions

View File

@ -361,9 +361,13 @@ object Generators {
fun <T> randomizedList(items: List<T>): Generator<T> = ListGenerator(items.seededShuffled())
fun <T> single(item: T): Generator<T> = Generators.list(item)
fun <T> permutation(snapshotCount: Int = -1, init: PermutationScope.() -> Unit): Generator<T> {
fun <T> permutation(snapshotCount: Int = -1, shuffled: Boolean = false, init: PermutationScope.() -> Unit): Generator<T> {
val snapshots = permuteSingle<T> { init() }
return ListGenerator(snapshots)
return if (shuffled) {
ListGenerator(snapshots.seededShuffled())
} else {
ListGenerator(snapshots)
}
}
fun <T> merge(vararg generators: Generator<T>): Generator<T> {
@ -621,7 +625,7 @@ object Generators {
fun callLinkRootKey(): Generator<ByteArray> = CallLinkRootKeyGenerator()
fun sendStatus(recipientIdGenerator: Generator<Long>): Generator<SendStatus> {
fun sendStatus(recipientIdGenerator: Generator<Long>, shuffled: Boolean = false): Generator<SendStatus> {
val (
pendingGenerator,
sentGenerator,
@ -660,7 +664,7 @@ object Generators {
}
)
return Generators.permutation {
return Generators.permutation(shuffled = shuffled) {
frames += SendStatus(
recipientId = some(recipientIdGenerator),
timestamp = someTimestamp(),
@ -674,14 +678,22 @@ object Generators {
)
}
}
/**
* Generates a pair of generators that can be used for setting incoming/outgoing message details.
* For outgoing statuses, one will be made for each of the outgoing recipients.
*/
fun incomingOutgoingDetails(vararg outgoingRecipients: Recipient): Pair<Generator<ChatItem.IncomingMessageDetails?>, Generator<ChatItem.OutgoingMessageDetails?>> {
return incomingOutgoingDetails(shuffledStatuses = false, outgoingRecipients = outgoingRecipients)
}
/**
* Generates a pair of generators that can be used for setting incoming/outgoing message details.
* For outgoing statuses, one will be made for each of the outgoing recipients.
*/
fun incomingOutgoingDetails(shuffledStatuses: Boolean = false, vararg outgoingRecipients: Recipient): Pair<Generator<ChatItem.IncomingMessageDetails?>, Generator<ChatItem.OutgoingMessageDetails?>> {
val sendStatusGenerators = outgoingRecipients.map { outgoingRecipient ->
Generators.sendStatus(
shuffled = shuffledStatuses,
recipientIdGenerator = Generators.single(outgoingRecipient.id)
)
}

View File

@ -332,7 +332,6 @@ object StandardFrames {
)
)
val chatAlice = Frame(
chat = Chat(
id = 2,

View File

@ -23,6 +23,7 @@ object ChatItemStandardMessageGroupTextOnlyTestCase : TestCase("chat_item_standa
frames += StandardFrames.chatGroupABC
val (incomingGenerator, outgoingGenerator) = Generators.incomingOutgoingDetails(
shuffledStatuses = true,
StandardFrames.recipientAlice.recipient!!,
StandardFrames.recipientBob.recipient!!,
StandardFrames.recipientCarol.recipient!!

View File

@ -220,15 +220,15 @@ Frame {
chatItem = ChatItem {
authorId = 4
chatId = 6
dateSent = 1731426801450
dateSent = 1769072981930
incoming = IncomingMessageDetails {
dateReceived = 1811261825532
dateServerSent = 1873559150162
dateReceived = 1858961967730
dateServerSent = 1731426801450
sealedSender = true
}
standardMessage = StandardMessage {
text = Text {
body = "convenire aenean aperiri usu maluisset propriae velit netus"
body = "sadipscing ignota nonumes discere augue diam"
}
}
}

View File

@ -220,15 +220,15 @@ Frame {
chatItem = ChatItem {
authorId = 4
chatId = 6
dateSent = 1731426801451
dateSent = 1769072981931
incoming = IncomingMessageDetails {
dateReceived = 1811261825533
dateServerSent = 1873559150163
dateReceived = 1858961967731
dateServerSent = 1731426801451
read = true
}
standardMessage = StandardMessage {
text = Text {
body = "cum luctus delectus"
body = "class homero periculis vero quaerendum molestie"
}
}
}

View File

@ -220,27 +220,33 @@ Frame {
chatItem = ChatItem {
authorId = 1
chatId = 6
dateSent = 1731426801452
dateSent = 1769072981932
outgoing = OutgoingMessageDetails {
dateReceived = 1805256517995
dateReceived = 1758919278018
sendStatus = [
SendStatus {
pending = Pending {}
failed = Failed {
reason = FailureReason.NETWORK
}
recipientId = 4
timestamp = 1830930358412
},
SendStatus {
pending = Pending {}
recipientId = 5
sent = Sent {
sealedSender = true
}
timestamp = 1792893756508
},
SendStatus {
pending = Pending {}
recipientId = 6
skipped = Skipped {}
}
]
}
standardMessage = StandardMessage {
text = Text {
body = "laoreet labores magnis persequeris"
body = "risus aeque elaboraret invenire"
}
}
}

View File

@ -220,34 +220,35 @@ Frame {
chatItem = ChatItem {
authorId = 1
chatId = 6
dateSent = 1731426801453
dateSent = 1769072981933
outgoing = OutgoingMessageDetails {
dateReceived = 1805256517996
dateReceived = 1758919278019
sendStatus = [
SendStatus {
recipientId = 4
sent = Sent {
sealedSender = true
failed = Failed {
reason = FailureReason.IDENTITY_KEY_MISMATCH
}
timestamp = 1660152710755
recipientId = 4
},
SendStatus {
recipientId = 5
sent = Sent {
sealedSender = true
failed = Failed {
reason = FailureReason.NETWORK
}
timestamp = 1871443451884
recipientId = 5
timestamp = 1792893756508
},
SendStatus {
recipientId = 6
sent = Sent {}
timestamp = 1906134040764
timestamp = 1679431906427
viewed = Viewed {
sealedSender = true
}
}
]
}
standardMessage = StandardMessage {
text = Text {
body = "convenire aenean aperiri usu maluisset propriae velit netus"
body = "sadipscing ignota nonumes discere augue diam"
}
}
}

View File

@ -220,32 +220,34 @@ Frame {
chatItem = ChatItem {
authorId = 1
chatId = 6
dateSent = 1731426801454
dateSent = 1769072981934
outgoing = OutgoingMessageDetails {
dateReceived = 1805256517997
dateReceived = 1758919278020
sendStatus = [
SendStatus {
recipientId = 4
sent = Sent {}
timestamp = 1830930358412
},
SendStatus {
recipientId = 5
sent = Sent {}
timestamp = 1876644825915
},
SendStatus {
recipientId = 6
sent = Sent {
delivered = Delivered {
sealedSender = true
}
timestamp = 1810343294547
recipientId = 4
},
SendStatus {
failed = Failed {
reason = FailureReason.IDENTITY_KEY_MISMATCH
}
recipientId = 5
},
SendStatus {
read = Read {
sealedSender = true
}
recipientId = 6
timestamp = 1679431906427
}
]
}
standardMessage = StandardMessage {
text = Text {
body = "cum luctus delectus"
body = "class homero periculis vero quaerendum molestie"
}
}
}

View File

@ -220,31 +220,28 @@ Frame {
chatItem = ChatItem {
authorId = 1
chatId = 6
dateSent = 1731426801455
dateSent = 1769072981935
outgoing = OutgoingMessageDetails {
dateReceived = 1805256517998
dateReceived = 1758919278021
sendStatus = [
SendStatus {
delivered = Delivered {
sealedSender = true
}
pending = Pending {}
recipientId = 4
},
SendStatus {
delivered = Delivered {
sealedSender = true
}
recipientId = 5
skipped = Skipped {}
},
SendStatus {
delivered = Delivered {}
recipientId = 6
timestamp = 1796894078130
viewed = Viewed {}
}
]
}
standardMessage = StandardMessage {
text = Text {
body = "laoreet labores magnis persequeris"
body = "risus aeque elaboraret invenire"
}
}
}

View File

@ -220,32 +220,29 @@ Frame {
chatItem = ChatItem {
authorId = 1
chatId = 6
dateSent = 1731426801456
dateSent = 1769072981936
outgoing = OutgoingMessageDetails {
dateReceived = 1805256517999
dateReceived = 1758919278022
sendStatus = [
SendStatus {
delivered = Delivered {}
recipientId = 4
timestamp = 1660152710755
viewed = Viewed {}
},
SendStatus {
delivered = Delivered {}
pending = Pending {}
recipientId = 5
timestamp = 1871443451884
},
SendStatus {
delivered = Delivered {
sealedSender = true
}
recipientId = 6
timestamp = 1906134040764
sent = Sent {}
timestamp = 1796894078130
}
]
}
standardMessage = StandardMessage {
text = Text {
body = "convenire aenean aperiri usu maluisset propriae velit netus"
body = "sadipscing ignota nonumes discere augue diam"
}
}
}

View File

@ -220,34 +220,36 @@ Frame {
chatItem = ChatItem {
authorId = 1
chatId = 6
dateSent = 1731426801457
dateSent = 1769072981937
outgoing = OutgoingMessageDetails {
dateReceived = 1805256518000
dateReceived = 1758919278023
sendStatus = [
SendStatus {
read = Read {
sealedSender = true
failed = Failed {
reason = FailureReason.UNKNOWN
}
recipientId = 4
timestamp = 1830930358412
timestamp = 1660152710755
},
SendStatus {
read = Read {}
recipientId = 5
timestamp = 1876644825915
timestamp = 1762578225552
viewed = Viewed {
sealedSender = true
}
},
SendStatus {
read = Read {
delivered = Delivered {
sealedSender = true
}
recipientId = 6
timestamp = 1810343294547
timestamp = 1796894078130
}
]
}
standardMessage = StandardMessage {
text = Text {
body = "cum luctus delectus"
body = "class homero periculis vero quaerendum molestie"
}
}
}

View File

@ -220,29 +220,31 @@ Frame {
chatItem = ChatItem {
authorId = 1
chatId = 6
dateSent = 1731426801458
dateSent = 1769072981938
outgoing = OutgoingMessageDetails {
dateReceived = 1805256518001
dateReceived = 1758919278024
sendStatus = [
SendStatus {
read = Read {}
recipientId = 4
},
SendStatus {
read = Read {
delivered = Delivered {
sealedSender = true
}
recipientId = 5
},
SendStatus {
read = Read {}
failed = Failed {
reason = FailureReason.IDENTITY_KEY_MISMATCH
}
recipientId = 6
}
]
}
standardMessage = StandardMessage {
text = Text {
body = "laoreet labores magnis persequeris"
body = "risus aeque elaboraret invenire"
}
}
}

View File

@ -220,32 +220,29 @@ Frame {
chatItem = ChatItem {
authorId = 1
chatId = 6
dateSent = 1731426801459
dateSent = 1769072981939
outgoing = OutgoingMessageDetails {
dateReceived = 1805256518002
dateReceived = 1758919278025
sendStatus = [
SendStatus {
delivered = Delivered {}
recipientId = 4
timestamp = 1660152710755
viewed = Viewed {}
},
SendStatus {
recipientId = 5
timestamp = 1871443451884
viewed = Viewed {
sealedSender = true
}
sent = Sent {}
timestamp = 1762578225552
},
SendStatus {
read = Read {}
recipientId = 6
timestamp = 1906134040764
viewed = Viewed {}
}
]
}
standardMessage = StandardMessage {
text = Text {
body = "convenire aenean aperiri usu maluisset propriae velit netus"
body = "sadipscing ignota nonumes discere augue diam"
}
}
}

View File

@ -220,34 +220,34 @@ Frame {
chatItem = ChatItem {
authorId = 1
chatId = 6
dateSent = 1731426801460
dateSent = 1769072981940
outgoing = OutgoingMessageDetails {
dateReceived = 1805256518003
dateReceived = 1758919278026
sendStatus = [
SendStatus {
recipientId = 4
timestamp = 1830930358412
viewed = Viewed {
sent = Sent {
sealedSender = true
}
timestamp = 1660152710755
},
SendStatus {
delivered = Delivered {}
recipientId = 5
timestamp = 1876644825915
viewed = Viewed {}
timestamp = 1762578225552
},
SendStatus {
recipientId = 6
timestamp = 1810343294547
viewed = Viewed {
sealedSender = true
failed = Failed {
reason = FailureReason.UNKNOWN
}
recipientId = 6
timestamp = 1796894078130
}
]
}
standardMessage = StandardMessage {
text = Text {
body = "cum luctus delectus"
body = "class homero periculis vero quaerendum molestie"
}
}
}

View File

@ -220,9 +220,9 @@ Frame {
chatItem = ChatItem {
authorId = 1
chatId = 6
dateSent = 1731426801461
dateSent = 1769072981941
outgoing = OutgoingMessageDetails {
dateReceived = 1805256518004
dateReceived = 1758919278027
sendStatus = [
SendStatus {
recipientId = 4
@ -230,17 +230,18 @@ Frame {
},
SendStatus {
recipientId = 5
skipped = Skipped {}
timestamp = 1792893756508
viewed = Viewed {}
},
SendStatus {
delivered = Delivered {}
recipientId = 6
skipped = Skipped {}
}
]
}
standardMessage = StandardMessage {
text = Text {
body = "laoreet labores magnis persequeris"
body = "risus aeque elaboraret invenire"
}
}
}

View File

@ -220,36 +220,34 @@ Frame {
chatItem = ChatItem {
authorId = 1
chatId = 6
dateSent = 1731426801462
dateSent = 1769072981942
outgoing = OutgoingMessageDetails {
dateReceived = 1805256518005
dateReceived = 1758919278028
sendStatus = [
SendStatus {
failed = Failed {
reason = FailureReason.UNKNOWN
}
recipientId = 4
timestamp = 1660152710755
timestamp = 1830930358412
viewed = Viewed {
sealedSender = true
}
},
SendStatus {
failed = Failed {
reason = FailureReason.UNKNOWN
}
read = Read {}
recipientId = 5
timestamp = 1871443451884
timestamp = 1792893756508
},
SendStatus {
failed = Failed {
reason = FailureReason.UNKNOWN
}
recipientId = 6
timestamp = 1906134040764
sent = Sent {
sealedSender = true
}
timestamp = 1679431906427
}
]
}
standardMessage = StandardMessage {
text = Text {
body = "convenire aenean aperiri usu maluisset propriae velit netus"
body = "sadipscing ignota nonumes discere augue diam"
}
}
}

View File

@ -220,36 +220,33 @@ Frame {
chatItem = ChatItem {
authorId = 1
chatId = 6
dateSent = 1731426801463
dateSent = 1769072981943
outgoing = OutgoingMessageDetails {
dateReceived = 1805256518006
dateReceived = 1758919278029
sendStatus = [
SendStatus {
failed = Failed {
reason = FailureReason.NETWORK
}
recipientId = 4
sent = Sent {}
timestamp = 1830930358412
},
SendStatus {
failed = Failed {
reason = FailureReason.NETWORK
read = Read {
sealedSender = true
}
recipientId = 5
timestamp = 1876644825915
},
SendStatus {
failed = Failed {
reason = FailureReason.NETWORK
}
recipientId = 6
timestamp = 1810343294547
timestamp = 1679431906427
}
]
}
standardMessage = StandardMessage {
text = Text {
body = "cum luctus delectus"
body = "class homero periculis vero quaerendum molestie"
}
}
}

View File

@ -220,33 +220,33 @@ Frame {
chatItem = ChatItem {
authorId = 1
chatId = 6
dateSent = 1731426801464
dateSent = 1769072981944
outgoing = OutgoingMessageDetails {
dateReceived = 1805256518007
dateReceived = 1758919278030
sendStatus = [
SendStatus {
failed = Failed {
reason = FailureReason.IDENTITY_KEY_MISMATCH
read = Read {
sealedSender = true
}
recipientId = 4
timestamp = 1830930358412
},
SendStatus {
failed = Failed {
reason = FailureReason.IDENTITY_KEY_MISMATCH
reason = FailureReason.UNKNOWN
}
recipientId = 5
timestamp = 1762578225552
},
SendStatus {
failed = Failed {
reason = FailureReason.IDENTITY_KEY_MISMATCH
}
pending = Pending {}
recipientId = 6
}
]
}
standardMessage = StandardMessage {
text = Text {
body = "laoreet labores magnis persequeris"
body = "risus aeque elaboraret invenire"
}
}
}