Skip to content

Commit

Permalink
feat(SPV-1298): utxo endpoint tests (#834)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-4chain authored Jan 3, 2025
1 parent 993421a commit e776a4b
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 80 deletions.
38 changes: 0 additions & 38 deletions actions/utxos/routes_test.go

This file was deleted.

65 changes: 65 additions & 0 deletions actions/utxos/search_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package utxos_test

import (
"testing"

"github.com/bitcoin-sv/spv-wallet/actions/testabilities"
"github.com/bitcoin-sv/spv-wallet/engine/tester/fixtures"
)

func TestUserUTXOs(t *testing.T) {
t.Run("return UTXOs for user", func(t *testing.T) {
// given:
given, then := testabilities.New(t)
cleanup := given.StartedSPVWallet()
defer cleanup()

// and:
client := given.HttpClient().ForGivenUser(fixtures.Sender)

// when:
res, _ := client.R().Get("/api/v1/utxos")

// then:
then.Response(res).
IsOK().
WithJSONf(`{
"content": [],
"page": {
"number": 1,
"size": 50,
"totalElements": 0,
"totalPages": 0
}
}`)

})

t.Run("try to return UTXOs for admin", func(t *testing.T) {
// given:
given, then := testabilities.New(t)
cleanup := given.StartedSPVWallet()
defer cleanup()
client := given.HttpClient().ForAdmin()

// when:
res, _ := client.R().Get("/api/v1/utxos")

// then:
then.Response(res).IsUnauthorizedForAdmin()
})

t.Run("return UTXOs for anonymous", func(t *testing.T) {
// given:
given, then := testabilities.New(t)
cleanup := given.StartedSPVWallet()
defer cleanup()
client := given.HttpClient().ForAnonymous()

// when:
res, _ := client.R().Get("/api/v1/utxos")

// then:
then.Response(res).IsUnauthorized()
})
}
42 changes: 0 additions & 42 deletions actions/utxos/utxo_test.go

This file was deleted.

0 comments on commit e776a4b

Please sign in to comment.