Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
asmogo committed Jul 25, 2024
1 parent 72a58bf commit 0500b41
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 300 deletions.
11 changes: 5 additions & 6 deletions netstr/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package netstr

import (
"context"
"github.com/asmogo/nws/protocol"
"github.com/nbd-wtf/go-nostr"
"runtime"
"testing"
Expand All @@ -14,21 +13,21 @@ import (
func TestNostrConnection_Read(t *testing.T) {
tests := []struct {
name string
event protocol.IncomingEvent
event nostr.IncomingEvent
nc func() *NostrConnection
wantN int
wantErr bool
}{
{
name: "Read invalid relay",
event: protocol.IncomingEvent{Relay: nil},
event: nostr.IncomingEvent{Relay: nil},
nc: func() *NostrConnection {
ctx, cancelFunc := context.WithCancel(context.Background())
return &NostrConnection{
uuid: uuid.New(),
ctx: ctx,
cancel: cancelFunc,
subscriptionChan: make(chan protocol.IncomingEvent, 1),
subscriptionChan: make(chan nostr.IncomingEvent, 1),
privateKey: "788de536151854213cc28dff9c3042e7897f0a1d59b391ddbbc1619d7e716e78",
}
},
Expand All @@ -37,7 +36,7 @@ func TestNostrConnection_Read(t *testing.T) {
},
{
name: "Read",
event: protocol.IncomingEvent{
event: nostr.IncomingEvent{
Relay: &nostr.Relay{URL: "wss://relay.example.com"},
Event: &nostr.Event{
ID: "eventID",
Expand All @@ -49,7 +48,7 @@ func TestNostrConnection_Read(t *testing.T) {
uuid: uuid.New(),
ctx: ctx,
cancel: cancelFunc,
subscriptionChan: make(chan protocol.IncomingEvent, 1),
subscriptionChan: make(chan nostr.IncomingEvent, 1),
privateKey: "788de536151854213cc28dff9c3042e7897f0a1d59b391ddbbc1619d7e716e78",
}
},
Expand Down
9 changes: 5 additions & 4 deletions socks5/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package socks5

import (
"bytes"
"github.com/nbd-wtf/go-nostr"
"testing"
)

Expand All @@ -10,7 +11,7 @@ func TestNoAuth(t *testing.T) {
req.Write([]byte{1, NoAuth})
var resp bytes.Buffer

s, _ := New(&Config{})
s, _ := New(&Config{}, &nostr.SimplePool{})
ctx, err := s.authenticate(&resp, req)
if err != nil {
t.Fatalf("err: %v", err)
Expand Down Expand Up @@ -38,7 +39,7 @@ func TestPasswordAuth_Valid(t *testing.T) {

cator := UserPassAuthenticator{Credentials: cred}

s, _ := New(&Config{AuthMethods: []Authenticator{cator}})
s, _ := New(&Config{AuthMethods: []Authenticator{cator}}, &nostr.SimplePool{})

ctx, err := s.authenticate(&resp, req)
if err != nil {
Expand Down Expand Up @@ -74,7 +75,7 @@ func TestPasswordAuth_Invalid(t *testing.T) {
"foo": "bar",
}
cator := UserPassAuthenticator{Credentials: cred}
s, _ := New(&Config{AuthMethods: []Authenticator{cator}})
s, _ := New(&Config{AuthMethods: []Authenticator{cator}}, &nostr.SimplePool{})

ctx, err := s.authenticate(&resp, req)
if err != UserAuthFailed {
Expand All @@ -101,7 +102,7 @@ func TestNoSupportedAuth(t *testing.T) {
}
cator := UserPassAuthenticator{Credentials: cred}

s, _ := New(&Config{AuthMethods: []Authenticator{cator}})
s, _ := New(&Config{AuthMethods: []Authenticator{cator}}, &nostr.SimplePool{})

ctx, err := s.authenticate(&resp, req)
if err != NoSupportedAuth {
Expand Down
11 changes: 0 additions & 11 deletions socks5/request.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package socks5

import (
"bufio"
"context"
"fmt"
"github.com/asmogo/nws/netstr"
Expand Down Expand Up @@ -79,15 +78,6 @@ type Request struct {
DestAddr *AddrSpec
// AddrSpec of the actual destination (might be affected by rewrite)
realDestAddr *AddrSpec
BufConn *bufio.Reader
}

func (r Request) Buffer(c net.Conn) {
payload, err := r.BufConn.Peek(4096)
if err != nil {
panic(err)
}
c.Write(payload)
}

/*
Expand Down Expand Up @@ -119,7 +109,6 @@ func NewRequest(bufConn io.Reader) (*Request, error) {
Version: socks5Version,
Command: header[1],
DestAddr: dest,
BufConn: bufConn.(*bufio.Reader),
}
return request, nil
}
Expand Down
169 changes: 0 additions & 169 deletions socks5/request_test.go

This file was deleted.

Loading

0 comments on commit 0500b41

Please sign in to comment.