-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ricky Saechao <[email protected]>
- Loading branch information
Showing
10 changed files
with
100 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* | ||
* Hedera Swift SDK | ||
* | ||
* Copyright (C) 2022 - 2023 Hedera Hashgraph, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
import HederaProtobufs | ||
import SnapshotTesting | ||
import XCTest | ||
|
||
@testable import Hedera | ||
|
||
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().toHexString(), 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().toHexString(), as: .description) | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
Tests/HederaTests/__Snapshots__/StakingInfoTests/testFromBytesAccount.1.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
StakingInfo(declineStakingReward: true, stakePeriodStart: Optional(1554158542000000000), pendingReward: 5 tℏ, stakedToMe: 10 tℏ, stakedAccountId: Optional(0.0.5009), stakedNodeId: nil) |
1 change: 1 addition & 0 deletions
1
Tests/HederaTests/__Snapshots__/StakingInfoTests/testFromBytesNode.1.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
StakingInfo(declineStakingReward: true, stakePeriodStart: Optional(1554158542000000000), pendingReward: 5 tℏ, stakedToMe: 10 tℏ, stakedAccountId: nil, stakedNodeId: Optional(3)) |
1 change: 1 addition & 0 deletions
1
Tests/HederaTests/__Snapshots__/StakingInfoTests/testFromProtobufAccount.1.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
StakingInfo(declineStakingReward: true, stakePeriodStart: Optional(1554158542000000000), pendingReward: 5 tℏ, stakedToMe: 10 tℏ, stakedAccountId: Optional(0.0.5009), stakedNodeId: nil) |
1 change: 1 addition & 0 deletions
1
Tests/HederaTests/__Snapshots__/StakingInfoTests/testFromProtobufNode.1.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
StakingInfo(declineStakingReward: true, stakePeriodStart: Optional(1554158542000000000), pendingReward: 5 tℏ, stakedToMe: 10 tℏ, stakedAccountId: nil, stakedNodeId: Optional(3)) |
1 change: 1 addition & 0 deletions
1
Tests/HederaTests/__Snapshots__/StakingInfoTests/testToBytesAccount.1.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0801120608cea78ae5051805200a2a03189127 |
1 change: 1 addition & 0 deletions
1
Tests/HederaTests/__Snapshots__/StakingInfoTests/testToBytesNode.1.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0801120608cea78ae5051805200a3003 |
10 changes: 10 additions & 0 deletions
10
Tests/HederaTests/__Snapshots__/StakingInfoTests/testToProtobufAccount.1.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
HederaProtobufs.Proto_StakingInfo: | ||
decline_reward: true | ||
stake_period_start { | ||
seconds: 1554158542 | ||
} | ||
pending_reward: 5 | ||
staked_to_me: 10 | ||
staked_account_id { | ||
accountNum: 5009 | ||
} |
8 changes: 8 additions & 0 deletions
8
Tests/HederaTests/__Snapshots__/StakingInfoTests/testToProtobufNode.1.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
HederaProtobufs.Proto_StakingInfo: | ||
decline_reward: true | ||
stake_period_start { | ||
seconds: 1554158542 | ||
} | ||
pending_reward: 5 | ||
staked_to_me: 10 | ||
staked_node_id: 3 |