Skip to content

Commit

Permalink
fix: metadata tests and change comment
Browse files Browse the repository at this point in the history
  • Loading branch information
im-adithya committed Oct 9, 2024
1 parent abb4f17 commit a09d7fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ 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
// 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
Expand Down
3 changes: 2 additions & 1 deletion transactions/make_invoice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package transactions
import (
"context"
"encoding/json"
"fmt"
"strings"
"testing"

Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit a09d7fe

Please sign in to comment.