mirror of
https://github.com/getAlby/lndhub.go.git
synced 2025-12-21 22:54:48 +01:00
add unit test to reproduce issue
This commit is contained in:
@@ -3,6 +3,7 @@ package integration_tests
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
@@ -87,6 +88,20 @@ func (suite *InvoiceTestSuite) TestAddInvoiceForNonExistingUser() {
|
|||||||
nonExistingLogin := suite.aliceLogin.Login + "abc"
|
nonExistingLogin := suite.aliceLogin.Login + "abc"
|
||||||
suite.createInvoiceReqError(10, "test invoice without token", nonExistingLogin)
|
suite.createInvoiceReqError(10, "test invoice without token", nonExistingLogin)
|
||||||
}
|
}
|
||||||
|
func (suite *InvoiceTestSuite) TestPreimageEntropy() {
|
||||||
|
user, _ := suite.service.FindUserByLogin(context.Background(), suite.aliceLogin.Login)
|
||||||
|
preimageChars := map[byte]int{}
|
||||||
|
for i := 0; i < 1000; i++ {
|
||||||
|
inv, err := suite.service.AddIncomingInvoice(context.Background(), user.ID, 10, "test entropy", "")
|
||||||
|
assert.NoError(suite.T(), err)
|
||||||
|
primgBytes, _ := hex.DecodeString(inv.Preimage)
|
||||||
|
for _, char := range primgBytes {
|
||||||
|
preimageChars[char] += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//check that we use all possible byte values
|
||||||
|
assert.Equal(suite.T(), 255, len(preimageChars))
|
||||||
|
}
|
||||||
|
|
||||||
func TestInvoiceSuite(t *testing.T) {
|
func TestInvoiceSuite(t *testing.T) {
|
||||||
suite.Run(t, new(InvoiceTestSuite))
|
suite.Run(t, new(InvoiceTestSuite))
|
||||||
|
|||||||
Reference in New Issue
Block a user