From 48fdb78ee7229e555951e79c48673092af68676b Mon Sep 17 00:00:00 2001 From: Ricky Saechao <76449893+RickyLB@users.noreply.github.com> Date: Tue, 3 Oct 2023 12:00:18 -0700 Subject: [PATCH] Add Unit Tests (#295) --- Tests/HederaTests/CryptoPemTests.swift | 106 ++++++++++++++++++ Tests/HederaTests/CustomFeeTests.swift | 106 ++++++++++++++++++ Tests/HederaTests/FeeScheduleTests.swift | 64 +++++++++++ Tests/HederaTests/LedgerIdTests.swift | 48 ++++++++ Tests/HederaTests/StakingInfoTests.swift | 1 - Tests/HederaTests/TokenNftTransferTests.swift | 42 +++++++ Tests/HederaTests/TokenTypeTests.swift | 43 +++++++ .../HederaTests/TopicMessageQueryTests.swift | 55 +++++++++ Tests/HederaTests/TopicMessageTests.swift | 94 ++++++++++++++++ .../TransactionChunkInfoTests.swift | 59 ++++++++++ .../TransactionFeeScheduleTests.swift | 72 ++++++++++++ Tests/HederaTests/TransactionTests.swift | 90 +++++++++++++++ .../testFixedFromProtobuf.1.txt | 1 + .../testFractionalFromProtobuf.1.txt | 1 + .../testRoyaltyFromProtobuf.1.txt | 1 + .../CustomFeeTests/testSerializeFixed.1.txt | 10 ++ .../testSerializeFractional.1.txt | 12 ++ .../CustomFeeTests/testSerializeRoyalty.1.txt | 16 +++ .../FeeScheduleTests/testFromProtobuf.1.txt | 1 + .../FeeScheduleTests/testSerialize.1.txt | 1 + .../FeeScheduleTests/testToFromBytes.1.txt | 1 + .../FeeScheduleTests/testToProtobuf.1.txt | 16 +++ .../TokenNftTransferTests/testSerialize.1.txt | 1 + .../testFromBytes.1.txt | 1 + .../testFromProtobuf.1.txt | 1 + .../testSerialize.1.txt | 1 + .../testToBytes.1.txt | 1 + .../testToProtobuf.1.txt | 33 ++++++ 28 files changed, 877 insertions(+), 1 deletion(-) create mode 100644 Tests/HederaTests/CryptoPemTests.swift create mode 100644 Tests/HederaTests/CustomFeeTests.swift create mode 100644 Tests/HederaTests/FeeScheduleTests.swift create mode 100644 Tests/HederaTests/LedgerIdTests.swift create mode 100644 Tests/HederaTests/TokenNftTransferTests.swift create mode 100644 Tests/HederaTests/TokenTypeTests.swift create mode 100644 Tests/HederaTests/TopicMessageQueryTests.swift create mode 100644 Tests/HederaTests/TopicMessageTests.swift create mode 100644 Tests/HederaTests/TransactionChunkInfoTests.swift create mode 100644 Tests/HederaTests/TransactionFeeScheduleTests.swift create mode 100644 Tests/HederaTests/TransactionTests.swift create mode 100644 Tests/HederaTests/__Snapshots__/CustomFeeTests/testFixedFromProtobuf.1.txt create mode 100644 Tests/HederaTests/__Snapshots__/CustomFeeTests/testFractionalFromProtobuf.1.txt create mode 100644 Tests/HederaTests/__Snapshots__/CustomFeeTests/testRoyaltyFromProtobuf.1.txt create mode 100644 Tests/HederaTests/__Snapshots__/CustomFeeTests/testSerializeFixed.1.txt create mode 100644 Tests/HederaTests/__Snapshots__/CustomFeeTests/testSerializeFractional.1.txt create mode 100644 Tests/HederaTests/__Snapshots__/CustomFeeTests/testSerializeRoyalty.1.txt create mode 100644 Tests/HederaTests/__Snapshots__/FeeScheduleTests/testFromProtobuf.1.txt create mode 100644 Tests/HederaTests/__Snapshots__/FeeScheduleTests/testSerialize.1.txt create mode 100644 Tests/HederaTests/__Snapshots__/FeeScheduleTests/testToFromBytes.1.txt create mode 100644 Tests/HederaTests/__Snapshots__/FeeScheduleTests/testToProtobuf.1.txt create mode 100644 Tests/HederaTests/__Snapshots__/TokenNftTransferTests/testSerialize.1.txt create mode 100644 Tests/HederaTests/__Snapshots__/TransactionFeeScheduleTests/testFromBytes.1.txt create mode 100644 Tests/HederaTests/__Snapshots__/TransactionFeeScheduleTests/testFromProtobuf.1.txt create mode 100644 Tests/HederaTests/__Snapshots__/TransactionFeeScheduleTests/testSerialize.1.txt create mode 100644 Tests/HederaTests/__Snapshots__/TransactionFeeScheduleTests/testToBytes.1.txt create mode 100644 Tests/HederaTests/__Snapshots__/TransactionFeeScheduleTests/testToProtobuf.1.txt diff --git a/Tests/HederaTests/CryptoPemTests.swift b/Tests/HederaTests/CryptoPemTests.swift new file mode 100644 index 00000000..58d00107 --- /dev/null +++ b/Tests/HederaTests/CryptoPemTests.swift @@ -0,0 +1,106 @@ +/* + * ‌ + * Hedera Swift SDK + * ​ + * Copyright (C) 2023 - 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 CryptoPemTests: XCTestCase { + internal func testLabelType() throws { + let pemString = + """ + -----BEGIN PRIVATE KEY----- + MIGbMFcGCSqGSIb3DQEFDTBKMCkGCSqGSIb3DQEFDDAcBAjeB6TNNQX+1gICCAAw + -----END PRIVATE KEY----- + """ + + let doc = try Crypto.Pem.decode(pemString) + + XCTAssertEqual(doc.typeLabel, "PRIVATE KEY") + } + + internal func testExceedsLineLimitFail() throws { + let pemString = + """ + -----BEGIN PRIVATE KEY----- + MIGbMFcGCSqGSIb3DQEFDTBKMCkGCSqGSIb3DQEFDDAcBAjeB6TNNQX+1gICCAAwMIGb + -----END PRIVATE KEY----- + """ + + XCTAssertThrowsError(try Crypto.Pem.decode(pemString)) + } + + internal func testShortLineFail() throws { + let pemString = + """ + -----BEGIN PRIVATE KEY----- + MIGbMFcGCSqGSIb3DQEFDTBKMCkGCSqGSIb3DQEFD + -----END PRIVATE KEY----- + """ + + XCTAssertThrowsError(try Crypto.Pem.decode(pemString)) + } + + internal func testNonBase64CharacterFail() throws { + let pemString = + """ + -----BEGIN PRIVATE KEY----- + ≈MIGbMFcGCSqGSIb3DQEFDTBKMCkGCSqGSIb3DQEFDDAcBAjeB6TNNQX+1gICCAAw + -----END PRIVATE KEY----- + """ + + XCTAssertThrowsError(try Crypto.Pem.decode(pemString)) + } + + internal func testBadHeaderFail() throws { + let pemString = + """ + -----BEGIN PRIVATE KEYS----- + MIGbMFcGCSqGSIb3DQEFDSTBKMCkGCSqGSIb3DQEFDDAcBAjeB6TNNQX+1gICCAAw + -----END PRIVATE KEY----- + """ + + XCTAssertThrowsError(try Crypto.Pem.decode(pemString)) + } + + internal func testBadFooterFail() throws { + let pemString = + """ + -----BEGIN PRIVATE KEY----- + MIGbMFcGCSqGSIb3DQEFDSTBKMCkGCSqGSIb3DQEFDDAcBAjeB6TNNQX+1gICCAAw + -----END PRIVATE KEYS----- + """ + + XCTAssertThrowsError(try Crypto.Pem.decode(pemString)) + } + + internal func testBase64CharacterFail() throws { + let pemString = + """ + -----BEGIN PRIVATE KEY----- + @IGbMFcGCSqGSIb3DQEFDTBKMCkGCSqGSIb3DQEFDDAcBAjeB6TNNQX+1gICCAAw + -----END PRIVATE KEY----- + """ + + XCTAssertThrowsError(try Crypto.Pem.decode(pemString)) + } +} diff --git a/Tests/HederaTests/CustomFeeTests.swift b/Tests/HederaTests/CustomFeeTests.swift new file mode 100644 index 00000000..b5431dba --- /dev/null +++ b/Tests/HederaTests/CustomFeeTests.swift @@ -0,0 +1,106 @@ +/* + * ‌ + * Hedera Swift SDK + * ​ + * Copyright (C) 2023 - 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 CustomFeeTests: XCTestCase { + private static let customFixedFee = Proto_CustomFee.with { proto in + proto.feeCollectorAccountID = AccountId(4322).toProtobuf() + proto.fee = .fixedFee( + Proto_FixedFee.with { proto in + proto.amount = 10 + proto.denominatingTokenID = TokenId(483902).toProtobuf() + }) + } + + private static let customFractionalFee = Proto_CustomFee.with { proto in + proto.feeCollectorAccountID = AccountId(389042).toProtobuf() + proto.fee = .fractionalFee( + Proto_FractionalFee.with { proto in + proto.fractionalAmount = .with { proto in + proto.numerator = 3 + proto.denominator = 7 + } + proto.minimumAmount = 3 + proto.maximumAmount = 100 + }) + } + + private static let customRoyaltyFee = Proto_CustomFee.with { proto in + proto.feeCollectorAccountID = AccountId(23423).toProtobuf() + proto.fee = .royaltyFee( + Proto_RoyaltyFee.with { proto in + proto.fallbackFee = .with { proto in + proto.amount = 10 + proto.denominatingTokenID = TokenId(483902).toProtobuf() + } + proto.exchangeValueFraction = .with { proto in + proto.numerator = 5 + proto.denominator = 8 + } + }) + } + + internal func testSerializeFixed() throws { + assertSnapshot(matching: Self.customFixedFee, as: .description) + } + + internal func testSerializeFractional() throws { + assertSnapshot(matching: Self.customFractionalFee, as: .description) + } + + internal func testSerializeRoyalty() throws { + assertSnapshot(matching: Self.customRoyaltyFee, as: .description) + } + + internal func testFixedFromToBytes() throws { + let fixed = try AnyCustomFee.fromProtobuf(Self.customFixedFee) + let bytes = fixed.toBytes() + XCTAssertEqual(try AnyCustomFee.fromBytes(bytes), fixed) + } + + internal func testFractionalFromToBytes() throws { + let fractional = try AnyCustomFee.fromProtobuf(Self.customFractionalFee) + let bytes = fractional.toBytes() + XCTAssertEqual(try AnyCustomFee.fromBytes(bytes), fractional) + } + + internal func testRoyaltyFromToBytes() throws { + let royalty = try AnyCustomFee.fromProtobuf(Self.customRoyaltyFee) + let bytes = royalty.toBytes() + XCTAssertEqual(try AnyCustomFee.fromBytes(bytes), royalty) + } + + internal func testFixedFromProtobuf() throws { + assertSnapshot(matching: try AnyCustomFee.fromProtobuf(Self.customFixedFee), as: .description) + } + + internal func testFractionalFromProtobuf() throws { + assertSnapshot(matching: try AnyCustomFee.fromProtobuf(Self.customFractionalFee), as: .description) + } + + internal func testRoyaltyFromProtobuf() throws { + assertSnapshot(matching: try AnyCustomFee.fromProtobuf(Self.customRoyaltyFee), as: .description) + } +} diff --git a/Tests/HederaTests/FeeScheduleTests.swift b/Tests/HederaTests/FeeScheduleTests.swift new file mode 100644 index 00000000..1b267a36 --- /dev/null +++ b/Tests/HederaTests/FeeScheduleTests.swift @@ -0,0 +1,64 @@ +/* + * ‌ + * Hedera Swift SDK + * ​ + * Copyright (C) 2023 - 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 SnapshotTesting +import XCTest + +@testable import Hedera + +internal final class FeeScheduleTests: XCTestCase { + private static func makeFeeComponent(_ min: UInt64, _ max: UInt64) -> FeeComponents { + FeeComponents( + min: min, max: max, constant: 0, bandwidthByte: 0, verification: 0, storageByteHour: 0, ramByteHour: 0, + contractTransactionGas: 0, transferVolumeHbar: 0, responseMemoryByte: 0, responseDiskByte: 0) + } + + private let feeSchedule: FeeSchedule = + FeeSchedule.init( + transactionFeeSchedules: [ + TransactionFeeSchedule( + requestType: nil, + fees: [ + FeeData.init( + node: makeFeeComponent(0, 0), network: makeFeeComponent(2, 5), + service: makeFeeComponent(0, 0), kind: FeeDataType.default) + ]) + ], expirationTime: Timestamp(seconds: 1_554_158_542, subSecondNanos: 0)) + + internal func testSerialize() throws { + assertSnapshot(matching: feeSchedule, as: .description) + } + + internal func testToFromBytes() throws { + assertSnapshot(matching: try FeeSchedule.fromBytes(feeSchedule.toBytes()), as: .description) + } + + internal func testFromProtobuf() throws { + let feeSchedule = try FeeSchedule.fromProtobuf(feeSchedule.toProtobuf()) + + assertSnapshot(matching: feeSchedule, as: .description) + } + + internal func testToProtobuf() throws { + let protoFeeSchedule = feeSchedule.toProtobuf() + + assertSnapshot(matching: protoFeeSchedule, as: .description) + } +} diff --git a/Tests/HederaTests/LedgerIdTests.swift b/Tests/HederaTests/LedgerIdTests.swift new file mode 100644 index 00000000..82ccd456 --- /dev/null +++ b/Tests/HederaTests/LedgerIdTests.swift @@ -0,0 +1,48 @@ +/* + * ‌ + * 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 SnapshotTesting +import XCTest + +import struct HederaProtobufs.Proto_Key + +@testable import Hedera + +internal final class LedgerIdTests: XCTestCase { + internal func testToString() throws { + XCTAssertEqual(LedgerId.mainnet.toString(), "mainnet") + XCTAssertEqual(LedgerId.testnet.toString(), "testnet") + XCTAssertEqual(LedgerId.previewnet.toString(), "previewnet") + XCTAssertEqual(LedgerId.fromBytes(Data([0x00, 0xFF, 0x00, 0xFF])), "00FF00FF") + } + + internal func testFromString() throws { + XCTAssertEqual(LedgerId.fromString("mainnet"), LedgerId.mainnet) + XCTAssertEqual(LedgerId.fromString("testnet"), LedgerId.testnet) + XCTAssertEqual(LedgerId.fromString("previewnet"), LedgerId.previewnet) + XCTAssertEqual(LedgerId.fromString("00ff00ff"), LedgerId.fromBytes(Data([0x00, 0xFF, 0x00, 0xFF]))) + XCTAssertEqual(LedgerId.fromString("00FF00FF"), LedgerId.fromBytes(Data([0x00, 0xFF, 0x00, 0xFF]))) + } + + internal func testToBytes() throws { + let bytes = Data([0x00, 0xFF, 0x00, 0xFF]) + XCTAssertEqual(LedgerId.fromBytes(Data([0x00, 0xFF, 0x00, 0xFF])).bytes, bytes) + } +} diff --git a/Tests/HederaTests/StakingInfoTests.swift b/Tests/HederaTests/StakingInfoTests.swift index c5973cf9..a7beec2a 100644 --- a/Tests/HederaTests/StakingInfoTests.swift +++ b/Tests/HederaTests/StakingInfoTests.swift @@ -25,7 +25,6 @@ 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() diff --git a/Tests/HederaTests/TokenNftTransferTests.swift b/Tests/HederaTests/TokenNftTransferTests.swift new file mode 100644 index 00000000..da5cde99 --- /dev/null +++ b/Tests/HederaTests/TokenNftTransferTests.swift @@ -0,0 +1,42 @@ +/* + * ‌ + * 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 class TokenNftTransferTests: XCTestCase { + internal static let testReceiver = AccountId("0.0.5008") + internal static let testSerialNumber = 4 + + private func makeTransfer() throws -> TokenNftTransfer { + TokenNftTransfer.init( + tokenId: Resources.tokenId, sender: Resources.accountId, receiver: Self.testReceiver, serial: 4, + isApproved: true) + } + + internal func testSerialize() throws { + let transfer = try makeTransfer() + + assertSnapshot(of: transfer, as: .description) + } +} diff --git a/Tests/HederaTests/TokenTypeTests.swift b/Tests/HederaTests/TokenTypeTests.swift new file mode 100644 index 00000000..d33f87ea --- /dev/null +++ b/Tests/HederaTests/TokenTypeTests.swift @@ -0,0 +1,43 @@ +/* + * ‌ + * 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 TokenTypeTests: XCTestCase { + internal func testToProtobuf() throws { + let fungibleTokenProto = TokenType.fungibleCommon.toProtobuf() + let nftTokenProto = TokenType.nonFungibleUnique.toProtobuf() + + XCTAssertEqual(fungibleTokenProto, Proto_TokenType.fungibleCommon) + XCTAssertEqual(nftTokenProto, Proto_TokenType.nonFungibleUnique) + } + + internal func testFromProtobuf() throws { + let fungibleTokenType = try TokenType.fromProtobuf(Proto_TokenType.fungibleCommon) + let nftTokenType = try TokenType.fromProtobuf(Proto_TokenType.nonFungibleUnique) + + XCTAssertEqual(fungibleTokenType, TokenType.fungibleCommon) + XCTAssertEqual(nftTokenType, TokenType.nonFungibleUnique) + } +} diff --git a/Tests/HederaTests/TopicMessageQueryTests.swift b/Tests/HederaTests/TopicMessageQueryTests.swift new file mode 100644 index 00000000..6ff18495 --- /dev/null +++ b/Tests/HederaTests/TopicMessageQueryTests.swift @@ -0,0 +1,55 @@ +/* + * ‌ + * 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 TopicMessageQueryTests: XCTestCase { + internal func testGetSetTopicId() throws { + let query = TopicMessageQuery() + query.topicId(Resources.topicId) + + XCTAssertEqual(query.topicId, Resources.topicId) + } + + internal func testGetSetStartTime() throws { + let query = TopicMessageQuery() + query.startTime(Resources.validStart) + + XCTAssertEqual(query.startTime, Resources.validStart) + } + + internal func testGetSetEndTime() throws { + let query = TopicMessageQuery() + query.endTime(Resources.validStart) + + XCTAssertEqual(query.endTime, Resources.validStart) + } + + internal func testGetSetLimit() throws { + let query = TopicMessageQuery() + query.limit(1415) + + XCTAssertEqual(query.limit, 1415) + } +} diff --git a/Tests/HederaTests/TopicMessageTests.swift b/Tests/HederaTests/TopicMessageTests.swift new file mode 100644 index 00000000..59019a47 --- /dev/null +++ b/Tests/HederaTests/TopicMessageTests.swift @@ -0,0 +1,94 @@ +/* + * ‌ + * 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 class TopicMessageTests: XCTestCase { + private static let testSequenceNumber: UInt64 = 7 + + private static let testContents = Data([0x01, 0x02, 0x03]) + private static let testRunningHash = Data([0x04, 0x05, 0x06]) + private static let testTxId = Resources.txId + + internal func testArguments() throws { + let topicMessageChunk = TopicMessageChunk.init( + header: ProtoTopicMessageHeader.init( + consensusTimestamp: Resources.validStart, sequenceNumber: Self.testSequenceNumber, + runningHash: Self.testRunningHash, runningHashVersion: 0, message: "yay".data(using: .utf8)!)) + + let topicMessageChunkArr: [TopicMessageChunk] = [topicMessageChunk, topicMessageChunk, topicMessageChunk] + + let topicMessage = TopicMessage( + consensusTimestamp: Resources.validStart, contents: Self.testContents, runningHash: Self.testRunningHash, + runningHashVersion: 0, sequenceNumber: Self.testSequenceNumber, transaction: Self.testTxId, + chunks: topicMessageChunkArr) + + XCTAssertEqual(topicMessage.consensusTimestamp, Resources.validStart) + XCTAssertEqual(topicMessage.contents, Self.testContents) + XCTAssertEqual(topicMessage.runningHash, Self.testRunningHash) + XCTAssertEqual(topicMessage.sequenceNumber, Self.testSequenceNumber) + XCTAssertEqual(topicMessage.chunks?.count, 3) + XCTAssertEqual(topicMessage.transaction, Self.testTxId) + XCTAssertEqual(topicMessage.runningHashVersion, 0) + } + + internal func testSingle() throws { + let topicMessageHeader = ProtoTopicMessageHeader.init( + consensusTimestamp: Resources.validStart, sequenceNumber: Self.testSequenceNumber, + runningHash: Self.testRunningHash, runningHashVersion: 0, message: Self.testContents) + + let topicMessage = TopicMessage(single: topicMessageHeader) + + XCTAssertEqual(topicMessage.consensusTimestamp, Resources.validStart) + XCTAssertEqual(topicMessage.contents, Self.testContents) + XCTAssertEqual(topicMessage.runningHash, Self.testRunningHash) + XCTAssertEqual(topicMessage.sequenceNumber, Self.testSequenceNumber) + XCTAssertEqual(topicMessage.chunks?.count, nil) + XCTAssertEqual(topicMessage.transaction, nil) + } + + internal func testMany() throws { + let topicMessageChunk1 = ProtoTopicMessageChunk.init( + header: ProtoTopicMessageHeader.init( + consensusTimestamp: Resources.validStart, sequenceNumber: Self.testSequenceNumber, + runningHash: Self.testRunningHash, runningHashVersion: 0, message: Self.testContents), + initialTransactionId: Resources.txId, number: 1, total: 2) + + let topicMessageChunk2 = ProtoTopicMessageChunk.init( + header: ProtoTopicMessageHeader.init( + consensusTimestamp: Resources.validStart + Duration.seconds(1), + sequenceNumber: Self.testSequenceNumber + 1, + runningHash: Self.testRunningHash, runningHashVersion: 0, message: Self.testContents), + initialTransactionId: Resources.txId, number: 2, total: 2) + + let topicMessage = TopicMessage.init(chunks: [topicMessageChunk1, topicMessageChunk2]) + + XCTAssertEqual(topicMessage.consensusTimestamp, Resources.validStart + Duration.seconds(1)) + XCTAssertEqual(topicMessage.contents, Data([0x01, 0x02, 0x03, 0x01, 0x02, 0x03])) + XCTAssertEqual(topicMessage.runningHash, Self.testRunningHash) + XCTAssertEqual(topicMessage.sequenceNumber, Self.testSequenceNumber + 1) + XCTAssertEqual(topicMessage.chunks?.count, 2) + XCTAssertEqual(topicMessage.transaction, Resources.txId) + } +} diff --git a/Tests/HederaTests/TransactionChunkInfoTests.swift b/Tests/HederaTests/TransactionChunkInfoTests.swift new file mode 100644 index 00000000..d9a2acac --- /dev/null +++ b/Tests/HederaTests/TransactionChunkInfoTests.swift @@ -0,0 +1,59 @@ +/* + * ‌ + * 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 TransactionChunkInfoTests: XCTestCase { + internal func testInitial() throws { + let info = ChunkInfo.initial(total: 2, transactionId: Resources.txId, nodeAccountId: Resources.accountId) + + XCTAssertEqual(info.current, 0) + XCTAssertEqual(info.total, 2) + XCTAssertEqual(info.currentTransactionId, Resources.txId) + XCTAssertEqual(info.initialTransactionId, Resources.txId) + XCTAssertEqual(info.nodeAccountId, Resources.accountId) + } + + internal func testArguments() throws { + let info = ChunkInfo( + current: 3, total: 4, initialTransactionId: Resources.txId, currentTransactionId: Resources.txId, + nodeAccountId: Resources.nodeAccountIds[0]) + + XCTAssertEqual(info.current, 3) + XCTAssertEqual(info.total, 4) + XCTAssertEqual(info.currentTransactionId, Resources.txId) + XCTAssertEqual(info.initialTransactionId, Resources.txId) + XCTAssertEqual(info.nodeAccountId, Resources.nodeAccountIds[0]) + } + + internal func testSingle() throws { + let info = ChunkInfo.single(transactionId: Resources.txId, nodeAccountId: Resources.nodeAccountIds[0]) + + XCTAssertEqual(info.current, 0) + XCTAssertEqual(info.total, 1) + XCTAssertEqual(info.currentTransactionId, Resources.txId) + XCTAssertEqual(info.initialTransactionId, Resources.txId) + XCTAssertEqual(info.nodeAccountId, Resources.nodeAccountIds[0]) + } +} diff --git a/Tests/HederaTests/TransactionFeeScheduleTests.swift b/Tests/HederaTests/TransactionFeeScheduleTests.swift new file mode 100644 index 00000000..5125d17f --- /dev/null +++ b/Tests/HederaTests/TransactionFeeScheduleTests.swift @@ -0,0 +1,72 @@ +/* + * ‌ + * 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 TransactionFeeScheduleTests: XCTestCase { + private static func makeFeeComponent(_ min: UInt64, _ max: UInt64) -> FeeComponents { + FeeComponents( + min: min, max: max, constant: 2, bandwidthByte: 5, verification: 6, storageByteHour: 0, ramByteHour: 0, + contractTransactionGas: 3, transferVolumeHbar: 2, responseMemoryByte: 7, responseDiskByte: 0) + } + private static func makeSchedule() throws -> TransactionFeeSchedule { + TransactionFeeSchedule( + requestType: nil, + fees: [ + FeeData( + node: makeFeeComponent(4, 7), network: makeFeeComponent(2, 5), + service: makeFeeComponent(4, 6), kind: FeeDataType.default) + ]) + } + + internal func testSerialize() throws { + let schedule = try Self.makeSchedule() + assertSnapshot(matching: schedule, as: .description) + } + + internal func testToProtobuf() throws { + let scheduleProto = try Self.makeSchedule().toProtobuf() + + assertSnapshot(matching: scheduleProto, as: .description) + } + + internal func testFromProtobuf() throws { + let scheduleProto = try Self.makeSchedule().toProtobuf() + let schedule = try TransactionFeeSchedule.fromProtobuf(scheduleProto) + + assertSnapshot(matching: schedule, as: .description) + } + + internal func testFromBytes() throws { + let schedule = try TransactionFeeSchedule.fromBytes(try Self.makeSchedule().toBytes()) + + assertSnapshot(matching: schedule, as: .description) + } + + internal func testToBytes() throws { + let schedule = try Self.makeSchedule().toBytes().toHexString() + + assertSnapshot(matching: schedule, as: .description) + } +} diff --git a/Tests/HederaTests/TransactionTests.swift b/Tests/HederaTests/TransactionTests.swift new file mode 100644 index 00000000..bcb5f3fd --- /dev/null +++ b/Tests/HederaTests/TransactionTests.swift @@ -0,0 +1,90 @@ +/* + * ‌ + * 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 TransactionTests: XCTestCase { + internal func testToFromBytes() throws { + let new = TransferTransaction() + + let bytes = try new.maxTransactionFee(10).transactionValidDuration(Duration.seconds(119)) + .transactionMemo("Frosted flakes").hbarTransfer(AccountId(2), 2).hbarTransfer(AccountId(101), -2) + .transactionId(Resources.txId).nodeAccountIds(Resources.nodeAccountIds).freeze().toBytes() + + let tx = new + + let lhs = try tx.makeProtoBody() + + let tx2 = try Transaction.fromBytes(bytes) + + let rhs = try tx2.makeProtoBody() + + XCTAssertEqual(tx.maxTransactionFee, tx2.maxTransactionFee) + + let lhs1 = tx.nodeAccountIds + let rhs2 = tx2.nodeAccountIds + + XCTAssertEqual(lhs1, rhs2) + + XCTAssertEqual(tx.transactionId, tx2.transactionId) + XCTAssertEqual(tx.transactionMemo, tx2.transactionMemo) + XCTAssertEqual(tx.transactionValidDuration, tx2.transactionValidDuration) + XCTAssertEqual(lhs, rhs) + XCTAssertNotNil(tx2.sources) + } + + internal func testFromBytesSignToBytes() throws { + let new = TransferTransaction() + + let bytes = try new.maxTransactionFee(10).transactionValidDuration(Duration.seconds(119)) + .transactionMemo("Frosted flakes").hbarTransfer(AccountId(2), 2).hbarTransfer(AccountId(101), -2) + .transactionId(Resources.txId).nodeAccountIds(Resources.nodeAccountIds).freeze().toBytes() + + let tx2 = try Transaction.fromBytes(bytes) + + tx2.sign( + try PrivateKey.fromBytes( + Data( + hexEncoded: + "302e020100300506032b657004220420e40d4241d093b22910c78135e0501b137cd9205bbb9c0153c5adf2c65e7dc95a" + )!)) + + _ = try tx2.toBytes() + + XCTAssertEqual(tx2.signers.count, 1) + } + + internal func testChunkedToFromBytes() throws { + let client = Client.forTestnet() + client.setOperator(AccountId(0), PrivateKey.generateEd25519()) + + let bytes = try TopicMessageSubmitTransaction().topicId(314).message("Fish cutlery".data(using: .utf8)!) + .chunkSize(8).maxChunks(2).transactionId(Resources.txId).nodeAccountIds(Resources.nodeAccountIds) + .freezeWith(client).toBytes() + + let tx = try Transaction.fromBytes(bytes) + + _ = try tx.toBytes() + } +} diff --git a/Tests/HederaTests/__Snapshots__/CustomFeeTests/testFixedFromProtobuf.1.txt b/Tests/HederaTests/__Snapshots__/CustomFeeTests/testFixedFromProtobuf.1.txt new file mode 100644 index 00000000..931e1d9b --- /dev/null +++ b/Tests/HederaTests/__Snapshots__/CustomFeeTests/testFixedFromProtobuf.1.txt @@ -0,0 +1 @@ +fixed(Hedera.FixedFee(feeCollectorAccountId: Optional(0.0.4322), allCollectorsAreExempt: false, amount: 10, denominatingTokenId: Optional(0.0.483902))) \ No newline at end of file diff --git a/Tests/HederaTests/__Snapshots__/CustomFeeTests/testFractionalFromProtobuf.1.txt b/Tests/HederaTests/__Snapshots__/CustomFeeTests/testFractionalFromProtobuf.1.txt new file mode 100644 index 00000000..a9ec893b --- /dev/null +++ b/Tests/HederaTests/__Snapshots__/CustomFeeTests/testFractionalFromProtobuf.1.txt @@ -0,0 +1 @@ +fractional(Hedera.FractionalFee(feeCollectorAccountId: Optional(0.0.389042), allCollectorsAreExempt: false, denominator: 7, numerator: 3, minimumAmount: 3, maximumAmount: 100, assessmentMethod: Hedera.FractionalFee.FeeAssessmentMethod.inclusive)) \ No newline at end of file diff --git a/Tests/HederaTests/__Snapshots__/CustomFeeTests/testRoyaltyFromProtobuf.1.txt b/Tests/HederaTests/__Snapshots__/CustomFeeTests/testRoyaltyFromProtobuf.1.txt new file mode 100644 index 00000000..78bd57da --- /dev/null +++ b/Tests/HederaTests/__Snapshots__/CustomFeeTests/testRoyaltyFromProtobuf.1.txt @@ -0,0 +1 @@ +royalty(Hedera.RoyaltyFee(feeCollectorAccountId: Optional(0.0.23423), allCollectorsAreExempt: false, denominator: 8, numerator: 5, fallbackFee: Optional(Hedera.FixedFee(feeCollectorAccountId: nil, allCollectorsAreExempt: false, amount: 10, denominatingTokenId: Optional(0.0.483902))))) \ No newline at end of file diff --git a/Tests/HederaTests/__Snapshots__/CustomFeeTests/testSerializeFixed.1.txt b/Tests/HederaTests/__Snapshots__/CustomFeeTests/testSerializeFixed.1.txt new file mode 100644 index 00000000..abd059dd --- /dev/null +++ b/Tests/HederaTests/__Snapshots__/CustomFeeTests/testSerializeFixed.1.txt @@ -0,0 +1,10 @@ +HederaProtobufs.Proto_CustomFee: +fixed_fee { + amount: 10 + denominating_token_id { + tokenNum: 483902 + } +} +fee_collector_account_id { + accountNum: 4322 +} diff --git a/Tests/HederaTests/__Snapshots__/CustomFeeTests/testSerializeFractional.1.txt b/Tests/HederaTests/__Snapshots__/CustomFeeTests/testSerializeFractional.1.txt new file mode 100644 index 00000000..ad908c59 --- /dev/null +++ b/Tests/HederaTests/__Snapshots__/CustomFeeTests/testSerializeFractional.1.txt @@ -0,0 +1,12 @@ +HederaProtobufs.Proto_CustomFee: +fractional_fee { + fractional_amount { + numerator: 3 + denominator: 7 + } + minimum_amount: 3 + maximum_amount: 100 +} +fee_collector_account_id { + accountNum: 389042 +} diff --git a/Tests/HederaTests/__Snapshots__/CustomFeeTests/testSerializeRoyalty.1.txt b/Tests/HederaTests/__Snapshots__/CustomFeeTests/testSerializeRoyalty.1.txt new file mode 100644 index 00000000..d1af6178 --- /dev/null +++ b/Tests/HederaTests/__Snapshots__/CustomFeeTests/testSerializeRoyalty.1.txt @@ -0,0 +1,16 @@ +HederaProtobufs.Proto_CustomFee: +fee_collector_account_id { + accountNum: 23423 +} +royalty_fee { + exchange_value_fraction { + numerator: 5 + denominator: 8 + } + fallback_fee { + amount: 10 + denominating_token_id { + tokenNum: 483902 + } + } +} diff --git a/Tests/HederaTests/__Snapshots__/FeeScheduleTests/testFromProtobuf.1.txt b/Tests/HederaTests/__Snapshots__/FeeScheduleTests/testFromProtobuf.1.txt new file mode 100644 index 00000000..7c1bc888 --- /dev/null +++ b/Tests/HederaTests/__Snapshots__/FeeScheduleTests/testFromProtobuf.1.txt @@ -0,0 +1 @@ +FeeSchedule(transactionFeeSchedules: [Hedera.TransactionFeeSchedule(requestType: nil, feeData: nil, fees: [Hedera.FeeData(node: Hedera.FeeComponents(min: 0, max: 0, constant: 0, bandwidthByte: 0, verification: 0, storageByteHour: 0, ramByteHour: 0, contractTransactionGas: 0, transferVolumeHbar: 0, responseMemoryByte: 0, responseDiskByte: 0), network: Hedera.FeeComponents(min: 2, max: 5, constant: 0, bandwidthByte: 0, verification: 0, storageByteHour: 0, ramByteHour: 0, contractTransactionGas: 0, transferVolumeHbar: 0, responseMemoryByte: 0, responseDiskByte: 0), service: Hedera.FeeComponents(min: 0, max: 0, constant: 0, bandwidthByte: 0, verification: 0, storageByteHour: 0, ramByteHour: 0, contractTransactionGas: 0, transferVolumeHbar: 0, responseMemoryByte: 0, responseDiskByte: 0), kind: Hedera.FeeDataType.default)])], expirationTime: 1554158542000000000) \ No newline at end of file diff --git a/Tests/HederaTests/__Snapshots__/FeeScheduleTests/testSerialize.1.txt b/Tests/HederaTests/__Snapshots__/FeeScheduleTests/testSerialize.1.txt new file mode 100644 index 00000000..7c1bc888 --- /dev/null +++ b/Tests/HederaTests/__Snapshots__/FeeScheduleTests/testSerialize.1.txt @@ -0,0 +1 @@ +FeeSchedule(transactionFeeSchedules: [Hedera.TransactionFeeSchedule(requestType: nil, feeData: nil, fees: [Hedera.FeeData(node: Hedera.FeeComponents(min: 0, max: 0, constant: 0, bandwidthByte: 0, verification: 0, storageByteHour: 0, ramByteHour: 0, contractTransactionGas: 0, transferVolumeHbar: 0, responseMemoryByte: 0, responseDiskByte: 0), network: Hedera.FeeComponents(min: 2, max: 5, constant: 0, bandwidthByte: 0, verification: 0, storageByteHour: 0, ramByteHour: 0, contractTransactionGas: 0, transferVolumeHbar: 0, responseMemoryByte: 0, responseDiskByte: 0), service: Hedera.FeeComponents(min: 0, max: 0, constant: 0, bandwidthByte: 0, verification: 0, storageByteHour: 0, ramByteHour: 0, contractTransactionGas: 0, transferVolumeHbar: 0, responseMemoryByte: 0, responseDiskByte: 0), kind: Hedera.FeeDataType.default)])], expirationTime: 1554158542000000000) \ No newline at end of file diff --git a/Tests/HederaTests/__Snapshots__/FeeScheduleTests/testToFromBytes.1.txt b/Tests/HederaTests/__Snapshots__/FeeScheduleTests/testToFromBytes.1.txt new file mode 100644 index 00000000..7c1bc888 --- /dev/null +++ b/Tests/HederaTests/__Snapshots__/FeeScheduleTests/testToFromBytes.1.txt @@ -0,0 +1 @@ +FeeSchedule(transactionFeeSchedules: [Hedera.TransactionFeeSchedule(requestType: nil, feeData: nil, fees: [Hedera.FeeData(node: Hedera.FeeComponents(min: 0, max: 0, constant: 0, bandwidthByte: 0, verification: 0, storageByteHour: 0, ramByteHour: 0, contractTransactionGas: 0, transferVolumeHbar: 0, responseMemoryByte: 0, responseDiskByte: 0), network: Hedera.FeeComponents(min: 2, max: 5, constant: 0, bandwidthByte: 0, verification: 0, storageByteHour: 0, ramByteHour: 0, contractTransactionGas: 0, transferVolumeHbar: 0, responseMemoryByte: 0, responseDiskByte: 0), service: Hedera.FeeComponents(min: 0, max: 0, constant: 0, bandwidthByte: 0, verification: 0, storageByteHour: 0, ramByteHour: 0, contractTransactionGas: 0, transferVolumeHbar: 0, responseMemoryByte: 0, responseDiskByte: 0), kind: Hedera.FeeDataType.default)])], expirationTime: 1554158542000000000) \ No newline at end of file diff --git a/Tests/HederaTests/__Snapshots__/FeeScheduleTests/testToProtobuf.1.txt b/Tests/HederaTests/__Snapshots__/FeeScheduleTests/testToProtobuf.1.txt new file mode 100644 index 00000000..2e941473 --- /dev/null +++ b/Tests/HederaTests/__Snapshots__/FeeScheduleTests/testToProtobuf.1.txt @@ -0,0 +1,16 @@ +HederaProtobufs.Proto_FeeSchedule: +transactionFeeSchedule { + fees { + nodedata { + } + networkdata { + min: 2 + max: 5 + } + servicedata { + } + } +} +expiryTime { + seconds: 1554158542 +} diff --git a/Tests/HederaTests/__Snapshots__/TokenNftTransferTests/testSerialize.1.txt b/Tests/HederaTests/__Snapshots__/TokenNftTransferTests/testSerialize.1.txt new file mode 100644 index 00000000..6180a0cb --- /dev/null +++ b/Tests/HederaTests/__Snapshots__/TokenNftTransferTests/testSerialize.1.txt @@ -0,0 +1 @@ +TokenNftTransfer(tokenId: 0.3.5, sender: 0.0.5009, receiver: 0.0.5008, serial: 4, isApproved: true) \ No newline at end of file diff --git a/Tests/HederaTests/__Snapshots__/TransactionFeeScheduleTests/testFromBytes.1.txt b/Tests/HederaTests/__Snapshots__/TransactionFeeScheduleTests/testFromBytes.1.txt new file mode 100644 index 00000000..90a95b50 --- /dev/null +++ b/Tests/HederaTests/__Snapshots__/TransactionFeeScheduleTests/testFromBytes.1.txt @@ -0,0 +1 @@ +TransactionFeeSchedule(requestType: nil, feeData: nil, fees: [Hedera.FeeData(node: Hedera.FeeComponents(min: 4, max: 7, constant: 2, bandwidthByte: 5, verification: 6, storageByteHour: 0, ramByteHour: 0, contractTransactionGas: 3, transferVolumeHbar: 2, responseMemoryByte: 7, responseDiskByte: 0), network: Hedera.FeeComponents(min: 2, max: 5, constant: 2, bandwidthByte: 5, verification: 6, storageByteHour: 0, ramByteHour: 0, contractTransactionGas: 3, transferVolumeHbar: 2, responseMemoryByte: 7, responseDiskByte: 0), service: Hedera.FeeComponents(min: 4, max: 6, constant: 2, bandwidthByte: 5, verification: 6, storageByteHour: 0, ramByteHour: 0, contractTransactionGas: 3, transferVolumeHbar: 2, responseMemoryByte: 7, responseDiskByte: 0), kind: Hedera.FeeDataType.default)]) \ No newline at end of file diff --git a/Tests/HederaTests/__Snapshots__/TransactionFeeScheduleTests/testFromProtobuf.1.txt b/Tests/HederaTests/__Snapshots__/TransactionFeeScheduleTests/testFromProtobuf.1.txt new file mode 100644 index 00000000..90a95b50 --- /dev/null +++ b/Tests/HederaTests/__Snapshots__/TransactionFeeScheduleTests/testFromProtobuf.1.txt @@ -0,0 +1 @@ +TransactionFeeSchedule(requestType: nil, feeData: nil, fees: [Hedera.FeeData(node: Hedera.FeeComponents(min: 4, max: 7, constant: 2, bandwidthByte: 5, verification: 6, storageByteHour: 0, ramByteHour: 0, contractTransactionGas: 3, transferVolumeHbar: 2, responseMemoryByte: 7, responseDiskByte: 0), network: Hedera.FeeComponents(min: 2, max: 5, constant: 2, bandwidthByte: 5, verification: 6, storageByteHour: 0, ramByteHour: 0, contractTransactionGas: 3, transferVolumeHbar: 2, responseMemoryByte: 7, responseDiskByte: 0), service: Hedera.FeeComponents(min: 4, max: 6, constant: 2, bandwidthByte: 5, verification: 6, storageByteHour: 0, ramByteHour: 0, contractTransactionGas: 3, transferVolumeHbar: 2, responseMemoryByte: 7, responseDiskByte: 0), kind: Hedera.FeeDataType.default)]) \ No newline at end of file diff --git a/Tests/HederaTests/__Snapshots__/TransactionFeeScheduleTests/testSerialize.1.txt b/Tests/HederaTests/__Snapshots__/TransactionFeeScheduleTests/testSerialize.1.txt new file mode 100644 index 00000000..90a95b50 --- /dev/null +++ b/Tests/HederaTests/__Snapshots__/TransactionFeeScheduleTests/testSerialize.1.txt @@ -0,0 +1 @@ +TransactionFeeSchedule(requestType: nil, feeData: nil, fees: [Hedera.FeeData(node: Hedera.FeeComponents(min: 4, max: 7, constant: 2, bandwidthByte: 5, verification: 6, storageByteHour: 0, ramByteHour: 0, contractTransactionGas: 3, transferVolumeHbar: 2, responseMemoryByte: 7, responseDiskByte: 0), network: Hedera.FeeComponents(min: 2, max: 5, constant: 2, bandwidthByte: 5, verification: 6, storageByteHour: 0, ramByteHour: 0, contractTransactionGas: 3, transferVolumeHbar: 2, responseMemoryByte: 7, responseDiskByte: 0), service: Hedera.FeeComponents(min: 4, max: 6, constant: 2, bandwidthByte: 5, verification: 6, storageByteHour: 0, ramByteHour: 0, contractTransactionGas: 3, transferVolumeHbar: 2, responseMemoryByte: 7, responseDiskByte: 0), kind: Hedera.FeeDataType.default)]) \ No newline at end of file diff --git a/Tests/HederaTests/__Snapshots__/TransactionFeeScheduleTests/testToBytes.1.txt b/Tests/HederaTests/__Snapshots__/TransactionFeeScheduleTests/testToBytes.1.txt new file mode 100644 index 00000000..d8464f7a --- /dev/null +++ b/Tests/HederaTests/__Snapshots__/TransactionFeeScheduleTests/testToBytes.1.txt @@ -0,0 +1 @@ +1a360a10080410071802200528064003480250071210080210051802200528064003480250071a1008041006180220052806400348025007 \ No newline at end of file diff --git a/Tests/HederaTests/__Snapshots__/TransactionFeeScheduleTests/testToProtobuf.1.txt b/Tests/HederaTests/__Snapshots__/TransactionFeeScheduleTests/testToProtobuf.1.txt new file mode 100644 index 00000000..143c2fe9 --- /dev/null +++ b/Tests/HederaTests/__Snapshots__/TransactionFeeScheduleTests/testToProtobuf.1.txt @@ -0,0 +1,33 @@ +HederaProtobufs.Proto_TransactionFeeSchedule: +fees { + nodedata { + min: 4 + max: 7 + constant: 2 + bpt: 5 + vpt: 6 + gas: 3 + tv: 2 + bpr: 7 + } + networkdata { + min: 2 + max: 5 + constant: 2 + bpt: 5 + vpt: 6 + gas: 3 + tv: 2 + bpr: 7 + } + servicedata { + min: 4 + max: 6 + constant: 2 + bpt: 5 + vpt: 6 + gas: 3 + tv: 2 + bpr: 7 + } +}