WIP - testSpendMinedSpendThatExpiresOnActivation
This commit is contained in:
parent
4d77455033
commit
71940c8d40
|
@ -173,7 +173,87 @@ class NetworkUpgradeTests: XCTestCase {
|
|||
|
||||
*/
|
||||
func testSpendMinedSpendThatExpiresOnActivation() throws {
|
||||
XCTFail()
|
||||
try FakeChainBuilder.buildChain(darksideWallet: coordinator.service, networkActivationHeight: activationHeight, length: 100)
|
||||
|
||||
let firstSyncExpectation = XCTestExpectation(description: "first sync")
|
||||
|
||||
try coordinator.applyStaged(blockheight: activationHeight - ZcashSDK.EXPIRY_OFFSET)
|
||||
sleep(3)
|
||||
|
||||
try coordinator.sync(completion: { (synchronizer) in
|
||||
|
||||
firstSyncExpectation.fulfill()
|
||||
|
||||
}, error: self.handleError)
|
||||
|
||||
wait(for: [firstSyncExpectation], timeout: 10)
|
||||
let verifiedBalance = coordinator.synchronizer.initializer.getVerifiedBalance()
|
||||
XCTAssertTrue(verifiedBalance > ZcashSDK.MINERS_FEE_ZATOSHI)
|
||||
|
||||
|
||||
|
||||
let sendExpectation = XCTestExpectation(description: "send expectation")
|
||||
var p: PendingTransactionEntity? = nil
|
||||
let spendAmount: Int64 = 10000
|
||||
/*
|
||||
send transaction to recipient address
|
||||
*/
|
||||
coordinator.synchronizer.sendToAddress(spendingKey: self.coordinator.spendingKeys!.first!, zatoshi: spendAmount, toAddress: self.testRecipientAddress, memo: "this is a test", from: 0, resultBlock: { (result) in
|
||||
switch result {
|
||||
case .failure(let e):
|
||||
self.handleError(e)
|
||||
case .success(let pendingTx):
|
||||
p = pendingTx
|
||||
}
|
||||
sendExpectation.fulfill()
|
||||
})
|
||||
|
||||
wait(for: [sendExpectation], timeout: 11)
|
||||
|
||||
guard let pendingTx = p else {
|
||||
XCTFail("no pending transaction after sending")
|
||||
try coordinator.stop()
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
getIncomingTransaction
|
||||
*/
|
||||
guard let incomingTx = try coordinator.getIncomingTransactions()?.first else {
|
||||
XCTFail("no incoming transaction")
|
||||
try coordinator.stop()
|
||||
return
|
||||
}
|
||||
|
||||
let sentTxHeight: BlockHeight = activationHeight - 5
|
||||
|
||||
|
||||
/*
|
||||
stage transaction at sentTxHeight
|
||||
*/
|
||||
|
||||
|
||||
try coordinator.stageTransaction(incomingTx, at: sentTxHeight)
|
||||
|
||||
try coordinator.applyStaged(blockheight: activationHeight + 5)
|
||||
sleep(2)
|
||||
|
||||
let afterSendExpectation = XCTestExpectation(description: "aftersend")
|
||||
|
||||
try coordinator.sync(completion: { (synchronizer) in
|
||||
|
||||
afterSendExpectation.fulfill()
|
||||
|
||||
}, error: self.handleError)
|
||||
|
||||
wait(for: [afterSendExpectation], timeout: 10)
|
||||
|
||||
guard let confirmedTx = try coordinator.synchronizer.allConfirmedTransactions(from: nil, limit: Int.max)?.first(where: { $0.rawTransactionId == pendingTx.rawTransactionId }) else {
|
||||
XCTFail("the sent transaction is not listed as a confirmed transaction")
|
||||
return
|
||||
}
|
||||
|
||||
XCTAssertEqual(confirmedTx.minedHeight, sentTxHeight)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue