Code Cleanup, test enhancements, linting changes
This commit is contained in:
parent
b72f9f1c35
commit
9a8d4c23b5
|
@ -66,10 +66,10 @@ PODS:
|
|||
- SwiftNIOFoundationCompat (< 3, >= 2.22.0)
|
||||
- SwiftNIOTLS (< 3, >= 2.22.0)
|
||||
- SwiftProtobuf (1.12.0)
|
||||
- ZcashLightClientKit (0.9.1):
|
||||
- ZcashLightClientKit (0.9.2):
|
||||
- gRPC-Swift (= 1.0.0-alpha.19)
|
||||
- SQLite.swift (~> 0.12.2)
|
||||
- ZcashLightClientKit/Tests (0.9.1):
|
||||
- ZcashLightClientKit/Tests (0.9.2):
|
||||
- gRPC-Swift (= 1.0.0-alpha.19)
|
||||
- SQLite.swift (~> 0.12.2)
|
||||
|
||||
|
@ -145,7 +145,7 @@ SPEC CHECKSUMS:
|
|||
SwiftNIOTLS: 46bb3a0ff37d6b52ae6baf5207ec3cd411da327c
|
||||
SwiftNIOTransportServices: 801923921fbecdcde1e1c1ff38e812167d01ead1
|
||||
SwiftProtobuf: 4ef85479c18ca85b5482b343df9c319c62bda699
|
||||
ZcashLightClientKit: d5a681033b3f59c59c93837232ed7890d3e07918
|
||||
ZcashLightClientKit: 56d5c41ecf19d290a2aa25437775f11285edb4fe
|
||||
|
||||
PODFILE CHECKSUM: 7d5095283dc02470f40ab06564d94076ba16d570
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = 'ZcashLightClientKit'
|
||||
s.version = '0.9.1'
|
||||
s.version = '0.9.2'
|
||||
s.summary = 'Zcash Light Client wallet SDK for iOS'
|
||||
|
||||
s.description = <<-DESC
|
||||
|
|
|
@ -137,4 +137,3 @@ public extension ConfirmedTransactionEntity {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -12,15 +12,7 @@ import Foundation
|
|||
*/
|
||||
public extension Data {
|
||||
func asZcashTransactionMemo() -> String? {
|
||||
|
||||
self.withUnsafeBytes { (rawPointer) -> String? in
|
||||
let unsafeBufferPointer = rawPointer.bindMemory(to: CChar.self)
|
||||
if let unsafePointer = unsafeBufferPointer.baseAddress, let utf8Memo = String(validatingUTF8: unsafePointer) {
|
||||
return utf8Memo.isEmpty ? nil : utf8Memo
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
String(data: self, encoding: .utf8)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -200,11 +200,11 @@ class ZcashRustBackend: ZcashRustBackendWelding {
|
|||
return zcashlc_create_to_address(dbData.0,
|
||||
dbData.1,
|
||||
account,
|
||||
extsk,
|
||||
[CChar](extsk.utf8CString),
|
||||
consensusBranchId,
|
||||
to,
|
||||
[CChar](to.utf8CString),
|
||||
value,
|
||||
memoBytes,
|
||||
[CChar](memoBytes.utf8CString),
|
||||
spendParamsPath,
|
||||
UInt(spendParamsPath.lengthOfBytes(using: .utf8)),
|
||||
outputParamsPath,
|
||||
|
|
|
@ -77,7 +77,6 @@ public class LightWalletGRPCService {
|
|||
cacheable: false)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
extension LightWalletGRPCService: LightWalletService {
|
||||
|
@ -250,4 +249,3 @@ extension LightWalletServiceError {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,6 @@ public class SDKSynchronizer: Synchronizer {
|
|||
private var transactionManager: OutboundTransactionManager
|
||||
private var transactionRepository: TransactionRepository
|
||||
|
||||
|
||||
/**
|
||||
Creates an SDKSynchronizer instance
|
||||
- Parameter initializer: a wallet Initializer object
|
||||
|
|
|
@ -338,7 +338,7 @@ class BalanceTests: XCTestCase {
|
|||
|
||||
*/
|
||||
func testVerifyChangeTransaction() throws {
|
||||
try FakeChainBuilder.buildChain(darksideWallet: coordinator.service)
|
||||
try FakeChainBuilder.buildSingleNoteChain(darksideWallet: coordinator.service)
|
||||
|
||||
try coordinator.applyStaged(blockheight: defaultLatestHeight)
|
||||
let sendExpectation = XCTestExpectation(description: "send expectation")
|
||||
|
@ -369,19 +369,21 @@ class BalanceTests: XCTestCase {
|
|||
/*
|
||||
Send
|
||||
*/
|
||||
|
||||
let memo = "shielding is fun!"
|
||||
var pendingTx: PendingTransactionEntity?
|
||||
coordinator.synchronizer.sendToAddress(spendingKey: spendingKeys, zatoshi: Int64(sendAmount), toAddress: testRecipientAddress, memo: "test memo \(self.description)", from: 0) { (sendResult) in
|
||||
switch sendResult {
|
||||
case .failure(let sendError):
|
||||
XCTFail("error sending \(sendError)")
|
||||
case .success(let tx):
|
||||
pendingTx = tx
|
||||
}
|
||||
coordinator.synchronizer.sendToAddress(spendingKey: spendingKeys, zatoshi: Int64(sendAmount), toAddress: testRecipientAddress, memo: memo, from: 0) { (sendResult) in
|
||||
DispatchQueue.main.async {
|
||||
switch sendResult {
|
||||
case .failure(let sendError):
|
||||
XCTFail("error sending \(sendError)")
|
||||
case .success(let tx):
|
||||
pendingTx = tx
|
||||
}
|
||||
|
||||
sendExpectation.fulfill()
|
||||
sendExpectation.fulfill()
|
||||
}
|
||||
}
|
||||
wait(for: [createToAddressExpectation], timeout: 11)
|
||||
wait(for: [createToAddressExpectation], timeout: 30)
|
||||
|
||||
let syncToMinedheightExpectation = XCTestExpectation(description: "sync to mined height + 1")
|
||||
|
||||
|
@ -424,6 +426,8 @@ class BalanceTests: XCTestCase {
|
|||
XCTAssertEqual(Int64(confirmedTx.value), self.sendAmount)
|
||||
XCTAssertEqual(confirmedTx.toAddress, self.testRecipientAddress)
|
||||
|
||||
XCTAssertEqual(confirmedTx.memo?.asZcashTransactionMemo(), memo)
|
||||
|
||||
guard let transactionId = confirmedTx.rawTransactionId else {
|
||||
XCTFail("no raw transaction id")
|
||||
return
|
||||
|
@ -452,7 +456,7 @@ class BalanceTests: XCTestCase {
|
|||
/*
|
||||
There’s a change note of value (previous note value - sent amount)
|
||||
*/
|
||||
XCTAssertEqual(Int64(sentNote.value) - self.sendAmount, Int64(receivedNote.value))
|
||||
XCTAssertEqual(previousVerifiedBalance - self.sendAmount - ZcashSDK.defaultFee(for: try! synchronizer.latestDownloadedHeight()), Int64(receivedNote.value))
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -22,6 +22,15 @@ class FakeChainBuilder {
|
|||
|
||||
static let testnetPostCanopyTx = "https://raw.githubusercontent.com/zcash-hackworks/darksidewalletd-test-data/master/testnet-canopy/post-activation-txs/ecaa6c03709d70aa25446a81690b18ddb11daac96a03fe4b5cfd0d89a49fb963.txt"
|
||||
|
||||
static func buildSingleNoteChain(darksideWallet: DarksideWalletService) throws {
|
||||
try darksideWallet.reset(saplingActivation: 663150)
|
||||
try darksideWallet.useDataset(from: txMainnetBlockUrl)
|
||||
|
||||
try darksideWallet.stageBlocksCreate(from: 663151, count: 100)
|
||||
|
||||
try darksideWallet.stageTransaction(from: txUrls[663174]!, at: 663174)
|
||||
|
||||
}
|
||||
static func buildChain(darksideWallet: DarksideWalletService) throws {
|
||||
try darksideWallet.reset(saplingActivation: 663150)
|
||||
try darksideWallet.useDataset(from: txMainnetBlockUrl)
|
||||
|
|
Loading…
Reference in New Issue