2019-10-18 11:45:19 -07:00
|
|
|
//
|
|
|
|
// WalletTests.swift
|
|
|
|
// ZcashLightClientKitTests
|
|
|
|
//
|
|
|
|
// Created by Francisco Gindre on 13/09/2019.
|
|
|
|
// Copyright © 2019 Electric Coin Company. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import XCTest
|
|
|
|
@testable import ZcashLightClientKit
|
|
|
|
|
|
|
|
class WalletTests: XCTestCase {
|
|
|
|
|
|
|
|
var dbData: URL! = nil
|
|
|
|
var paramDestination: URL! = nil
|
|
|
|
var cacheData: URL! = nil
|
|
|
|
|
|
|
|
override func setUp() {
|
2019-11-04 15:18:07 -08:00
|
|
|
|
|
|
|
dbData = try! __dataDbURL()
|
|
|
|
cacheData = try! __cacheDbURL()
|
|
|
|
paramDestination = try! __documentsDirectory().appendingPathComponent("parameters")
|
2019-10-18 11:45:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
override func tearDown() {
|
|
|
|
if FileManager.default.fileExists(atPath: dbData.absoluteString) {
|
|
|
|
try! FileManager.default.trashItem(at: dbData, resultingItemURL: nil)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func testWalletInitialization() {
|
|
|
|
|
2019-12-06 04:38:47 -08:00
|
|
|
let wallet = Initializer(cacheDbURL: cacheData, dataDbURL: dbData, pendingDbURL: try! TestDbBuilder.pendingTransactionsDbURL(), endpoint: LightWalletEndpointBuilder.default, spendParamsURL: try! __spendParamsURL(), outputParamsURL: try! __outputParamsURL())
|
2019-10-18 11:45:19 -07:00
|
|
|
|
2020-01-14 14:25:14 -08:00
|
|
|
XCTAssertNoThrow(try wallet.initialize(seedProvider: SampleSeedProvider(), walletBirthdayHeight: ZcashSDK.SAPLING_ACTIVATION_HEIGHT))
|
2019-10-18 11:45:19 -07:00
|
|
|
|
|
|
|
// fileExists actually sucks, so attempting to delete the file and checking what happens is far better :)
|
|
|
|
XCTAssertNoThrow( try FileManager.default.removeItem(at: dbData!) )
|
2019-11-04 15:18:07 -08:00
|
|
|
// TODO: Initialize cacheDB on start, will be done when Synchronizer is ready and integrated
|
|
|
|
// XCTAssertNoThrow( try FileManager.default.removeItem(at: cacheData!) )
|
2019-10-18 11:45:19 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SampleSeedProvider: SeedProvider {
|
|
|
|
func seed() -> [UInt8] {
|
2020-02-26 08:54:48 -08:00
|
|
|
Array("testreferencealicetestreferencealice".utf8)
|
2019-10-18 11:45:19 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct WalletBirthdayProvider {
|
|
|
|
static var testBirthday: WalletBirthday {
|
|
|
|
WalletBirthday()
|
|
|
|
}
|
|
|
|
}
|