Skip to content

Commit

Permalink
add test to show negative balances are no longer possible
Browse files Browse the repository at this point in the history
  • Loading branch information
kiwiidb committed Jul 5, 2023
1 parent 9a6f9ab commit 3497d53
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 2 additions & 8 deletions integration_tests/hodl_invoice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type HodlInvoiceSuite struct {

func (suite *HodlInvoiceSuite) SetupSuite() {
mlnd := newDefaultMockLND()
externalLND, err := NewMockLND("1234567890abcdefabcd", 0, make(chan (*lnrpc.Invoice)))
externalLND, err := NewMockLND("1234567890abcdefabcd", 0, make(chan (*lnrpc.Invoice), 5))
if err != nil {
log.Fatalf("Error initializing test service: %v", err)
}
Expand Down Expand Up @@ -307,17 +307,11 @@ func (suite *HodlInvoiceSuite) TestNegativeBalanceWithHodl() {
Status: lnrpc.Payment_SUCCEEDED,
FailureReason: 0,
})
//wait a bit for db update to happen
time.Sleep(time.Second)

if err != nil {
fmt.Printf("Error when getting balance %v\n", err.Error())
}
//fetch user balance again
userBalance, err := suite.service.CurrentUserBalance(context.Background(), userId)
assert.NoError(suite.T(), err)
//assert the balance is negative
assert.True(suite.T(), userBalance < 0)
assert.False(suite.T(), userBalance < 0)
}

func (suite *HodlInvoiceSuite) TearDownSuite() {
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/lnd_mock_hodl.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (hps *HodlPaymentSubscriber) Recv() (*lnrpc.Payment, error) {
func NewLNDMockHodlWrapperAsync(lnd lnd.LightningClientWrapper) (result *LNDMockHodlWrapperAsync, err error) {
return &LNDMockHodlWrapperAsync{
hps: &HodlPaymentSubscriber{
ch: make(chan lnrpc.Payment),
ch: make(chan lnrpc.Payment, 5),
},
LightningClientWrapper: lnd,
}, nil
Expand Down

0 comments on commit 3497d53

Please sign in to comment.