Skip to content

Commit

Permalink
use local dht container
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelneale committed Jul 26, 2024
1 parent 0b8ef0b commit 1db7b21
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
52 changes: 27 additions & 25 deletions impl/concurrencytest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

var (
iterationsPerServer = 1000
server = "http://localhost:8305"
servers = []string{"http://localhost:8305", "http://localhost:8305"}
)

func main() {
Expand All @@ -26,30 +26,32 @@ func main() {
programStart := time.Now()

var wg sync.WaitGroup
for i := 0; i < iterationsPerServer; i++ {
log := logrus.WithField("server", server).WithField("i", i)

s := server
wg.Add(1)
go func() {
putStart := time.Now()
suffix, err := put(s)
if err != nil {
log = log.WithError(err)
}
log.WithField("time", time.Since(putStart)).Info("PUT request completed")
if err != nil {
return
}

getStart := time.Now()
if err = get(s, suffix); err != nil {
log = log.WithError(err)
}
log.WithField("time", time.Since(getStart)).Info("GET request completed")

wg.Done()
}()
for _, server := range servers {
for i := 0; i < iterationsPerServer; i++ {
log := logrus.WithField("server", server).WithField("i", i)

s := server
wg.Add(1)
go func() {
putStart := time.Now()
suffix, err := put(s)
if err != nil {
log = log.WithError(err)
}
log.WithField("time", time.Since(putStart)).Info("PUT request completed")
if err != nil {
return
}

getStart := time.Now()
if err = get(s, suffix); err != nil {
log = log.WithError(err)
}
log.WithField("time", time.Since(getStart)).Info("GET request completed")

wg.Done()
}()
}
}

wg.Wait()
Expand Down
4 changes: 2 additions & 2 deletions impl/internal/did/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

func TestClient(t *testing.T) {
client, err := NewGatewayClient("https://diddht.tbddev.org")
client, err := NewGatewayClient("http://localhost:8305")

require.NoError(t, err)
require.NotNil(t, client)
Expand Down Expand Up @@ -49,7 +49,7 @@ func TestClientInvalidGateway(t *testing.T) {
}

func TestInvalidDIDDocument(t *testing.T) {
client, err := NewGatewayClient("https://diddht.tbddev.test")
client, err := NewGatewayClient("http://localhost:8305")
require.NoError(t, err)
require.NotEmpty(t, client)

Expand Down

0 comments on commit 1db7b21

Please sign in to comment.