-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathNftIdTests.swift
58 lines (41 loc) · 1.72 KB
/
NftIdTests.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
// SPDX-License-Identifier: Apache-2.0
import SnapshotTesting
import XCTest
@testable import Hiero
private let parsedNftId = NftId(tokenId: TokenId(shard: 1415, realm: 314, num: 123), serial: 456)
internal final class NftIdTests: XCTestCase {
internal func testParseSlashFormat() {
let actualNftId: NftId = "1415.314.123/456"
XCTAssertEqual(parsedNftId, actualNftId)
}
internal func testParseAtFormat() {
let actualNftId: NftId = "1415.314.123@456"
XCTAssertEqual(parsedNftId, actualNftId)
}
internal func testFromString() throws {
assertSnapshot(matching: try NftId.fromString("0.0.5005@1234"), as: .description)
}
internal func testFromString2() throws {
assertSnapshot(matching: try NftId.fromString("0.0.5005/1234"), as: .description)
}
internal func testfromStringWithChecksumOnMainnet() throws {
let nftId = try NftId.fromString("0.0.123-vfmkw/7584")
try nftId.validateChecksums(on: .mainnet)
}
internal func testfromStringWithChecksumOnTestnet() throws {
let nftId = try NftId.fromString("0.0.123-esxsf@584903")
try nftId.validateChecksums(on: .testnet)
}
internal func testfromStringWithChecksumOnPreviewnet() throws {
let nftId = try NftId.fromString("0.0.123-ogizo/487302")
try nftId.validateChecksums(on: .previewnet)
}
internal func testFromBytes() throws {
let nftId = TokenId(5005).nft(574489).toBytes()
assertSnapshot(matching: try NftId.fromBytes(nftId), as: .description)
}
internal func testToBytes() throws {
let nftId = TokenId(5005).nft(4920)
assertSnapshot(matching: nftId.toBytes().hexStringEncoded(), as: .description)
}
}