-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathStakingInfoTests.swift
61 lines (49 loc) · 2.19 KB
/
StakingInfoTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// SPDX-License-Identifier: Apache-2.0
import HieroProtobufs
import SnapshotTesting
import XCTest
@testable import Hiero
internal final class StakingInfoTests: XCTestCase {
private static let stakingInfoAccount: Proto_StakingInfo = .with { proto in
proto.declineReward = true
proto.stakePeriodStart = Resources.validStart.toProtobuf()
proto.pendingReward = 5
proto.stakedToMe = 10
proto.stakedAccountID = Resources.accountId.toProtobuf()
}
private static let stakingInfoNode: Proto_StakingInfo = .with { proto in
proto.declineReward = true
proto.stakePeriodStart = Resources.validStart.toProtobuf()
proto.pendingReward = 5
proto.stakedToMe = 10
proto.stakedNodeID = 3
}
internal func testFromProtobufAccount() throws {
assertSnapshot(matching: try StakingInfo.fromProtobuf(Self.stakingInfoAccount), as: .description)
}
internal func testToProtobufAccount() throws {
assertSnapshot(matching: try StakingInfo.fromProtobuf(Self.stakingInfoAccount).toProtobuf(), as: .description)
}
internal func testFromProtobufNode() throws {
assertSnapshot(matching: try StakingInfo.fromProtobuf(Self.stakingInfoNode), as: .description)
}
internal func testToProtobufNode() throws {
assertSnapshot(matching: try StakingInfo.fromProtobuf(Self.stakingInfoNode).toProtobuf(), as: .description)
}
internal func testFromBytesAccount() throws {
assertSnapshot(matching: try StakingInfo.fromBytes(Self.stakingInfoAccount.serializedData()), as: .description)
}
internal func testToBytesAccount() throws {
assertSnapshot(
matching: try StakingInfo.fromBytes(Self.stakingInfoAccount.serializedData()).toBytes().hexStringEncoded(),
as: .description)
}
internal func testFromBytesNode() throws {
assertSnapshot(matching: try StakingInfo.fromBytes(Self.stakingInfoNode.serializedData()), as: .description)
}
internal func testToBytesNode() throws {
assertSnapshot(
matching: try StakingInfo.fromBytes(Self.stakingInfoNode.serializedData()).toBytes().hexStringEncoded(),
as: .description)
}
}