@ -305,7 +305,7 @@ fileprivate extension LibSessionUtilSpec {
// E m p t y c o n t a c t s s h o u l d n ' t h a v e a n e x i s t i n g c o n t a c t
let definitelyRealId : String = " 050000000000000000000000000000000000000000000000000000000000000000 "
var cDefinitelyRealId : [ CChar ] = definitelyRealId . c Array. nullTerminated ( )
var cDefinitelyRealId : [ CChar ] = definitelyRealId . c String( using : . utf8 ) !
let contactPtr : UnsafeMutablePointer < contacts_contact > ? = nil
expect ( contacts_get ( conf , contactPtr , & cDefinitelyRealId ) ) . to ( beFalse ( ) )
@ -374,7 +374,7 @@ fileprivate extension LibSessionUtilSpec {
// P r e t e n d w e u p l o a d e d i t
let fakeHash1 : String = " fakehash1 "
var cFakeHash1 : [ CChar ] = fakeHash1 . c Array. nullTerminated ( )
var cFakeHash1 : [ CChar ] = fakeHash1 . c String( using : . utf8 ) !
config_confirm_pushed ( conf , pushData2 . pointee . seqno , & cFakeHash1 )
expect ( config_needs_push ( conf ) ) . to ( beFalse ( ) )
expect ( config_needs_dump ( conf ) ) . to ( beTrue ( ) )
@ -415,7 +415,7 @@ fileprivate extension LibSessionUtilSpec {
expect ( contact4 . created ) . to ( equal ( createdTs ) )
let anotherId : String = " 051111111111111111111111111111111111111111111111111111111111111111 "
var cAnotherId : [ CChar ] = anotherId . c Array. nullTerminated ( )
var cAnotherId : [ CChar ] = anotherId . c String( using : . utf8 ) !
var contact5 : contacts_contact = contacts_contact ( )
expect ( contacts_get_or_construct ( conf2 , & contact5 , & cAnotherId ) ) . to ( beTrue ( ) )
expect ( String ( libSessionVal : contact5 . name ) ) . to ( beEmpty ( ) )
@ -435,8 +435,8 @@ fileprivate extension LibSessionUtilSpec {
// C h e c k t h e m e r g i n g
let fakeHash2 : String = " fakehash2 "
var cFakeHash2 : [ CChar ] = fakeHash2 . c Array. nullTerminated ( )
var mergeHashes : [ UnsafePointer < CChar > ? ] = [cFakeHash2 ] . unsafeCopy ( )
var cFakeHash2 : [ CChar ] = fakeHash2 . c String( using : . utf8 ) !
var mergeHashes : [ UnsafePointer < CChar > ? ] = (( try ? [cFakeHash2 ] . unsafeCopy CStringArray ( ) ) ? ? [ ] )
var mergeData : [ UnsafePointer < UInt8 > ? ] = [ UnsafePointer ( pushData4 . pointee . config ) ]
var mergeSize : [ Int ] = [ pushData4 . pointee . config_len ]
let mergedHashes : UnsafeMutablePointer < config_string_list > ? = config_merge ( conf , & mergeHashes , & mergeData , & mergeSize , 1 )
@ -481,7 +481,7 @@ fileprivate extension LibSessionUtilSpec {
// C l i e n t 2 a d d s a n e w f r i e n d :
let thirdId : String = " 052222222222222222222222222222222222222222222222222222222222222222 "
var cThirdId : [ CChar ] = thirdId . c Array. nullTerminated ( )
var cThirdId : [ CChar ] = thirdId . c String( using : . utf8 ) !
var contact7 : contacts_contact = contacts_contact ( )
expect ( contacts_get_or_construct ( conf2 , & contact7 , & cThirdId ) ) . to ( beTrue ( ) )
contact7 . nickname = " Nickname 3 " . toLibSession ( )
@ -509,13 +509,13 @@ fileprivate extension LibSessionUtilSpec {
. to ( equal ( [ fakeHash2 ] ) )
let fakeHash3a : String = " fakehash3a "
var cFakeHash3a : [ CChar ] = fakeHash3a . c Array. nullTerminated ( )
var cFakeHash3a : [ CChar ] = fakeHash3a . c String( using : . utf8 ) !
let fakeHash3b : String = " fakehash3b "
var cFakeHash3b : [ CChar ] = fakeHash3b . c Array. nullTerminated ( )
var cFakeHash3b : [ CChar ] = fakeHash3b . c String( using : . utf8 ) !
config_confirm_pushed ( conf , pushData6 . pointee . seqno , & cFakeHash3a )
config_confirm_pushed ( conf2 , pushData7 . pointee . seqno , & cFakeHash3b )
var mergeHashes2 : [ UnsafePointer < CChar > ? ] = [cFakeHash3b ] . unsafeCopy ( )
var mergeHashes2 : [ UnsafePointer < CChar > ? ] = (( try ? [cFakeHash3b ] . unsafeCopy CStringArray ( ) ) ? ? [ ] )
var mergeData2 : [ UnsafePointer < UInt8 > ? ] = [ UnsafePointer ( pushData7 . pointee . config ) ]
var mergeSize2 : [ Int ] = [ pushData7 . pointee . config_len ]
let mergedHashes2 : UnsafeMutablePointer < config_string_list > ? = config_merge ( conf , & mergeHashes2 , & mergeData2 , & mergeSize2 , 1 )
@ -526,7 +526,7 @@ fileprivate extension LibSessionUtilSpec {
mergedHashes2 ? . deallocate ( )
pushData7 . deallocate ( )
var mergeHashes3 : [ UnsafePointer < CChar > ? ] = [cFakeHash3a ] . unsafeCopy ( )
var mergeHashes3 : [ UnsafePointer < CChar > ? ] = (( try ? [cFakeHash3a ] . unsafeCopy CStringArray ( ) ) ? ? [ ] )
var mergeData3 : [ UnsafePointer < UInt8 > ? ] = [ UnsafePointer ( pushData6 . pointee . config ) ]
var mergeSize3 : [ Int ] = [ pushData6 . pointee . config_len ]
let mergedHashes3 : UnsafeMutablePointer < config_string_list > ? = config_merge ( conf2 , & mergeHashes3 , & mergeData3 , & mergeSize3 , 1 )
@ -552,7 +552,7 @@ fileprivate extension LibSessionUtilSpec {
. to ( equal ( [ fakeHash3a , fakeHash3b ] ) )
let fakeHash4 : String = " fakeHash4 "
var cFakeHash4 : [ CChar ] = fakeHash4 . c Array. nullTerminated ( )
var cFakeHash4 : [ CChar ] = fakeHash4 . c String( using : . utf8 ) !
config_confirm_pushed ( conf , pushData8 . pointee . seqno , & cFakeHash4 )
config_confirm_pushed ( conf2 , pushData9 . pointee . seqno , & cFakeHash4 )
pushData8 . deallocate ( )
@ -594,7 +594,7 @@ fileprivate extension LibSessionUtilSpec {
) throws -> contacts_contact {
let postPrefixId : String = " 05 \( rand . nextBytes ( count : 32 ) . toHexString ( ) ) "
let sessionId : String = ( " 05 \( index ) a " + postPrefixId . suffix ( postPrefixId . count - " 05 \( index ) a " . count ) )
var cSessionId : [ CChar ] = sessionId . c Array. nullTerminated ( )
var cSessionId : [ CChar ] = sessionId . c String( using : . utf8 ) !
var contact : contacts_contact = contacts_contact ( )
guard contacts_get_or_construct ( conf , & contact , & cSessionId ) else {
@ -717,7 +717,7 @@ fileprivate extension LibSessionUtilSpec {
let pushData2 : UnsafeMutablePointer < config_push_data > = config_push ( conf )
expect ( pushData2 . pointee . seqno ) . to ( equal ( 1 ) )
let expPush1Encrypted : [ UInt8 ] = Data ( hex : [
let expPush1Encrypted : [ UInt8 ] = Array ( Data ( hex : [
" 9693a69686da3055f1ecdfb239c3bf8e746951a36d888c2fb7c02e856a5c2091b24e39a7e1af828f " ,
" 1fa09fe8bf7d274afde0a0847ba143c43ffb8722301b5ae32e2f078b9a5e19097403336e50b18c84 " ,
" aade446cd2823b011f97d6ad2116a53feb814efecc086bc172d31f4214b4d7c630b63bbe575b0868 " ,
@ -725,7 +725,7 @@ fileprivate extension LibSessionUtilSpec {
" e7486ccde24416a7fd4a8ba5fa73899c65f4276dfaddd5b2100adcf0f793104fb235b31ce32ec656 " ,
" 056009a9ebf58d45d7d696b74e0c7ff0499c4d23204976f19561dc0dba6dc53a2497d28ce03498ea " ,
" 49bf122762d7bc1d6d9c02f6d54f8384 "
] . joined ( ) ) .bytes
] . joined ( ) ) )
// W e h a v e n ' t d u m p e d , s o s t i l l n e e d t o d u m p :
expect ( config_needs_dump ( conf ) ) . to ( beTrue ( ) )
@ -743,7 +743,7 @@ fileprivate extension LibSessionUtilSpec {
// S o n o w i m a g i n e w e g o t b a c k c o n f i r m a t i o n f r o m t h e s w a r m t h a t t h e p u s h h a s b e e n s t o r e d :
let fakeHash1 : String = " fakehash1 "
var cFakeHash1 : [ CChar ] = fakeHash1 . c Array. nullTerminated ( )
var cFakeHash1 : [ CChar ] = fakeHash1 . c String( using : . utf8 ) !
config_confirm_pushed ( conf , pushData2 . pointee . seqno , & cFakeHash1 )
pushData2 . deallocate ( )
@ -768,8 +768,8 @@ fileprivate extension LibSessionUtilSpec {
// N o w i m a g i n e w e j u s t p u l l e d d o w n t h e ` e x p _ p u s h 1 ` s t r i n g f r o m t h e s w a r m ; w e m e r g e i t i n t o
// c o n f 2 :
var mergeHashes : [ UnsafePointer < CChar > ? ] = [cFakeHash1 ] . unsafeCopy ( )
var mergeData : [ UnsafePointer < UInt8 > ? ] = [expPush1Encrypted ] . unsafeCopy ( )
var mergeHashes : [ UnsafePointer < CChar > ? ] = (( try ? [cFakeHash1 ] . unsafeCopy CStringArray ( ) ) ? ? [ ] )
var mergeData : [ UnsafePointer < UInt8 > ? ] = (( try ? [expPush1Encrypted ] . unsafeCopy UInt8Array ( ) ) ? ? [ ] )
var mergeSize : [ Int ] = [ expPush1Encrypted . count ]
let mergedHashes : UnsafeMutablePointer < config_string_list > ? = config_merge ( conf2 , & mergeHashes , & mergeData , & mergeSize , 1 )
expect ( [ String ] ( pointer : mergedHashes ? . pointee . value , count : mergedHashes ? . pointee . len ) )
@ -820,13 +820,13 @@ fileprivate extension LibSessionUtilSpec {
expect ( config_needs_push ( conf2 ) ) . to ( beTrue ( ) )
let fakeHash2 : String = " fakehash2 "
var cFakeHash2 : [ CChar ] = fakeHash2 . c Array. nullTerminated ( )
var cFakeHash2 : [ CChar ] = fakeHash2 . c String( using : . utf8 ) !
let pushData3 : UnsafeMutablePointer < config_push_data > = config_push ( conf )
expect ( pushData3 . pointee . seqno ) . to ( equal ( 2 ) ) // i n c r e m e n t e d , s i n c e w e m a d e a f i e l d c h a n g e
config_confirm_pushed ( conf , pushData3 . pointee . seqno , & cFakeHash2 )
let fakeHash3 : String = " fakehash3 "
var cFakeHash3 : [ CChar ] = fakeHash3 . c Array. nullTerminated ( )
var cFakeHash3 : [ CChar ] = fakeHash3 . c String( using : . utf8 ) !
let pushData4 : UnsafeMutablePointer < config_push_data > = config_push ( conf2 )
expect ( pushData4 . pointee . seqno ) . to ( equal ( 2 ) ) // i n c r e m e n t e d , s i n c e w e m a d e a f i e l d c h a n g e
config_confirm_pushed ( conf , pushData4 . pointee . seqno , & cFakeHash3 )
@ -852,7 +852,7 @@ fileprivate extension LibSessionUtilSpec {
// F e e d t h e n e w c o n f i g i n t o e a c h o t h e r . ( T h i s a r r a y c o u l d h o l d m u l t i p l e c o n f i g s i f w e p u l l e d
// d o w n m o r e t h a n o n e ) .
var mergeHashes2 : [ UnsafePointer < CChar > ? ] = [cFakeHash2 ] . unsafeCopy ( )
var mergeHashes2 : [ UnsafePointer < CChar > ? ] = (( try ? [cFakeHash2 ] . unsafeCopy CStringArray ( ) ) ? ? [ ] )
var mergeData2 : [ UnsafePointer < UInt8 > ? ] = [ UnsafePointer ( pushData3 . pointee . config ) ]
var mergeSize2 : [ Int ] = [ pushData3 . pointee . config_len ]
let mergedHashes2 : UnsafeMutablePointer < config_string_list > ? = config_merge ( conf2 , & mergeHashes2 , & mergeData2 , & mergeSize2 , 1 )
@ -862,7 +862,7 @@ fileprivate extension LibSessionUtilSpec {
mergedHashes2 ? . deallocate ( )
pushData3 . deallocate ( )
var mergeHashes3 : [ UnsafePointer < CChar > ? ] = [cFakeHash3 ] . unsafeCopy ( )
var mergeHashes3 : [ UnsafePointer < CChar > ? ] = (( try ? [cFakeHash3 ] . unsafeCopy CStringArray ( ) ) ? ? [ ] )
var mergeData3 : [ UnsafePointer < UInt8 > ? ] = [ UnsafePointer ( pushData4 . pointee . config ) ]
var mergeSize3 : [ Int ] = [ pushData4 . pointee . config_len ]
let mergedHashes3 : UnsafeMutablePointer < config_string_list > ? = config_merge ( conf , & mergeHashes3 , & mergeData3 , & mergeSize3 , 1 )
@ -909,9 +909,9 @@ fileprivate extension LibSessionUtilSpec {
expect ( user_profile_get_blinded_msgreqs ( conf2 ) ) . to ( equal ( 1 ) )
let fakeHash4 : String = " fakehash4 "
var cFakeHash4 : [ CChar ] = fakeHash4 . c Array. nullTerminated ( )
var cFakeHash4 : [ CChar ] = fakeHash4 . c String( using : . utf8 ) !
let fakeHash5 : String = " fakehash5 "
var cFakeHash5 : [ CChar ] = fakeHash5 . c Array. nullTerminated ( )
var cFakeHash5 : [ CChar ] = fakeHash5 . c String( using : . utf8 ) !
config_confirm_pushed ( conf , pushData5 . pointee . seqno , & cFakeHash4 )
config_confirm_pushed ( conf2 , pushData6 . pointee . seqno , & cFakeHash5 )
pushData5 . deallocate ( )
@ -967,7 +967,7 @@ fileprivate extension LibSessionUtilSpec {
// E m p t y c o n t a c t s s h o u l d n ' t h a v e a n e x i s t i n g c o n t a c t
let definitelyRealId : String = " 055000000000000000000000000000000000000000000000000000000000000000 "
var cDefinitelyRealId : [ CChar ] = definitelyRealId . c Array. nullTerminated ( )
var cDefinitelyRealId : [ CChar ] = definitelyRealId . c String( using : . utf8 ) !
var oneToOne1 : convo_info_volatile_1to1 = convo_info_volatile_1to1 ( )
expect ( convo_info_volatile_get_1to1 ( conf , & oneToOne1 , & cDefinitelyRealId ) ) . to ( beFalse ( ) )
expect ( convo_info_volatile_size ( conf ) ) . to ( equal ( 0 ) )
@ -1001,7 +1001,7 @@ fileprivate extension LibSessionUtilSpec {
expect ( config_needs_dump ( conf ) ) . to ( beTrue ( ) )
let openGroupBaseUrl : String = " http://Example.ORG:5678 "
var cOpenGroupBaseUrl : [ CChar ] = openGroupBaseUrl . c Array. nullTerminated ( )
var cOpenGroupBaseUrl : [ CChar ] = openGroupBaseUrl . c String( using : . utf8 ) !
let openGroupBaseUrlResult : String = openGroupBaseUrl . lowercased ( )
// ( " h t t p : / / E x a m p l e . O R G : 5 6 7 8 "
// . l o w e r c a s e d ( )
@ -1009,7 +1009,7 @@ fileprivate extension LibSessionUtilSpec {
// [ C C h a r ] ( r e p e a t i n g : 0 , c o u n t : ( 2 6 8 - o p e n G r o u p B a s e U r l . c o u n t ) )
// )
let openGroupRoom : String = " SudokuRoom "
var cOpenGroupRoom : [ CChar ] = openGroupRoom . c Array. nullTerminated ( )
var cOpenGroupRoom : [ CChar ] = openGroupRoom . c String( using : . utf8 ) !
let openGroupRoomResult : String = openGroupRoom . lowercased ( )
// ( " S u d o k u R o o m "
// . l o w e r c a s e d ( )
@ -1036,7 +1036,7 @@ fileprivate extension LibSessionUtilSpec {
// P r e t e n d w e u p l o a d e d i t
let fakeHash1 : String = " fakehash1 "
var cFakeHash1 : [ CChar ] = fakeHash1 . c Array. nullTerminated ( )
var cFakeHash1 : [ CChar ] = fakeHash1 . c String( using : . utf8 ) !
config_confirm_pushed ( conf , pushData1 . pointee . seqno , & cFakeHash1 )
expect ( config_needs_dump ( conf ) ) . to ( beTrue ( ) )
expect ( config_needs_push ( conf ) ) . to ( beFalse ( ) )
@ -1070,14 +1070,14 @@ fileprivate extension LibSessionUtilSpec {
community2 . unread = true
let anotherId : String = " 051111111111111111111111111111111111111111111111111111111111111111 "
var cAnotherId : [ CChar ] = anotherId . c Array. nullTerminated ( )
var cAnotherId : [ CChar ] = anotherId . c String( using : . utf8 ) !
var oneToOne5 : convo_info_volatile_1to1 = convo_info_volatile_1to1 ( )
expect ( convo_info_volatile_get_or_construct_1to1 ( conf2 , & oneToOne5 , & cAnotherId ) ) . to ( beTrue ( ) )
oneToOne5 . unread = true
convo_info_volatile_set_1to1 ( conf2 , & oneToOne5 )
let thirdId : String = " 05cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc "
var cThirdId : [ CChar ] = thirdId . c Array. nullTerminated ( )
var cThirdId : [ CChar ] = thirdId . c String( using : . utf8 ) !
var legacyGroup2 : convo_info_volatile_legacy_group = convo_info_volatile_legacy_group ( )
expect ( convo_info_volatile_get_or_construct_legacy_group ( conf2 , & legacyGroup2 , & cThirdId ) ) . to ( beTrue ( ) )
legacyGroup2 . last_read = ( nowTimestampMs - 50 )
@ -1089,8 +1089,8 @@ fileprivate extension LibSessionUtilSpec {
// C h e c k t h e m e r g i n g
let fakeHash2 : String = " fakehash2 "
var cFakeHash2 : [ CChar ] = fakeHash2 . c Array. nullTerminated ( )
var mergeHashes : [ UnsafePointer < CChar > ? ] = [cFakeHash2 ] . unsafeCopy ( )
var cFakeHash2 : [ CChar ] = fakeHash2 . c String( using : . utf8 ) !
var mergeHashes : [ UnsafePointer < CChar > ? ] = (( try ? [cFakeHash2 ] . unsafeCopy CStringArray ( ) ) ? ? [ ] )
var mergeData : [ UnsafePointer < UInt8 > ? ] = [ UnsafePointer ( pushData2 . pointee . config ) ]
var mergeSize : [ Int ] = [ pushData2 . pointee . config_len ]
let mergedHashes : UnsafeMutablePointer < config_string_list > ? = config_merge ( conf , & mergeHashes , & mergeData , & mergeSize , 1 )
@ -1141,7 +1141,7 @@ fileprivate extension LibSessionUtilSpec {
}
let fourthId : String = " 052000000000000000000000000000000000000000000000000000000000000000 "
var cFourthId : [ CChar ] = fourthId . c Array. nullTerminated ( )
var cFourthId : [ CChar ] = fourthId . c String( using : . utf8 ) !
expect ( config_needs_push ( conf ) ) . to ( beFalse ( ) )
convo_info_volatile_erase_1to1 ( conf , & cFourthId )
expect ( config_needs_push ( conf ) ) . to ( beFalse ( ) )
@ -1231,7 +1231,7 @@ fileprivate extension LibSessionUtilSpec {
// E m p t y c o n t a c t s s h o u l d n ' t h a v e a n e x i s t i n g c o n t a c t
let definitelyRealId : String = " 055000000000000000000000000000000000000000000000000000000000000000 "
var cDefinitelyRealId : [ CChar ] = definitelyRealId . c Array. nullTerminated ( )
var cDefinitelyRealId : [ CChar ] = definitelyRealId . c String( using : . utf8 ) !
let legacyGroup1 : UnsafeMutablePointer < ugroups_legacy_group_info > ? = user_groups_get_legacy_group ( conf , & cDefinitelyRealId )
expect ( legacyGroup1 ? . pointee ) . to ( beNil ( ) )
expect ( user_groups_size ( conf ) ) . to ( equal ( 0 ) )
@ -1285,7 +1285,7 @@ fileprivate extension LibSessionUtilSpec {
" 055555555555555555555555555555555555555555555555555555555555555555 " ,
" 056666666666666666666666666666666666666666666666666666666666666666 "
]
var cUsers : [ [ CChar ] ] = users . map { $0 . c Array. nullTerminated ( ) }
var cUsers : [ [ CChar ] ] = users . map { $0 . c String( using : . utf8 ) ! }
legacyGroup2 . pointee . name = " Englishmen " . toLibSession ( )
legacyGroup2 . pointee . disappearing_timer = 60
legacyGroup2 . pointee . joined_at = createdTs
@ -1348,9 +1348,9 @@ fileprivate extension LibSessionUtilSpec {
ugroups_legacy_group_free ( legacyGroup3 )
let communityPubkey : String = " 0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef "
var cCommunityPubkey : [ UInt8 ] = Data ( hex : communityPubkey ) .cArray
var cCommunityBaseUrl : [ CChar ] = " http://Example.ORG:5678 " . c Array. nullTerminated ( )
var cCommunityRoom : [ CChar ] = " SudokuRoom " . c Array. nullTerminated ( )
var cCommunityPubkey : [ UInt8 ] = Array ( Data ( hex : communityPubkey ) )
var cCommunityBaseUrl : [ CChar ] = " http://Example.ORG:5678 " . c String( using : . utf8 ) !
var cCommunityRoom : [ CChar ] = " SudokuRoom " . c String( using : . utf8 ) !
var community1 : ugroups_community_info = ugroups_community_info ( )
expect ( user_groups_get_or_construct_community ( conf , & community1 , & cCommunityBaseUrl , & cCommunityRoom , & cCommunityPubkey ) )
. to ( beTrue ( ) )
@ -1373,7 +1373,7 @@ fileprivate extension LibSessionUtilSpec {
// P r e t e n d w e u p l o a d e d i t
let fakeHash1 : String = " fakehash1 "
var cFakeHash1 : [ CChar ] = fakeHash1 . c Array. nullTerminated ( )
var cFakeHash1 : [ CChar ] = fakeHash1 . c String( using : . utf8 ) !
config_confirm_pushed ( conf , pushData2 . pointee . seqno , & cFakeHash1 )
expect ( config_needs_dump ( conf ) ) . to ( beTrue ( ) )
expect ( config_needs_push ( conf ) ) . to ( beFalse ( ) )
@ -1492,8 +1492,8 @@ fileprivate extension LibSessionUtilSpec {
] ) )
}
var cCommunity2BaseUrl : [ CChar ] = " http://example.org:5678 " . c Array. nullTerminated ( )
var cCommunity2Room : [ CChar ] = " sudokuRoom " . c Array. nullTerminated ( )
var cCommunity2BaseUrl : [ CChar ] = " http://example.org:5678 " . c String( using : . utf8 ) !
var cCommunity2Room : [ CChar ] = " sudokuRoom " . c String( using : . utf8 ) !
var community2 : ugroups_community_info = ugroups_community_info ( )
expect ( user_groups_get_community ( conf2 , & community2 , & cCommunity2BaseUrl , & cCommunity2Room ) )
. to ( beTrue ( ) )
@ -1518,7 +1518,7 @@ fileprivate extension LibSessionUtilSpec {
expect ( config_needs_dump ( conf2 ) ) . to ( beTrue ( ) )
let fakeHash2 : String = " fakehash2 "
var cFakeHash2 : [ CChar ] = fakeHash2 . c Array. nullTerminated ( )
var cFakeHash2 : [ CChar ] = fakeHash2 . c String( using : . utf8 ) !
let pushData7 : UnsafeMutablePointer < config_push_data > = config_push ( conf2 )
expect ( pushData7 . pointee . seqno ) . to ( equal ( 2 ) )
config_confirm_pushed ( conf2 , pushData7 . pointee . seqno , & cFakeHash2 )
@ -1542,7 +1542,7 @@ fileprivate extension LibSessionUtilSpec {
config_confirm_pushed ( conf2 , pushData8 . pointee . seqno , & cFakeHash2 )
expect ( config_needs_dump ( conf2 ) ) . to ( beFalse ( ) )
var mergeHashes1 : [ UnsafePointer < CChar > ? ] = [cFakeHash2 ] . unsafeCopy ( )
var mergeHashes1 : [ UnsafePointer < CChar > ? ] = (( try ? [cFakeHash2 ] . unsafeCopy CStringArray ( ) ) ? ? [ ] )
var mergeData1 : [ UnsafePointer < UInt8 > ? ] = [ UnsafePointer ( pushData8 . pointee . config ) ]
var mergeSize1 : [ Int ] = [ pushData8 . pointee . config_len ]
let mergedHashes1 : UnsafeMutablePointer < config_string_list > ? = config_merge ( conf , & mergeHashes1 , & mergeData1 , & mergeSize1 , 1 )
@ -1552,8 +1552,8 @@ fileprivate extension LibSessionUtilSpec {
mergedHashes1 ? . deallocate ( )
pushData8 . deallocate ( )
var cCommunity3BaseUrl : [ CChar ] = " http://example.org:5678 " . c Array. nullTerminated ( )
var cCommunity3Room : [ CChar ] = " SudokuRoom " . c Array. nullTerminated ( )
var cCommunity3BaseUrl : [ CChar ] = " http://example.org:5678 " . c String( using : . utf8 ) !
var cCommunity3Room : [ CChar ] = " SudokuRoom " . c String( using : . utf8 ) !
var community3 : ugroups_community_info = ugroups_community_info ( )
expect ( user_groups_get_community ( conf , & community3 , & cCommunity3BaseUrl , & cCommunity3Room ) )
. to ( beTrue ( ) )
@ -1581,12 +1581,12 @@ fileprivate extension LibSessionUtilSpec {
expect ( config_needs_push ( conf2 ) ) . to ( beTrue ( ) )
expect ( config_needs_dump ( conf2 ) ) . to ( beTrue ( ) )
var cCommunity4BaseUrl : [ CChar ] = " http://exAMple.ORG:5678 " . c Array. nullTerminated ( )
var cCommunity4Room : [ CChar ] = " sudokuROOM " . c Array. nullTerminated ( )
var cCommunity4BaseUrl : [ CChar ] = " http://exAMple.ORG:5678 " . c String( using : . utf8 ) !
var cCommunity4Room : [ CChar ] = " sudokuROOM " . c String( using : . utf8 ) !
user_groups_erase_community ( conf2 , & cCommunity4BaseUrl , & cCommunity4Room )
let fakeHash3 : String = " fakehash3 "
var cFakeHash3 : [ CChar ] = fakeHash3 . c Array. nullTerminated ( )
var cFakeHash3 : [ CChar ] = fakeHash3 . c String( using : . utf8 ) !
let pushData10 : UnsafeMutablePointer < config_push_data > = config_push ( conf2 )
config_confirm_pushed ( conf2 , pushData10 . pointee . seqno , & cFakeHash3 )
@ -1599,7 +1599,7 @@ fileprivate extension LibSessionUtilSpec {
. to ( equal ( [ fakeHash3 ] ) )
currentHashes4 ? . deallocate ( )
var mergeHashes2 : [ UnsafePointer < CChar > ? ] = [cFakeHash3 ] . unsafeCopy ( )
var mergeHashes2 : [ UnsafePointer < CChar > ? ] = (( try ? [cFakeHash3 ] . unsafeCopy CStringArray ( ) ) ? ? [ ] )
var mergeData2 : [ UnsafePointer < UInt8 > ? ] = [ UnsafePointer ( pushData10 . pointee . config ) ]
var mergeSize2 : [ Int ] = [ pushData10 . pointee . config_len ]
let mergedHashes2 : UnsafeMutablePointer < config_string_list > ? = config_merge ( conf , & mergeHashes2 , & mergeData2 , & mergeSize2 , 1 )
@ -1613,13 +1613,13 @@ fileprivate extension LibSessionUtilSpec {
expect ( user_groups_size_legacy_groups ( conf ) ) . to ( equal ( 1 ) )
var prio : Int32 = 0
var cBeanstalkBaseUrl : [ CChar ] = " http://jacksbeanstalk.org " . c Array. nullTerminated ( )
var cBeanstalkPubkey : [ UInt8 ] = Data (
var cBeanstalkBaseUrl : [ CChar ] = " http://jacksbeanstalk.org " . c String( using : . utf8 ) !
var cBeanstalkPubkey : [ UInt8 ] = Array ( Data (
hex : " 0000111122223333444455556666777788889999aaaabbbbccccddddeeeeffff "
) .cArray
) )
[ " fee " , " fi " , " fo " , " fum " ] . forEach { room in
var cRoom : [ CChar ] = room . c Array. nullTerminated ( )
var cRoom : [ CChar ] = room . c String( using : . utf8 ) !
prio += 1
var community4 : ugroups_community_info = ugroups_community_info ( )
@ -1634,7 +1634,7 @@ fileprivate extension LibSessionUtilSpec {
expect ( user_groups_size_legacy_groups ( conf ) ) . to ( equal ( 1 ) )
let fakeHash4 : String = " fakehash4 "
var cFakeHash4 : [ CChar ] = fakeHash4 . c Array. nullTerminated ( )
var cFakeHash4 : [ CChar ] = fakeHash4 . c String( using : . utf8 ) !
let pushData11 : UnsafeMutablePointer < config_push_data > = config_push ( conf )
config_confirm_pushed ( conf , pushData11 . pointee . seqno , & cFakeHash4 )
expect ( pushData11 . pointee . seqno ) . to ( equal ( 4 ) )
@ -1643,12 +1643,12 @@ fileprivate extension LibSessionUtilSpec {
// L o a d s o m e o b s o l e t e o n e s i n j u s t t o c h e c k t h a t t h e y g e t i m m e d i a t e l y o b s o l e t e d
let fakeHash10 : String = " fakehash10 "
let cFakeHash10 : [ CChar ] = fakeHash10 . c Array. nullTerminated ( )
let cFakeHash10 : [ CChar ] = fakeHash10 . c String( using : . utf8 ) !
let fakeHash11 : String = " fakehash11 "
let cFakeHash11 : [ CChar ] = fakeHash11 . c Array. nullTerminated ( )
let cFakeHash11 : [ CChar ] = fakeHash11 . c String( using : . utf8 ) !
let fakeHash12 : String = " fakehash12 "
let cFakeHash12 : [ CChar ] = fakeHash12 . c Array. nullTerminated ( )
var mergeHashes3 : [ UnsafePointer < CChar > ? ] = [cFakeHash10 , cFakeHash11 , cFakeHash12 , cFakeHash4 ] . unsafeCopy ( )
let cFakeHash12 : [ CChar ] = fakeHash12 . c String( using : . utf8 ) !
var mergeHashes3 : [ UnsafePointer < CChar > ? ] = (( try ? [cFakeHash10 , cFakeHash11 , cFakeHash12 , cFakeHash4 ] . unsafeCopy CStringArray ( ) ) ? ? [ ] )
var mergeData3 : [ UnsafePointer < UInt8 > ? ] = [
UnsafePointer ( pushData10 . pointee . config ) ,
UnsafePointer ( pushData2 . pointee . config ) ,