mirror of
https://github.com/callebtc/electronwall.git
synced 2025-12-17 15:14:25 +01:00
fix test
This commit is contained in:
34
main_test.go
34
main_test.go
@@ -2,12 +2,14 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/hex"
|
||||||
|
"testing"
|
||||||
|
|
||||||
"github.com/callebtc/electronwall/config"
|
"github.com/callebtc/electronwall/config"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc"
|
"github.com/lightningnetwork/lnd/lnrpc"
|
||||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"testing"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestApp(t *testing.T) {
|
func TestApp(t *testing.T) {
|
||||||
@@ -451,16 +453,16 @@ func TestChannelAllowlist_CorrectKey(t *testing.T) {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
app := NewApp(ctx, client)
|
app := NewApp(ctx, client)
|
||||||
|
pubkey_str := "03006fcf3312dae8d068ea297f58e2bd00ec1ffe214b793eda46966b6294a53ce6"
|
||||||
config.Configuration.ChannelMode = "allowlist"
|
config.Configuration.ChannelMode = "allowlist"
|
||||||
config.Configuration.ChannelAllowlist = []string{"03006fcf3312dae8d068ea297f58e2bd00ec1ffe214b793eda46966b6294a53ce6"}
|
config.Configuration.ChannelAllowlist = []string{pubkey_str}
|
||||||
|
|
||||||
app.DispatchChannelAcceptor(ctx)
|
app.DispatchChannelAcceptor(ctx)
|
||||||
|
|
||||||
// correct key: should be allowed
|
// correct key: should be allowed
|
||||||
|
pubkey, _ := hex.DecodeString(pubkey_str)
|
||||||
client.channelAcceptorRequests <- &lnrpc.ChannelAcceptRequest{
|
client.channelAcceptorRequests <- &lnrpc.ChannelAcceptRequest{
|
||||||
NodePubkey: []byte("03006fcf3312dae8d068ea297f58e2bd00ec1ffe214b793eda46966b6294a53ce6"),
|
NodePubkey: pubkey,
|
||||||
FundingAmt: 1337000,
|
FundingAmt: 1337000,
|
||||||
PendingChanId: []byte("759495353533530113"),
|
PendingChanId: []byte("759495353533530113"),
|
||||||
}
|
}
|
||||||
@@ -476,8 +478,9 @@ func TestChannelAllowlist_WrongKey(t *testing.T) {
|
|||||||
|
|
||||||
app := NewApp(ctx, client)
|
app := NewApp(ctx, client)
|
||||||
|
|
||||||
|
pubkey_str := "03006fcf3312dae8d068ea297f58e2bd00ec1ffe214b793eda46966b6294a53ce6"
|
||||||
config.Configuration.ChannelMode = "allowlist"
|
config.Configuration.ChannelMode = "allowlist"
|
||||||
config.Configuration.ChannelAllowlist = []string{"03006fcf3312dae8d068ea297f58e2bd00ec1ffe214b793eda46966b6294a53ce6"}
|
config.Configuration.ChannelAllowlist = []string{pubkey_str}
|
||||||
|
|
||||||
app.DispatchChannelAcceptor(ctx)
|
app.DispatchChannelAcceptor(ctx)
|
||||||
// wrong key: should be denied
|
// wrong key: should be denied
|
||||||
@@ -500,12 +503,14 @@ func TestChannelAllowlist_Wildcard(t *testing.T) {
|
|||||||
|
|
||||||
app.DispatchChannelAcceptor(ctx)
|
app.DispatchChannelAcceptor(ctx)
|
||||||
|
|
||||||
|
pubkey_str := "03006fcf3312dae8d068ea297f58e2bd00ec1ffe214b793eda46966b6294a53ce6"
|
||||||
// wildcard: should be allowed
|
// wildcard: should be allowed
|
||||||
config.Configuration.ChannelMode = "allowlist"
|
config.Configuration.ChannelMode = "allowlist"
|
||||||
config.Configuration.ChannelAllowlist = []string{"*"}
|
config.Configuration.ChannelAllowlist = []string{"*"}
|
||||||
|
|
||||||
|
pubkey, _ := hex.DecodeString(pubkey_str)
|
||||||
client.channelAcceptorRequests <- &lnrpc.ChannelAcceptRequest{
|
client.channelAcceptorRequests <- &lnrpc.ChannelAcceptRequest{
|
||||||
NodePubkey: []byte("03006fcf3312dae8d068ea297f58e2bd00ec1ffe214b793eda46966b6294a53ce6"),
|
NodePubkey: pubkey,
|
||||||
FundingAmt: 1337000,
|
FundingAmt: 1337000,
|
||||||
PendingChanId: []byte("759495353533530113"),
|
PendingChanId: []byte("759495353533530113"),
|
||||||
}
|
}
|
||||||
@@ -520,16 +525,16 @@ func TestChannelDenylist_Match(t *testing.T) {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
app := NewApp(ctx, client)
|
app := NewApp(ctx, client)
|
||||||
|
pubkey_str := "03006fcf3312dae8d068ea297f58e2bd00ec1ffe214b793eda46966b6294a53ce6"
|
||||||
config.Configuration.ChannelMode = "denylist"
|
config.Configuration.ChannelMode = "denylist"
|
||||||
config.Configuration.ChannelDenylist = []string{"03006fcf3312dae8d068ea297f58e2bd00ec1ffe214b793eda46966b6294a53ce6"}
|
config.Configuration.ChannelDenylist = []string{pubkey_str}
|
||||||
|
|
||||||
app.DispatchChannelAcceptor(ctx)
|
app.DispatchChannelAcceptor(ctx)
|
||||||
|
|
||||||
// should be denied
|
// should be denied
|
||||||
|
pubkey, _ := hex.DecodeString(pubkey_str)
|
||||||
client.channelAcceptorRequests <- &lnrpc.ChannelAcceptRequest{
|
client.channelAcceptorRequests <- &lnrpc.ChannelAcceptRequest{
|
||||||
NodePubkey: []byte("03006fcf3312dae8d068ea297f58e2bd00ec1ffe214b793eda46966b6294a53ce6"),
|
NodePubkey: []byte(pubkey),
|
||||||
FundingAmt: 1337000,
|
FundingAmt: 1337000,
|
||||||
PendingChanId: []byte("759495353533530113"),
|
PendingChanId: []byte("759495353533530113"),
|
||||||
}
|
}
|
||||||
@@ -544,15 +549,16 @@ func TestChannelAllowlist_Match(t *testing.T) {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
app := NewApp(ctx, client)
|
app := NewApp(ctx, client)
|
||||||
|
pubkey_str := "03006fcf3312dae8d068ea297f58e2bd00ec1ffe214b793eda46966b6294a53ce6"
|
||||||
config.Configuration.ChannelMode = "allowlist"
|
config.Configuration.ChannelMode = "allowlist"
|
||||||
config.Configuration.ChannelAllowlist = []string{"03006fcf3312dae8d068ea297f58e2bd00ec1ffe214b793eda46966b6294a53ce6"}
|
config.Configuration.ChannelAllowlist = []string{pubkey_str}
|
||||||
|
|
||||||
app.DispatchChannelAcceptor(ctx)
|
app.DispatchChannelAcceptor(ctx)
|
||||||
|
|
||||||
// should be allowed
|
// should be allowed
|
||||||
|
pubkey, _ := hex.DecodeString(pubkey_str)
|
||||||
client.channelAcceptorRequests <- &lnrpc.ChannelAcceptRequest{
|
client.channelAcceptorRequests <- &lnrpc.ChannelAcceptRequest{
|
||||||
NodePubkey: []byte("03006fcf3312dae8d068ea297f58e2bd00ec1ffe214b793eda46966b6294a53ce6"),
|
NodePubkey: []byte(pubkey),
|
||||||
FundingAmt: 1337000,
|
FundingAmt: 1337000,
|
||||||
PendingChanId: []byte("759495353533530113"),
|
PendingChanId: []byte("759495353533530113"),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user