Skip to content

Commit

Permalink
Change route group read timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkren committed Dec 12, 2019
1 parent d344eda commit 3ca14a9
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 70 deletions.
2 changes: 1 addition & 1 deletion pkg/router/route_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (r *RouteGroup) Read(p []byte) (n int, err error) {
}
r.mu.Unlock()

timeout := time.NewTimer(5 * time.Second)
timeout := time.NewTimer(500 * time.Second)
defer timeout.Stop()

var data []byte
Expand Down
66 changes: 0 additions & 66 deletions pkg/router/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,72 +178,6 @@ func TestRouter_Serve(t *testing.T) {
assert.Equal(t, packet.Payload(), recvPacket.Payload())
assert.Equal(t, dstRtIDs[1], recvPacket.RouteID())
})

// TODO(evanlinjin): I'm having so much trouble with this I officially give up.
// t.Run("handlePacket_appRule", func(t *testing.T) {
// const duration = 10 * time.Second
// // time.AfterFunc(duration, func() {
// // panic("timeout")
// // })
//
// defer clearRules(r0, r1)
//
// // prepare mock-app
// localPort := routing.Port(9)
// cConn, sConn := net.Pipe()
//
// // mock-app config
// // appConf := &app.Config{
// // AppName: "test_app",
// // AppVersion: "1.0",
// // ProtocolVersion: supportedProtocolVersion,
// // }
//
// // serve mock-app
// // sErrCh := make(chan error, 1)
// go func() {
// // sErrCh <- r0.ServeApp(sConn, localPort, appConf)
// _ = r0.ServeApp(sConn, localPort, appConf)
// // close(sErrCh)
// }()
// // defer func() {
// // assert.NoError(t, cConn.Close())
// // assert.NoError(t, <-sErrCh)
// // }()
//
// // a, err := app.New(cConn, appConf)
// // require.NoError(t, err)
// // cErrCh := make(chan error, 1)
// go func() {
// conn, err := a.Accept()
// if err == nil {
// fmt.Println("ACCEPTED:", conn.RemoteAddr())
// }
// fmt.Println("FAILED TO ACCEPT")
// // cErrCh <- err
// // close(cErrCh)
// }()
// a.Dial(a.Addr().(routing.Addr))
// // defer func() {
// // assert.NoError(t, <-cErrCh)
// // }()
//
// // Add a APP rule for r0.
// // port8 := routing.Port(8)
// appRtID := routing.RouteID(7)
// appRule := routing.ConsumeRule(10*time.Minute, appRtID, keys[1].PK, localPort, localPort)
// require.NoError(t, r0.rt.SaveRule(appRule))
//
// // Call handleTransportPacket for r0.
//
// // payload is prepended with two bytes to satisfy app.Proto.
// // payload[0] = frame type, payload[1] = id
// rAddr := routing.Addr{PubKey: keys[1].PK, Port: localPort}
// rawRAddr, _ := json.Marshal(rAddr)
// // payload := append([]byte{byte(app.FrameClose), 0}, rawRAddr...)
// packet := routing.MakeDataPacket(appRtID, rawRAddr)
// require.NoError(t, r0.handleTransportPacket(context.TODO(), packet))
// })
}

// TODO (Darkren): fix tests
Expand Down
2 changes: 0 additions & 2 deletions vendor/github.com/SkycoinProject/dmsg/disc/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ golang.org/x/crypto/internal/chacha20
golang.org/x/crypto/internal/subtle
golang.org/x/crypto/poly1305
golang.org/x/crypto/ssh/terminal
# golang.org/x/net v0.0.0-20191105084925-a882066a44e0
# golang.org/x/net v0.0.0-20191204025024-5ee1b9f4859a
golang.org/x/net/context
golang.org/x/net/internal/socks
golang.org/x/net/nettest
Expand Down

0 comments on commit 3ca14a9

Please sign in to comment.