mirror of
https://github.com/getAlby/hub.git
synced 2026-08-13 12:33:39 +02:00
fix: increase metadata limit (#731)
* fix: increase metadata limit * fix: metadata tests and change comment --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com>
This commit is contained in:
parent
35a07491b5
commit
0c72ff35db
2 changed files with 6 additions and 5 deletions
|
|
@ -31,10 +31,10 @@ const (
|
|||
)
|
||||
|
||||
// limit encoded metadata length, otherwise relays may have trouble listing multiple transactions
|
||||
// given a relay limit of 512000 bytes and ideally being able to list 50 transactions,
|
||||
// each transaction would have to have a maximum size of 10240
|
||||
// accounting for encryption and other metadata in the response, this is set to 2048 characters
|
||||
const INVOICE_METADATA_MAX_LENGTH = 2048
|
||||
// given a relay limit of 512000 bytes and ideally being able to list 25 transactions,
|
||||
// each transaction would have to have a maximum size of 20480
|
||||
// accounting for encryption and other metadata in the response, this is set to 4096 characters
|
||||
const INVOICE_METADATA_MAX_LENGTH = 4096
|
||||
|
||||
// errors used by NIP-47 and the transaction service
|
||||
const (
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package transactions
|
|||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
|
|
@ -50,7 +51,7 @@ func TestMakeInvoice_MetadataTooLarge(t *testing.T) {
|
|||
transaction, err := transactionsService.MakeInvoice(ctx, 1234, "Hello world", "", 0, metadata, svc.LNClient, nil, nil)
|
||||
|
||||
assert.Error(t, err)
|
||||
assert.Equal(t, "encoded invoice metadata provided is too large. Limit: 2048 Received: 2049", err.Error())
|
||||
assert.Equal(t, fmt.Sprintf("encoded invoice metadata provided is too large. Limit: %d Received: %d", constants.INVOICE_METADATA_MAX_LENGTH, constants.INVOICE_METADATA_MAX_LENGTH+1), err.Error())
|
||||
assert.Nil(t, transaction)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue