Make TestEncodeMessageAErr pass

This commit is contained in:
Sasha Koshka 2025-04-25 15:12:01 -04:00
parent 86cf3ee89d
commit 9bf0c596ba

View File

@ -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)