fix tests and ci

This commit is contained in:
Page Fault
2020-06-10 12:53:38 +00:00
parent e81826c12f
commit a0318cbf1c
7 changed files with 26 additions and 15 deletions
+2
View File
@@ -20,6 +20,8 @@ jobs:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Test
run: go test ./...
- name: Build
run: mkdir dist && go build -tags "full" -o dist
- name: Upload Binary
@@ -7,12 +7,6 @@ on:
- 'docs'
tags:
- 'v*.*.*'
pull_request:
branches:
- 'master'
paths-ignore:
- '**.md'
- 'docs'
name: docker-build
jobs:
build:
@@ -2,9 +2,6 @@ on:
push:
branches:
- 'dev'
pull_request:
branches:
- 'dev'
name: docker-dev-build
jobs:
build:
+8
View File
@@ -9,6 +9,7 @@ import (
"io"
"net"
"net/http"
"sync"
"time"
)
@@ -43,6 +44,7 @@ func runHelloHTTPServer() {
}
go server.ListenAndServe()
fmt.Println("http test server listening on", HTTPAddr)
wg.Done()
}
var EchoAddr string
@@ -50,6 +52,7 @@ var EchoAddr string
func runTCPEchoServer() {
listener, err := net.Listen("tcp", EchoAddr)
common.Must(err)
wg.Done()
go func() {
for {
conn, err := listener.Accept()
@@ -77,6 +80,7 @@ func runTCPEchoServer() {
func runUDPEchoServer() {
conn, err := net.ListenPacket("udp", EchoAddr)
common.Must(err)
wg.Done()
go func() {
for {
buf := make([]byte, 1024*8)
@@ -96,9 +100,13 @@ func GeneratePayload(length int) []byte {
return buf
}
var wg = sync.WaitGroup{}
func init() {
wg.Add(3)
runHelloHTTPServer()
EchoAddr = GetTestAddr()
runTCPEchoServer()
runUDPEchoServer()
wg.Wait()
}
+8 -1
View File
@@ -16,7 +16,14 @@ import (
)
func TestMux(t *testing.T) {
cfg := newDefaultConfig().(*Config)
cfg := &Config{
Mux: MuxConfig{
Enabled: true,
Concurrency: 8,
Timeout: 10,
},
}
data, err := yaml.Marshal(cfg)
common.Must(err)
fmt.Println(string(data))
+7 -5
View File
@@ -3,15 +3,15 @@ package socks
import (
"context"
"fmt"
"net"
"sync"
"testing"
"github.com/p4gefau1t/trojan-go/common"
"github.com/p4gefau1t/trojan-go/config"
"github.com/p4gefau1t/trojan-go/test/util"
"github.com/p4gefau1t/trojan-go/tunnel"
"golang.org/x/net/proxy"
"net"
"sync"
"testing"
"time"
)
func TestSocks(t *testing.T) {
@@ -29,14 +29,16 @@ func TestSocks(t *testing.T) {
wg := sync.WaitGroup{}
wg.Add(2)
time.Sleep(time.Second * 2)
go func() {
conn2, err = s.AcceptConn(nil)
common.Must(err)
wg.Done()
}()
time.Sleep(time.Second * 1)
go func() {
conn1, err = socksClient.Dial("tcp", "www.baidu.com:80")
conn1, err = socksClient.Dial("tcp", util.EchoAddr)
common.Must(err)
wg.Done()
}()
+1
View File
@@ -14,6 +14,7 @@ import (
func TestWebsocket(t *testing.T) {
cfg := &Config{
Websocket: WebsocketConfig{
Enabled: true,
Hostname: "localhost",
Path: "/ws",
},