-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from getAlby/feature/block-malformed-keysend
add a check on wallet id tlv
- Loading branch information
Showing
3 changed files
with
114 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/lightningnetwork/lnd/lnrpc" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestCheckInvoice(t *testing.T) { | ||
//test non keysend | ||
assert.True(t, shouldPublishInvoice(&lnrpc.Invoice{ | ||
State: lnrpc.Invoice_SETTLED, | ||
IsKeysend: false, | ||
Htlcs: []*lnrpc.InvoiceHTLC{ | ||
{ | ||
ChanId: 0, | ||
HtlcIndex: 0, | ||
AmtMsat: 0, | ||
AcceptHeight: 0, | ||
AcceptTime: 0, | ||
ResolveTime: 0, | ||
ExpiryHeight: 0, | ||
State: 0, | ||
MppTotalAmtMsat: 0, | ||
Amp: &lnrpc.AMP{}, | ||
}, | ||
}, | ||
})) | ||
//test keysend with wallet id tlv | ||
assert.True(t, shouldPublishInvoice(&lnrpc.Invoice{ | ||
State: lnrpc.Invoice_SETTLED, | ||
IsKeysend: true, | ||
Htlcs: []*lnrpc.InvoiceHTLC{ | ||
{ | ||
ChanId: 0, | ||
HtlcIndex: 0, | ||
AmtMsat: 0, | ||
AcceptHeight: 0, | ||
AcceptTime: 0, | ||
ResolveTime: 0, | ||
ExpiryHeight: 0, | ||
State: 0, | ||
CustomRecords: map[uint64][]byte{ | ||
696969: {69, 69, 69}, | ||
}, | ||
MppTotalAmtMsat: 0, | ||
Amp: &lnrpc.AMP{}, | ||
}, | ||
}, | ||
})) | ||
//test keysend without wallet id tlv | ||
assert.False(t, shouldPublishInvoice(&lnrpc.Invoice{ | ||
State: lnrpc.Invoice_SETTLED, | ||
IsKeysend: true, | ||
Htlcs: []*lnrpc.InvoiceHTLC{ | ||
{ | ||
ChanId: 0, | ||
HtlcIndex: 0, | ||
AmtMsat: 0, | ||
AcceptHeight: 0, | ||
AcceptTime: 0, | ||
ResolveTime: 0, | ||
ExpiryHeight: 0, | ||
State: 0, | ||
CustomRecords: map[uint64][]byte{ | ||
696970: {69, 69, 70}, | ||
}, | ||
MppTotalAmtMsat: 0, | ||
Amp: &lnrpc.AMP{}, | ||
}, | ||
}, | ||
})) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters