@@ -48,7 +48,6 @@ func TestUnitMirrorNodeAccountBalanceQueryDefaults(t *testing.T) {
4848 assert .Zero (t , query .GetMaxAttempts ())
4949}
5050
51- // AC 1: a valid account ID returns the hbar balance the mirror node reports.
5251func TestUnitMirrorNodeAccountBalanceQueryReturnsHbarBalance (t * testing.T ) {
5352 var gotAccountID string
5453 client := newMockMirrorClient (t , "balance.example.com:443" , balancesHandler (t , & gotAccountID ,
@@ -79,7 +78,6 @@ func TestUnitMirrorNodeAccountBalanceQueryLargeBalanceIsLossless(t *testing.T) {
7978 assert .Equal (t , tinybars , balance .Hbars .AsTinybar ())
8079}
8180
82- // AC 2: an EVM address is sent as bare hex, which is what the mirror node resolves.
8381func TestUnitMirrorNodeAccountBalanceQueryResolvesEvmAddress (t * testing.T ) {
8482 var gotAccountID string
8583 client := newMockMirrorClient (t , "evm.example.com:443" , balancesHandler (t , & gotAccountID ,
@@ -97,7 +95,6 @@ func TestUnitMirrorNodeAccountBalanceQueryResolvesEvmAddress(t *testing.T) {
9795 assert .Equal (t , "742d35cc6634c0532925a3b844bc454e4438f44e" , gotAccountID )
9896}
9997
100- // AC 3: a public key alias is sent base32-encoded, the form the mirror node reports and accepts.
10198func TestUnitMirrorNodeAccountBalanceQueryResolvesPublicKeyAlias (t * testing.T ) {
10299 var gotAccountID string
103100 client := newMockMirrorClient (t , "alias.example.com:443" , balancesHandler (t , & gotAccountID ,
@@ -119,7 +116,6 @@ func TestUnitMirrorNodeAccountBalanceQueryResolvesPublicKeyAlias(t *testing.T) {
119116 assert .Equal (t , gotAccountID , url .QueryEscape (gotAccountID ), "alias must need no escaping" )
120117}
121118
122- // AC 4: a contract is addressed through the same account.id parameter.
123119func TestUnitMirrorNodeAccountBalanceQueryResolvesContractID (t * testing.T ) {
124120 var gotAccountID string
125121 client := newMockMirrorClient (t , "contract.example.com:443" , balancesHandler (t , & gotAccountID ,
@@ -135,7 +131,6 @@ func TestUnitMirrorNodeAccountBalanceQueryResolvesContractID(t *testing.T) {
135131 assert .Equal (t , "0.0.98765" , gotAccountID )
136132}
137133
138- // AC 5: an unknown account yields an empty list, which is a zero balance and not an error.
139134func TestUnitMirrorNodeAccountBalanceQueryNonExistentAccountIsZero (t * testing.T ) {
140135 var gotAccountID string
141136 client := newMockMirrorClient (t , "missing.example.com:443" , balancesHandler (t , & gotAccountID ,
@@ -149,7 +144,6 @@ func TestUnitMirrorNodeAccountBalanceQueryNonExistentAccountIsZero(t *testing.T)
149144 assert .Equal (t , HbarFromTinybar (0 ), balance .Hbars )
150145}
151146
152- // AC 6: an unset account ID fails before any network call.
153147func TestUnitMirrorNodeAccountBalanceQueryNoAccountIDErrorsBeforeRequest (t * testing.T ) {
154148 var called atomic.Bool
155149 client := newMockMirrorClient (t , "unused.example.com:443" , func (w http.ResponseWriter , r * http.Request ) {
@@ -173,7 +167,6 @@ func TestUnitMirrorNodeAccountBalanceQueryNilClientErrors(t *testing.T) {
173167 require .ErrorIs (t , err , errNoClientProvided )
174168}
175169
176- // AC 7: a transient 503 is retried and the following success is returned.
177170func TestUnitMirrorNodeAccountBalanceQueryRetriesTransientError (t * testing.T ) {
178171 var attempts atomic.Int32
179172 client := newMockMirrorClient (t , "retry.example.com:443" , func (w http.ResponseWriter , r * http.Request ) {
@@ -289,8 +282,7 @@ func TestUnitMirrorNodeAccountBalanceQueryBadChecksumErrorsBeforeRequest(t *test
289282 assert .False (t , called .Load (), "a checksum mismatch must not reach the network" )
290283}
291284
292- // resolveAttempts: query setting, then client, then SDK default. The default must not be a single
293- // attempt -- this query has to retry 5xx, and Client.GetMaxAttempts reports -1 when unset.
285+ // The fallback must not be a single attempt; 5xx responses still have to be retried.
294286func TestUnitMirrorNodeAccountBalanceQueryResolveAttempts (t * testing.T ) {
295287 t .Parallel ()
296288
0 commit comments