Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-tron committed Jul 29, 2023
1 parent e2a2439 commit afd9c8f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
30 changes: 12 additions & 18 deletions pkg/api/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ func TestHandler_GetRawAccount(t *testing.T) {
require.Nil(t, err)
account, err := h.GetRawAccount(context.Background(), tt.params)
require.Nil(t, err)
rawAccount, ok := account.(*oas.RawAccount)
require.True(t, ok)
require.Equal(t, tt.wantAddress, rawAccount.Address)
require.Equal(t, tt.wantStatus, rawAccount.Status)

require.Equal(t, tt.wantAddress, account.Address)
require.Equal(t, tt.wantStatus, account.Status)
})
}
}
Expand Down Expand Up @@ -67,10 +66,8 @@ func TestHandler_GetAccount(t *testing.T) {
require.Nil(t, err)
accountRes, err := h.GetAccount(context.Background(), tt.params)
require.Nil(t, err)
account, ok := accountRes.(*oas.Account)
require.True(t, ok)
require.Equal(t, tt.wantAddress, account.Address)
require.Equal(t, tt.wantStatus, account.Status)
require.Equal(t, tt.wantAddress, accountRes.Address)
require.Equal(t, tt.wantStatus, accountRes.Status)
})
}
}
Expand Down Expand Up @@ -138,17 +135,15 @@ func TestHandler_GetAccounts(t *testing.T) {
accountRes, err := h.GetAccounts(context.Background(), tt.params)
require.Nil(t, err)
if len(tt.wantBadRequestError) > 0 {
badRequest, ok := accountRes.(*oas.BadRequest)
badRequest, ok := err.(*oas.ErrorStatusCode)
require.True(t, ok)
require.Equal(t, tt.wantBadRequestError, badRequest.Error)
require.Equal(t, tt.wantBadRequestError, badRequest.Response.Error)
return
}
accounts, ok := accountRes.(*oas.Accounts)
require.True(t, ok)
_ = accounts

statuses := map[string]string{}
names := map[string]string{}
for _, account := range accounts.Accounts {
for _, account := range accountRes.Accounts {
statuses[account.Address] = account.Status
names[account.Address] = account.Name.Value
}
Expand Down Expand Up @@ -186,11 +181,10 @@ func TestHandler_GetTransactions(t *testing.T) {
res, err := h.GetBlockTransactions(context.Background(), tt.params)
require.Nil(t, err)
fmt.Printf("%v\n", res)
transactions, ok := res.(*oas.Transactions)
require.True(t, ok)
require.Equal(t, tt.wantTxCount, len(transactions.Transactions))

require.Equal(t, tt.wantTxCount, len(res.Transactions))
txHashes := map[string]struct{}{}
for _, tx := range transactions.Transactions {
for _, tx := range res.Transactions {
txHashes[tx.Hash] = struct{}{}
}
require.Equal(t, tt.wantTxHashes, txHashes)
Expand Down
4 changes: 1 addition & 3 deletions pkg/api/jetton_handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ func TestHandler_GetJettonsBalances(t *testing.T) {
require.Nil(t, err)
res, err := h.GetJettonsBalances(context.Background(), tt.params)
require.Nil(t, err)
balances, ok := res.(*oas.JettonsBalances)
require.True(t, ok)
pkgTesting.CompareResults(t, balances, tt.filenamePrefix)
pkgTesting.CompareResults(t, res, tt.filenamePrefix)
})
}
}

0 comments on commit afd9c8f

Please sign in to comment.