routing: add new TestEmptyRoutesGenerateSphinxPacket test

This commit is contained in:
Olaoluwa Osuntokun 2018-07-30 13:40:20 -07:00
parent 098cd940e3
commit c903a9a711
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

@ -9,14 +9,14 @@ import (
"testing"
"time"
"github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/channeldb"
"github.com/lightningnetwork/lnd/htlcswitch"
"github.com/btcsuite/btcd/wire"
"github.com/btcsuite/btcd/btcec"
"github.com/davecgh/go-spew/spew"
"github.com/lightningnetwork/lightning-onion"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/btcsuite/btcd/btcec"
)
// defaultNumRoutes is the default value for the maximum number of routes to
@ -1941,3 +1941,16 @@ func TestIsStaleEdgePolicy(t *testing.T) {
t.Fatalf("router failed to detect fresh edge policy")
}
}
// TestEmptyRoutesGenerateSphinxPacket tests that the generateSphinxPacket
// function is able to gracefully handle being passed a nil set of hops for the
// route by the caller.
func TestEmptyRoutesGenerateSphinxPacket(t *testing.T) {
t.Parallel()
emptyRoute := &Route{}
_, _, err := generateSphinxPacket(emptyRoute, testHash[:])
if err != ErrNoRouteHopsProvided {
t.Fatalf("expected empty hops error: instead got: %v", err)
}
}