Skip to content

Commit

Permalink
Skipping reservations in testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jaytaph committed Mar 15, 2021
1 parent 376d50c commit be09f44
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions internal/handler/address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/bitmaelum/bitmaelum-suite/pkg/bmcrypto"
"github.com/bitmaelum/bitmaelum-suite/pkg/hash"
"github.com/bitmaelum/bitmaelum-suite/pkg/proofofwork"
"github.com/bitmaelum/key-resolver-go/internal"
"github.com/bitmaelum/key-resolver-go/internal/address"
"github.com/bitmaelum/key-resolver-go/internal/http"
"github.com/bitmaelum/key-resolver-go/internal/organisation"
Expand Down Expand Up @@ -713,6 +714,9 @@ func TestHistory(t *testing.T) {
}

func setupRepo() {
// NO reservation checks
internal.SkipReservationCheck = true

sr := address.NewSqliteResolver(":memory:")
address.SetDefaultRepository(sr)

Expand Down
12 changes: 6 additions & 6 deletions internal/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ func ExportMetric() *events.APIGatewayV2HTTPResponse {
body += "# TYPE keyresolver_request counter\n"

input := &dynamodb.ScanInput{
ExpressionAttributeNames: map[string]*string{
"#path_code": aws.String("path_code"),
"#hits": aws.String("hits"),
},
ProjectionExpression: aws.String("#path_code, #hits"),
TableName: aws.String("prometheus"),
ExpressionAttributeNames: map[string]*string{
"#path_code": aws.String("path_code"),
"#hits": aws.String("hits"),
},
ProjectionExpression: aws.String("#path_code, #hits"),
TableName: aws.String("prometheus"),
}

dyna := getDyna()
Expand Down
6 changes: 6 additions & 0 deletions internal/reservation.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import (
// @TODO: Make this dynamic
const baseReservedUrl = "https://resolver.bitmaelum.org/reserved/"

var SkipReservationCheck = false

func getDomainReservations(hash hash.Hash) ([]string, error) {
// call /reserved/<hash>
client := http.DefaultClient
Expand Down Expand Up @@ -70,6 +72,10 @@ func getDomainReservations(hash hash.Hash) ([]string, error) {
}

func CheckReservations(h hash.Hash, pk *bmcrypto.PubKey) bool {
if SkipReservationCheck {
return true
}

domains, err := getDomainReservations(h)
if err != nil {
// Error while fetching domains
Expand Down

0 comments on commit be09f44

Please sign in to comment.