Skip to content

Commit 36be312

Browse files
committed
test: uncomment account balance e2e test
Signed-off-by: Ricky Saechao <[email protected]>
1 parent 92317c5 commit 36be312

File tree

2 files changed

+42
-50
lines changed

2 files changed

+42
-50
lines changed

Sources/Hedera/Account/AccountBalanceQuery.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,6 @@ public final class AccountBalanceQuery: Query<AccountBalance> {
9898
let accountId = try AccountId.fromProtobuf(proto.accountID)
9999
let tokenBalanceProto = try await mirrorNodeService.getTokenBalancesForAccount(String(accountId.num))
100100

101-
// var tokenBalances: [TokenId: UInt64] = [:]
102-
103-
// for balance in tokenBalanceProto {
104-
// tokenBalances[.fromProtobuf(balance.tokenID)] = balance.balance
105-
// }
106-
107101
return AccountBalance(
108102
accountId: accountId, hbars: .fromTinybars(Int64(proto.balance)),
109103
tokensInner: .fromProtobuf(tokenBalanceProto))

Tests/HederaE2ETests/Account/AccountBalance.swift

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -114,48 +114,46 @@ internal final class AccountBalance: XCTestCase {
114114
}
115115
}
116116

117-
// disabled because swift doesn't have a way to ignore deprecated warnings.
118-
// internal func testQueryTokenBalances() async throws {
119-
// let testEnv = try TestEnvironment.nonFree
120-
121-
// let account = try await Account.create(testEnv, balance: 10)
122-
123-
// addTeardownBlock { try await account.delete(testEnv) }
124-
125-
// let receipt = try await TokenCreateTransaction()
126-
// .name("ffff")
127-
// .symbol("f")
128-
// .initialSupply(10000)
129-
// .decimals(50)
130-
// .treasuryAccountId(account.id)
131-
// .expirationTime(.now + .minutes(5))
132-
// .adminKey(.single(account.key.publicKey))
133-
// .supplyKey(.single(account.key.publicKey))
134-
// .freezeDefault(false)
135-
// .sign(account.key)
136-
// .execute(testEnv.client)
137-
// .getReceipt(testEnv.client)
138-
139-
// let tokenId = try XCTUnwrap(receipt.tokenId)
140-
141-
// addTeardownBlock {
142-
// _ = try await TokenBurnTransaction()
143-
// .tokenId(tokenId)
144-
// .amount(10000)
145-
// .sign(account.key)
146-
// .execute(testEnv.client)
147-
// .getReceipt(testEnv.client)
148-
149-
// _ = try await TokenDeleteTransaction()
150-
// .tokenId(tokenId)
151-
// .sign(account.key)
152-
// .execute(testEnv.client)
153-
// .getReceipt(testEnv.client)
154-
// }
155-
156-
// let _ = try await AccountBalanceQuery().accountId(account.id).execute(testEnv.client)
157-
158-
// // XCTAssertEqual(balance.tokenBalances[tokenId], 10000)
159-
// // XCTAssertEqual(balance.tokenDecimals[tokenId], 50)
160-
// }
117+
internal func testQueryTokenBalances() async throws {
118+
let testEnv = try TestEnvironment.nonFree
119+
120+
let account = try await Account.create(testEnv, balance: 10)
121+
122+
addTeardownBlock { try await account.delete(testEnv) }
123+
124+
let receipt = try await TokenCreateTransaction()
125+
.name("ffff")
126+
.symbol("f")
127+
.initialSupply(10000)
128+
.decimals(50)
129+
.treasuryAccountId(account.id)
130+
.expirationTime(.now + .minutes(5))
131+
.adminKey(.single(account.key.publicKey))
132+
.supplyKey(.single(account.key.publicKey))
133+
.freezeDefault(false)
134+
.sign(account.key)
135+
.execute(testEnv.client)
136+
.getReceipt(testEnv.client)
137+
138+
let tokenId = try XCTUnwrap(receipt.tokenId)
139+
140+
addTeardownBlock {
141+
_ = try await TokenBurnTransaction()
142+
.tokenId(tokenId)
143+
.amount(10000)
144+
.sign(account.key)
145+
.execute(testEnv.client)
146+
.getReceipt(testEnv.client)
147+
148+
_ = try await TokenDeleteTransaction()
149+
.tokenId(tokenId)
150+
.sign(account.key)
151+
.execute(testEnv.client)
152+
.getReceipt(testEnv.client)
153+
}
154+
155+
let balance = try await AccountBalanceQuery().accountId(account.id).execute(testEnv.client)
156+
157+
XCTAssertEqual(balance.hbars, 10)
158+
}
161159
}

0 commit comments

Comments
 (0)