2022-06-28 00:38:08 -07:00
|
|
|
//
|
|
|
|
// WalletEventsSnapshotTests.swift
|
|
|
|
// secantTests
|
|
|
|
//
|
|
|
|
// Created by Lukáš Korba on 27.06.2022.
|
|
|
|
//
|
|
|
|
|
|
|
|
import XCTest
|
|
|
|
@testable import secant_testnet
|
|
|
|
import ComposableArchitecture
|
2022-07-19 11:56:46 -07:00
|
|
|
import ZcashLightClientKit
|
2022-06-28 00:38:08 -07:00
|
|
|
|
|
|
|
class WalletEventsSnapshotTests: XCTestCase {
|
2022-07-08 11:27:18 -07:00
|
|
|
func testFullWalletEventsSnapshot() throws {
|
2023-02-22 05:50:59 -08:00
|
|
|
let store = WalletEventsFlowStore(
|
|
|
|
initialState: .placeHolder,
|
|
|
|
reducer: WalletEventsFlowReducer()
|
2022-07-08 11:27:18 -07:00
|
|
|
)
|
2023-02-22 05:50:59 -08:00
|
|
|
|
|
|
|
// landing wallet events screen
|
2022-07-08 11:27:18 -07:00
|
|
|
addAttachments(
|
|
|
|
name: "\(#function)_initial",
|
2023-02-22 05:50:59 -08:00
|
|
|
WalletEventsFlowView(store: store)
|
2022-07-08 11:27:18 -07:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-06-30 04:59:03 -07:00
|
|
|
func testWalletEventDetailSnapshot_sent() throws {
|
2023-02-06 00:38:34 -08:00
|
|
|
let memo = try? Memo(string:
|
|
|
|
"""
|
|
|
|
Testing some long memo so I can see many lines of text \
|
|
|
|
instead of just one. This can take some time and I'm \
|
|
|
|
bored to write all this stuff.
|
|
|
|
""")
|
|
|
|
guard let memo else {
|
|
|
|
XCTFail("testWalletEventDetailSnapshot_sent: memo is expected to be successfuly initialized")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-06-28 00:38:08 -07:00
|
|
|
let transaction = TransactionState(
|
2023-02-06 00:38:34 -08:00
|
|
|
memos: [memo],
|
2022-06-28 00:38:08 -07:00
|
|
|
minedHeight: 1_875_256,
|
|
|
|
zAddress: "t1gXqfSSQt6WfpwyuCU3Wi7sSVZ66DYQ3Po",
|
2022-07-19 11:56:46 -07:00
|
|
|
fee: Zatoshi(1_000_000),
|
2022-06-28 00:38:08 -07:00
|
|
|
id: "ff3927e1f83df9b1b0dc75540ddc59ee435eecebae914d2e6dfe8576fbedc9a8",
|
|
|
|
status: .paid(success: true),
|
|
|
|
timestamp: 1234567,
|
2022-07-19 11:56:46 -07:00
|
|
|
zecAmount: Zatoshi(25_000_000)
|
2022-06-28 00:38:08 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
let walletEvent = WalletEvent(id: transaction.id, state: .send(transaction), timestamp: transaction.timestamp)
|
|
|
|
|
2022-07-19 11:56:46 -07:00
|
|
|
let balance = WalletBalance(verified: 12_345_000, total: 12_345_000)
|
2022-06-28 00:38:08 -07:00
|
|
|
let store = HomeStore(
|
|
|
|
initialState: .init(
|
2022-11-09 01:30:40 -08:00
|
|
|
balanceBreakdownState: .placeholder,
|
2022-06-28 00:38:08 -07:00
|
|
|
profileState: .placeholder,
|
|
|
|
scanState: .placeholder,
|
2022-08-17 06:22:35 -07:00
|
|
|
sendState: .placeholder,
|
2023-03-02 06:24:32 -08:00
|
|
|
settingsState: .placeholder,
|
2023-02-13 11:32:50 -08:00
|
|
|
shieldedBalance: balance.redacted,
|
2022-07-08 07:49:31 -07:00
|
|
|
synchronizerStatusSnapshot: .default,
|
2023-03-07 09:03:37 -08:00
|
|
|
walletConfig: .default,
|
2022-08-17 06:22:35 -07:00
|
|
|
walletEventsState: .init(walletEvents: IdentifiedArrayOf(uniqueElements: [walletEvent]))
|
2022-06-28 00:38:08 -07:00
|
|
|
),
|
2022-11-09 01:30:40 -08:00
|
|
|
reducer: HomeReducer()
|
2022-06-28 00:38:08 -07:00
|
|
|
)
|
|
|
|
|
2022-12-01 06:31:30 -08:00
|
|
|
ViewStore(store).send(.walletEvents(.updateDestination(.showWalletEvent(walletEvent))))
|
2022-06-30 04:59:03 -07:00
|
|
|
let walletEventsStore = WalletEventsFlowStore(
|
|
|
|
initialState: .placeHolder,
|
2022-11-04 23:14:44 -07:00
|
|
|
reducer: WalletEventsFlowReducer()
|
2022-06-30 04:59:03 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
addAttachments(
|
|
|
|
name: "\(#function)_WalletEventDetail",
|
2022-09-22 12:20:46 -07:00
|
|
|
TransactionDetailView(transaction: transaction, store: walletEventsStore)
|
2022-06-30 04:59:03 -07:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func testWalletEventDetailSnapshot_received() throws {
|
2023-02-06 00:38:34 -08:00
|
|
|
let memo = try? Memo(string:
|
|
|
|
"""
|
|
|
|
Testing some long memo so I can see many lines of text \
|
|
|
|
instead of just one. This can take some time and I'm \
|
|
|
|
bored to write all this stuff.
|
|
|
|
""")
|
|
|
|
guard let memo else {
|
|
|
|
XCTFail("testWalletEventDetailSnapshot_received: memo is expected to be successfuly initialized")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-06-30 04:59:03 -07:00
|
|
|
let transaction = TransactionState(
|
2023-02-06 00:38:34 -08:00
|
|
|
memos: [memo],
|
2022-06-30 04:59:03 -07:00
|
|
|
minedHeight: 1_875_256,
|
|
|
|
zAddress: "t1gXqfSSQt6WfpwyuCU3Wi7sSVZ66DYQ3Po",
|
2022-07-19 11:56:46 -07:00
|
|
|
fee: Zatoshi(1_000_000),
|
2022-06-30 04:59:03 -07:00
|
|
|
id: "ff3927e1f83df9b1b0dc75540ddc59ee435eecebae914d2e6dfe8576fbedc9a8",
|
|
|
|
status: .received,
|
|
|
|
timestamp: 1234567,
|
2022-07-19 11:56:46 -07:00
|
|
|
zecAmount: Zatoshi(25_000_000)
|
2022-06-30 04:59:03 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
let walletEvent = WalletEvent(id: transaction.id, state: .send(transaction), timestamp: transaction.timestamp)
|
|
|
|
|
2022-07-19 11:56:46 -07:00
|
|
|
let balance = WalletBalance(verified: 12_345_000, total: 12_345_000)
|
2022-06-30 04:59:03 -07:00
|
|
|
let store = HomeStore(
|
|
|
|
initialState: .init(
|
2022-11-09 01:30:40 -08:00
|
|
|
balanceBreakdownState: .placeholder,
|
2022-06-30 04:59:03 -07:00
|
|
|
profileState: .placeholder,
|
|
|
|
scanState: .placeholder,
|
2022-08-17 06:22:35 -07:00
|
|
|
sendState: .placeholder,
|
2023-03-02 06:24:32 -08:00
|
|
|
settingsState: .placeholder,
|
2023-02-13 11:32:50 -08:00
|
|
|
shieldedBalance: balance.redacted,
|
2022-07-08 07:49:31 -07:00
|
|
|
synchronizerStatusSnapshot: .default,
|
2023-03-07 09:03:37 -08:00
|
|
|
walletConfig: .default,
|
2022-08-17 06:22:35 -07:00
|
|
|
walletEventsState: .init(walletEvents: IdentifiedArrayOf(uniqueElements: [walletEvent]))
|
2022-06-30 04:59:03 -07:00
|
|
|
),
|
2022-11-09 01:30:40 -08:00
|
|
|
reducer: HomeReducer()
|
2022-06-30 04:59:03 -07:00
|
|
|
)
|
|
|
|
|
2022-12-01 06:31:30 -08:00
|
|
|
ViewStore(store).send(.walletEvents(.updateDestination(.showWalletEvent(walletEvent))))
|
2022-06-30 04:59:03 -07:00
|
|
|
let walletEventsStore = WalletEventsFlowStore(
|
|
|
|
initialState: .placeHolder,
|
2022-11-04 23:14:44 -07:00
|
|
|
reducer: WalletEventsFlowReducer()
|
2022-06-30 04:59:03 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
addAttachments(
|
|
|
|
name: "\(#function)_WalletEventDetail",
|
2022-09-22 12:20:46 -07:00
|
|
|
TransactionDetailView(transaction: transaction, store: walletEventsStore)
|
2022-06-30 04:59:03 -07:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func testWalletEventDetailSnapshot_pending() throws {
|
2023-02-06 00:38:34 -08:00
|
|
|
let memo = try? Memo(string:
|
|
|
|
"""
|
|
|
|
Testing some long memo so I can see many lines of text \
|
|
|
|
instead of just one. This can take some time and I'm \
|
|
|
|
bored to write all this stuff.
|
|
|
|
""")
|
|
|
|
guard let memo else {
|
|
|
|
XCTFail("testWalletEventDetailSnapshot_pending: memo is expected to be successfuly initialized")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-06-30 04:59:03 -07:00
|
|
|
let transaction = TransactionState(
|
2023-02-06 00:38:34 -08:00
|
|
|
memos: [memo],
|
2022-06-30 04:59:03 -07:00
|
|
|
minedHeight: 1_875_256,
|
|
|
|
zAddress: "t1gXqfSSQt6WfpwyuCU3Wi7sSVZ66DYQ3Po",
|
2022-07-19 11:56:46 -07:00
|
|
|
fee: Zatoshi(1_000_000),
|
2022-06-30 04:59:03 -07:00
|
|
|
id: "ff3927e1f83df9b1b0dc75540ddc59ee435eecebae914d2e6dfe8576fbedc9a8",
|
|
|
|
status: .pending,
|
|
|
|
timestamp: 1234567,
|
2022-07-19 11:56:46 -07:00
|
|
|
zecAmount: Zatoshi(25_000_000)
|
2022-06-30 04:59:03 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
let walletEvent = WalletEvent(id: transaction.id, state: .send(transaction), timestamp: transaction.timestamp)
|
|
|
|
|
2022-07-19 11:56:46 -07:00
|
|
|
let balance = WalletBalance(verified: 12_345_000, total: 12_345_000)
|
2022-06-30 04:59:03 -07:00
|
|
|
let store = HomeStore(
|
|
|
|
initialState: .init(
|
2022-11-09 01:30:40 -08:00
|
|
|
balanceBreakdownState: .placeholder,
|
2022-06-30 04:59:03 -07:00
|
|
|
profileState: .placeholder,
|
|
|
|
scanState: .placeholder,
|
2022-08-17 06:22:35 -07:00
|
|
|
sendState: .placeholder,
|
2023-03-02 06:24:32 -08:00
|
|
|
settingsState: .placeholder,
|
2023-02-13 11:32:50 -08:00
|
|
|
shieldedBalance: balance.redacted,
|
2022-07-08 07:49:31 -07:00
|
|
|
synchronizerStatusSnapshot: .default,
|
2023-03-07 09:03:37 -08:00
|
|
|
walletConfig: .default,
|
2022-08-17 06:22:35 -07:00
|
|
|
walletEventsState: .init(walletEvents: IdentifiedArrayOf(uniqueElements: [walletEvent]))
|
2022-06-30 04:59:03 -07:00
|
|
|
),
|
2022-11-09 01:30:40 -08:00
|
|
|
reducer: HomeReducer()
|
2022-06-30 04:59:03 -07:00
|
|
|
)
|
|
|
|
|
2022-11-04 23:14:44 -07:00
|
|
|
let walletEventsState = WalletEventsFlowReducer.State(
|
2022-06-30 04:59:03 -07:00
|
|
|
requiredTransactionConfirmations: 10,
|
|
|
|
walletEvents: .placeholder
|
|
|
|
)
|
|
|
|
|
2022-12-01 06:31:30 -08:00
|
|
|
ViewStore(store).send(.walletEvents(.updateDestination(.showWalletEvent(walletEvent))))
|
2022-06-30 04:59:03 -07:00
|
|
|
let walletEventsStore = WalletEventsFlowStore(
|
|
|
|
initialState: walletEventsState,
|
2022-11-04 23:14:44 -07:00
|
|
|
reducer: WalletEventsFlowReducer()
|
2022-06-30 04:59:03 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
addAttachments(
|
|
|
|
name: "\(#function)_WalletEventDetail",
|
2022-09-22 12:20:46 -07:00
|
|
|
TransactionDetailView(transaction: transaction, store: walletEventsStore)
|
2022-06-30 04:59:03 -07:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func testWalletEventDetailSnapshot_failed() throws {
|
2023-02-06 00:38:34 -08:00
|
|
|
let memo = try? Memo(string:
|
|
|
|
"""
|
|
|
|
Testing some long memo so I can see many lines of text \
|
|
|
|
instead of just one. This can take some time and I'm \
|
|
|
|
bored to write all this stuff.
|
|
|
|
""")
|
|
|
|
guard let memo else {
|
|
|
|
XCTFail("testWalletEventDetailSnapshot_failed: memo is expected to be successfuly initialized")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2022-06-30 04:59:03 -07:00
|
|
|
let transaction = TransactionState(
|
|
|
|
errorMessage: "possible roll back",
|
2023-02-06 00:38:34 -08:00
|
|
|
memos: [memo],
|
2022-06-30 04:59:03 -07:00
|
|
|
minedHeight: 1_875_256,
|
|
|
|
zAddress: "t1gXqfSSQt6WfpwyuCU3Wi7sSVZ66DYQ3Po",
|
2022-07-19 11:56:46 -07:00
|
|
|
fee: Zatoshi(1_000_000),
|
2022-06-30 04:59:03 -07:00
|
|
|
id: "ff3927e1f83df9b1b0dc75540ddc59ee435eecebae914d2e6dfe8576fbedc9a8",
|
|
|
|
status: .failed,
|
|
|
|
timestamp: 1234567,
|
2022-07-19 11:56:46 -07:00
|
|
|
zecAmount: Zatoshi(25_000_000)
|
2022-06-30 04:59:03 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
let walletEvent = WalletEvent(id: transaction.id, state: .send(transaction), timestamp: transaction.timestamp)
|
|
|
|
|
2022-07-19 11:56:46 -07:00
|
|
|
let balance = WalletBalance(verified: 12_345_000, total: 12_345_000)
|
2022-06-30 04:59:03 -07:00
|
|
|
let store = HomeStore(
|
|
|
|
initialState: .init(
|
2022-11-09 01:30:40 -08:00
|
|
|
balanceBreakdownState: .placeholder,
|
2022-06-30 04:59:03 -07:00
|
|
|
profileState: .placeholder,
|
|
|
|
scanState: .placeholder,
|
2022-08-17 06:22:35 -07:00
|
|
|
sendState: .placeholder,
|
2023-03-02 06:24:32 -08:00
|
|
|
settingsState: .placeholder,
|
2023-02-13 11:32:50 -08:00
|
|
|
shieldedBalance: balance.redacted,
|
2022-07-08 07:49:31 -07:00
|
|
|
synchronizerStatusSnapshot: .default,
|
2023-03-07 09:03:37 -08:00
|
|
|
walletConfig: .default,
|
2022-08-17 06:22:35 -07:00
|
|
|
walletEventsState: .init(walletEvents: IdentifiedArrayOf(uniqueElements: [walletEvent]))
|
2022-06-30 04:59:03 -07:00
|
|
|
),
|
2022-11-09 01:30:40 -08:00
|
|
|
reducer: HomeReducer()
|
2022-06-30 04:59:03 -07:00
|
|
|
)
|
|
|
|
|
2022-12-01 06:31:30 -08:00
|
|
|
ViewStore(store).send(.walletEvents(.updateDestination(.showWalletEvent(walletEvent))))
|
2022-06-28 00:38:08 -07:00
|
|
|
let walletEventsStore = WalletEventsFlowStore(
|
|
|
|
initialState: .placeHolder,
|
2022-11-04 23:14:44 -07:00
|
|
|
reducer: WalletEventsFlowReducer()
|
2022-06-28 00:38:08 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
addAttachments(
|
|
|
|
name: "\(#function)_WalletEventDetail",
|
2022-09-22 12:20:46 -07:00
|
|
|
TransactionDetailView(transaction: transaction, store: walletEventsStore)
|
2022-06-28 00:38:08 -07:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|