session-ios/_SharedTestUtilities/MockCrypto.swift
Morgan Pretty a41f1c1366 Fixed the broken tests
Cleaned up the Dependencies so that tests can run synchronously without having to custom set queues as much
Sorted out the crypto and network dependencies to avoid needing weird dependency inheritance
Fixed the flaky tests so they are no longer flaky
Fixed some unexpected JobRunner behaviours
Updated the CI config to use a local build directory for derivedData (now works with build tweaks)
2023-08-01 14:27:41 +10:00

25 lines
879 B
Swift

// Copyright © 2023 Rangeproof Pty Ltd. All rights reserved.
import Foundation
import SessionUtilitiesKit
class MockCrypto: Mock<CryptoType>, CryptoType {
func size(_ size: Crypto.Size) -> Int {
return accept(funcName: "size(\(size.id))", args: size.args) as! Int
}
func perform(_ action: Crypto.Action) throws -> Array<UInt8> {
return try accept(funcName: "perform(\(action.id))", args: action.args) as? Array<UInt8> ?? {
throw CryptoError.failedToGenerateOutput
}()
}
func verify(_ verification: Crypto.Verification) -> Bool {
return accept(funcName: "verify(\(verification.id))", args: verification.args) as! Bool
}
func generate(_ keyPairType: Crypto.KeyPairType) -> KeyPair? {
return accept(funcName: "generate(\(keyPairType.id))", args: keyPairType.args) as? KeyPair
}
}