Make TestEncodeMessageAErr pass
This commit is contained in:
parent
86cf3ee89d
commit
9bf0c596ba
13
metadapta.go
13
metadapta.go
@ -103,7 +103,7 @@ func (this *a) unlistTransactionSafe(id int64) {
|
||||
func (this *a) sendMessageSafe(trans int64, method uint16, data []byte) error {
|
||||
this.sendLock.Lock()
|
||||
defer this.sendLock.Unlock()
|
||||
return encodeMessageA(this.underlying, trans, method, data)
|
||||
return encodeMessageA(this.underlying, this.sizeLimit, trans, method, data)
|
||||
}
|
||||
|
||||
func (this *a) receive() {
|
||||
@ -269,7 +269,16 @@ type incomingMessage struct {
|
||||
payload []byte
|
||||
}
|
||||
|
||||
func encodeMessageA(writer io.Writer, trans int64, method uint16, data []byte) error {
|
||||
func encodeMessageA(
|
||||
writer io.Writer,
|
||||
sizeLimit int64,
|
||||
trans int64,
|
||||
method uint16,
|
||||
data []byte,
|
||||
) error {
|
||||
if int64(len(data)) > sizeLimit {
|
||||
return ErrPayloadTooLarge
|
||||
}
|
||||
buffer := make([]byte, 18 + len(data))
|
||||
tape.EncodeI64(buffer[:8], trans)
|
||||
tape.EncodeI16(buffer[8:10], method)
|
||||
|
Loading…
Reference in New Issue
Block a user