This repository has been archived by the owner on May 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package test | ||
|
||
import ( | ||
"sync" | ||
"testing" | ||
|
||
wwr "github.com/qbeon/webwire-go" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
// TestConnSignalBufferOverflow tests Connection.Signal with a name and payload | ||
// that would overflow the buffer | ||
func TestConnSignalBufferOverflow(t *testing.T) { | ||
finished := sync.WaitGroup{} | ||
finished.Add(1) | ||
|
||
// Initialize server | ||
setup := SetupTestServer( | ||
t, | ||
&ServerImpl{ | ||
ClientConnected: func(_ wwr.ConnectionOptions, c wwr.Connection) { | ||
defer finished.Done() | ||
|
||
payload := make([]byte, 2048) | ||
err := c.Signal( | ||
[]byte(nil), // No name | ||
wwr.Payload{Data: payload}, // Payload too big | ||
) | ||
|
||
assert.Error(t, err) | ||
assert.IsType(t, wwr.ErrBufferOverflow{}, err) | ||
}, | ||
}, | ||
wwr.ServerOptions{ | ||
MessageBufferSize: 1024, | ||
}, | ||
nil, // Use the default transport implementation | ||
) | ||
|
||
// Initialize client | ||
setup.NewClientSocket() | ||
|
||
finished.Wait() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters