Change license to AGPL
This commit:
- Updates the `LICENSE` file
- Start every file with something like:
// Copyright YEAR_FIRST_PUBLISHED Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
---
First, I removed existing license headers with this Ruby 3.1.2 script:
require 'set'
EXTENSIONS_TO_CHECK = Set['.h', '.hpp', '.cpp', '.m', '.mm', '.pch', '.swift']
same = 0
different = 0
all_files = `git ls-files`.lines.map { |line| line.strip }
all_files.each do |relative_path|
if relative_path == 'Pods'
next
end
unless EXTENSIONS_TO_CHECK.include? File.extname(relative_path)
next
end
path = File.expand_path(relative_path)
contents = File.read(path)
new_contents = contents.sub(/\/\/\n\/\/ Copyright .*\n\/\/\n\n/, '')
if contents == new_contents
same += 1
else
different += 1
end
File.write(path, new_contents)
end
puts "updated #{different} file(s), left #{same} untouched"
I'm sure this script could be improved, but it worked well enough.
Then, I created `Scripts/lint/lint-license-headers` and ran it to auto-
fix a lot of files. This changed the mode of some files, but I think
that's actually desirable. For example,
`SignalServiceKit/src/Util/AppContext.m` previously had a mode of
`0755/-rwxr-xr-x`, and it's now `0644/-rw-r--r--`.
Then I fixed some stragglers and updated the precommit script.
See [a similar change in the Desktop app][0].
[0]: 8bfaf598af
110 lines
3.5 KiB
Swift
110 lines
3.5 KiB
Swift
//
|
|
// Copyright 2020 Signal Messenger, LLC
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
//
|
|
|
|
import Foundation
|
|
import XCTest
|
|
import SignalServiceKit
|
|
import LibSignalClient
|
|
|
|
class SessionMigrationPerfTest: PerformanceBaseTest {
|
|
static let newlyInitializedSessionStateData: Data = {
|
|
let dataURL = Bundle(for: SessionMigrationPerfTest.self).url(forResource: "newlyInitializedSessionState",
|
|
withExtension: "")!
|
|
return try! Data(contentsOf: dataURL)
|
|
}()
|
|
|
|
static func makeNewlyInitializedSessionState() -> LegacySessionState {
|
|
let result = try! NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(Self.newlyInitializedSessionStateData)
|
|
return result as! LegacySessionState
|
|
}
|
|
|
|
func makeDeepSession(depth: Int = 2000) -> LegacySessionRecord {
|
|
let session = LegacySessionRecord()!
|
|
|
|
for _ in 1...5 {
|
|
session.archiveCurrentState()
|
|
|
|
let state = Self.makeNewlyInitializedSessionState()
|
|
session.setState(state)
|
|
|
|
state.receivingChains = (1...5).map { _ in
|
|
let senderRatchetKey = Curve25519.generateKeyPair().publicKey
|
|
let chain = LegacyReceivingChain(chainKey: LegacyChainKey(data: senderRatchetKey, index: 0),
|
|
senderRatchetKey: senderRatchetKey)!
|
|
let dummyKeys = LegacyMessageKeys(cipherKey: Data(repeating: 1, count: 32),
|
|
macKey: Data(repeating: 2, count: 32),
|
|
iv: Data(repeating: 3, count: 16),
|
|
index: 0)!
|
|
chain.messageKeysList.addObjects(from: Array(repeating: dummyKeys, count: depth))
|
|
return chain
|
|
}
|
|
}
|
|
|
|
return session
|
|
}
|
|
|
|
func testSerializeDeepSession() {
|
|
let x = makeDeepSession()
|
|
measure {
|
|
_ = try! x.serializeProto()
|
|
}
|
|
}
|
|
|
|
func testDeserializeDeepSession() {
|
|
let x = makeDeepSession()
|
|
let data = try! x.serializeProto()
|
|
measure {
|
|
_ = try! LegacySessionRecord(serializedProto: data)
|
|
}
|
|
}
|
|
|
|
func testUnarchiveDeepSession() {
|
|
let x = makeDeepSession()
|
|
let data = NSKeyedArchiver.archivedData(withRootObject: x)
|
|
measure {
|
|
_ = NSKeyedUnarchiver.unarchiveObject(with: data)
|
|
}
|
|
}
|
|
|
|
func testMigrateDeepSession() {
|
|
let x = makeDeepSession()
|
|
let data = try! x.serializeProto()
|
|
measure {
|
|
_ = try! SessionRecord(bytes: data)
|
|
}
|
|
}
|
|
|
|
func testSerializeSomewhatDeepSession() {
|
|
let x = makeDeepSession(depth: 200)
|
|
measure {
|
|
_ = try! x.serializeProto()
|
|
}
|
|
}
|
|
|
|
func testDeserializeSomewhatDeepSession() {
|
|
let x = makeDeepSession(depth: 200)
|
|
let data = try! x.serializeProto()
|
|
measure {
|
|
_ = try! LegacySessionRecord(serializedProto: data)
|
|
}
|
|
}
|
|
|
|
func testUnarchiveSomewhatDeepSession() {
|
|
let x = makeDeepSession(depth: 200)
|
|
let data = NSKeyedArchiver.archivedData(withRootObject: x)
|
|
measure {
|
|
_ = NSKeyedUnarchiver.unarchiveObject(with: data)
|
|
}
|
|
}
|
|
|
|
func testMigrateSomewhatDeepSession() {
|
|
let x = makeDeepSession(depth: 200)
|
|
let data = try! x.serializeProto()
|
|
measure {
|
|
_ = try! SessionRecord(bytes: data)
|
|
}
|
|
}
|
|
}
|