Rust backend tests
This commit is contained in:
parent
22e8b86b2f
commit
56093730fe
|
@ -7,6 +7,7 @@
|
||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
0B45933D22C612CB002A66BA /* ZcashRustBackendTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B45933C22C612CB002A66BA /* ZcashRustBackendTests.swift */; };
|
||||||
103AFE8F228312A30074BC98 /* ZcashLightClientKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 103AFE85228312A30074BC98 /* ZcashLightClientKit.framework */; };
|
103AFE8F228312A30074BC98 /* ZcashLightClientKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 103AFE85228312A30074BC98 /* ZcashLightClientKit.framework */; };
|
||||||
103AFE94228312A30074BC98 /* ZcashLightClientKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 103AFE93228312A30074BC98 /* ZcashLightClientKitTests.swift */; };
|
103AFE94228312A30074BC98 /* ZcashLightClientKitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 103AFE93228312A30074BC98 /* ZcashLightClientKitTests.swift */; };
|
||||||
103AFE96228312A30074BC98 /* ZcashLightClientKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 103AFE88228312A30074BC98 /* ZcashLightClientKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
103AFE96228312A30074BC98 /* ZcashLightClientKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 103AFE88228312A30074BC98 /* ZcashLightClientKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
|
@ -26,6 +27,7 @@
|
||||||
/* End PBXContainerItemProxy section */
|
/* End PBXContainerItemProxy section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
|
0B45933C22C612CB002A66BA /* ZcashRustBackendTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ZcashRustBackendTests.swift; sourceTree = "<group>"; };
|
||||||
103AFE85228312A30074BC98 /* ZcashLightClientKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ZcashLightClientKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
103AFE85228312A30074BC98 /* ZcashLightClientKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ZcashLightClientKit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
103AFE88228312A30074BC98 /* ZcashLightClientKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ZcashLightClientKit.h; sourceTree = "<group>"; };
|
103AFE88228312A30074BC98 /* ZcashLightClientKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ZcashLightClientKit.h; sourceTree = "<group>"; };
|
||||||
103AFE89228312A30074BC98 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
103AFE89228312A30074BC98 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
|
@ -92,6 +94,7 @@
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
103AFE93228312A30074BC98 /* ZcashLightClientKitTests.swift */,
|
103AFE93228312A30074BC98 /* ZcashLightClientKitTests.swift */,
|
||||||
|
0B45933C22C612CB002A66BA /* ZcashRustBackendTests.swift */,
|
||||||
103AFE95228312A30074BC98 /* Info.plist */,
|
103AFE95228312A30074BC98 /* Info.plist */,
|
||||||
);
|
);
|
||||||
path = ZcashLightClientKitTests;
|
path = ZcashLightClientKitTests;
|
||||||
|
@ -254,6 +257,7 @@
|
||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
0B45933D22C612CB002A66BA /* ZcashRustBackendTests.swift in Sources */,
|
||||||
103AFE94228312A30074BC98 /* ZcashLightClientKitTests.swift in Sources */,
|
103AFE94228312A30074BC98 /* ZcashLightClientKitTests.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
//
|
||||||
|
// ZcashRustBackendTests.swift
|
||||||
|
// ZcashLightClientKitTests
|
||||||
|
//
|
||||||
|
// Created by Jack Grigg on 28/06/2019.
|
||||||
|
// Copyright © 2019 Electric Coin Company. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import XCTest
|
||||||
|
@testable import ZcashLightClientKit
|
||||||
|
|
||||||
|
class ZcashRustBackendTests: XCTestCase {
|
||||||
|
var dbData: URL? = nil
|
||||||
|
|
||||||
|
override func setUp() {
|
||||||
|
let dataDir = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true)
|
||||||
|
dbData = dataDir.appendingPathComponent("data.db")
|
||||||
|
}
|
||||||
|
|
||||||
|
override func tearDown() {
|
||||||
|
// Delete test database between runs
|
||||||
|
do {
|
||||||
|
try FileManager.default.removeItem(at: dbData!)
|
||||||
|
} catch {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func testInitAndGetAddress() {
|
||||||
|
let seed = "seed"
|
||||||
|
|
||||||
|
XCTAssert(ZcashRustBackend.initDataDb(dbData: dbData!))
|
||||||
|
XCTAssertEqual(ZcashRustBackend.getLastError(), nil)
|
||||||
|
|
||||||
|
let _ = ZcashRustBackend.initAccountsTable(dbData: dbData!, seed: Array(seed.utf8), accounts: 1)
|
||||||
|
XCTAssertEqual(ZcashRustBackend.getLastError(), nil)
|
||||||
|
|
||||||
|
let addr = ZcashRustBackend.getAddress(dbData: dbData!, account: 0)
|
||||||
|
XCTAssertEqual(ZcashRustBackend.getLastError(), nil)
|
||||||
|
XCTAssertEqual(addr, Optional("ztestsapling1meqz0cd598fw0jlq2htkuarg8gqv36fam83yxmu5mu3wgkx4khlttqhqaxvwf57urm3rqsq9t07"))
|
||||||
|
|
||||||
|
// Test invalid account
|
||||||
|
let addr2 = ZcashRustBackend.getAddress(dbData: dbData!, account: 1)
|
||||||
|
XCTAssert(ZcashRustBackend.getLastError() != nil)
|
||||||
|
XCTAssertEqual(addr2, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue