channeldb+htlcswitch: don't use fastsha256 in tests
The btcsuite/fastsha256 registers itself in the crypto package of golang as a replacement for sha256. This causes problems in TLS1.3 connections that require the hash implementations to be serializable and results in the "tls: internal error: failed to clone hash" error. By removing all uses of the library we fix that error.
This commit is contained in:
parent
afc60353a1
commit
a17ddc5dd1
@ -2,6 +2,7 @@ package channeldb
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
@ -9,7 +10,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/fastsha256"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/record"
|
||||
@ -46,7 +46,7 @@ func genInfo() (*PaymentCreationInfo, *HTLCAttemptInfo,
|
||||
"generate preimage: %v", err)
|
||||
}
|
||||
|
||||
rhash := fastsha256.Sum256(preimage[:])
|
||||
rhash := sha256.Sum256(preimage[:])
|
||||
return &PaymentCreationInfo{
|
||||
PaymentHash: rhash,
|
||||
Value: testRoute.ReceiverAmt(),
|
||||
|
1
go.mod
1
go.mod
@ -14,7 +14,6 @@ require (
|
||||
github.com/btcsuite/btcwallet/wallet/txrules v1.0.0
|
||||
github.com/btcsuite/btcwallet/walletdb v1.3.1
|
||||
github.com/btcsuite/btcwallet/wtxmgr v1.1.1-0.20200515224913-e0e62245ecbe
|
||||
github.com/btcsuite/fastsha256 v0.0.0-20160815193821-637e65642941
|
||||
github.com/davecgh/go-spew v1.1.1
|
||||
github.com/go-errors/errors v1.0.1
|
||||
github.com/go-openapi/strfmt v0.19.5 // indirect
|
||||
|
2
go.sum
2
go.sum
@ -52,8 +52,6 @@ github.com/btcsuite/btcwallet/wtxmgr v1.0.0 h1:aIHgViEmZmZfe0tQQqF1xyd2qBqFWxX5v
|
||||
github.com/btcsuite/btcwallet/wtxmgr v1.0.0/go.mod h1:vc4gBprll6BP0UJ+AIGDaySoc7MdAmZf8kelfNb8CFY=
|
||||
github.com/btcsuite/btcwallet/wtxmgr v1.1.1-0.20200515224913-e0e62245ecbe h1:yQbJVYfsKbdqDQNLxd4hhiLSiMkIygefW5mSHMsdKpc=
|
||||
github.com/btcsuite/btcwallet/wtxmgr v1.1.1-0.20200515224913-e0e62245ecbe/go.mod h1:OwC0W0HhUszbWdvJvH6xvgabKSJ0lXl11YbmmqF9YXQ=
|
||||
github.com/btcsuite/fastsha256 v0.0.0-20160815193821-637e65642941 h1:kij1x2aL7VE6gtx8KMIt8PGPgI5GV9LgtHFG5KaEMPY=
|
||||
github.com/btcsuite/fastsha256 v0.0.0-20160815193821-637e65642941/go.mod h1:QcFA8DZHtuIAdYKCq/BzELOaznRsCvwf4zTPmaYwaig=
|
||||
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd h1:R/opQEbFEy9JGkIguV40SvRY1uliPX8ifOvi6ICsFCw=
|
||||
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg=
|
||||
github.com/btcsuite/golangcrypto v0.0.0-20150304025918-53f62d9b43e8 h1:nOsAWScwueMVk/VLm/dvQQD7DuanyvAUb6B3P3eT274=
|
||||
|
@ -11,7 +11,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/btcsuite/fastsha256"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/htlcswitch/hop"
|
||||
@ -199,7 +198,7 @@ func TestSwitchSendPending(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to generate preimage: %v", err)
|
||||
}
|
||||
rhash := fastsha256.Sum256(preimage[:])
|
||||
rhash := sha256.Sum256(preimage[:])
|
||||
packet := &htlcPacket{
|
||||
incomingChanID: bobChanID,
|
||||
incomingHTLCID: 0,
|
||||
@ -309,7 +308,7 @@ func TestSwitchForward(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to generate preimage: %v", err)
|
||||
}
|
||||
rhash := fastsha256.Sum256(preimage[:])
|
||||
rhash := sha256.Sum256(preimage[:])
|
||||
packet := &htlcPacket{
|
||||
incomingChanID: aliceChannelLink.ShortChanID(),
|
||||
incomingHTLCID: 0,
|
||||
@ -431,7 +430,7 @@ func TestSwitchForwardFailAfterFullAdd(t *testing.T) {
|
||||
// Create request which should be forwarded from Alice channel link to
|
||||
// bob channel link.
|
||||
preimage := [sha256.Size]byte{1}
|
||||
rhash := fastsha256.Sum256(preimage[:])
|
||||
rhash := sha256.Sum256(preimage[:])
|
||||
ogPacket := &htlcPacket{
|
||||
incomingChanID: aliceChannelLink.ShortChanID(),
|
||||
incomingHTLCID: 0,
|
||||
@ -626,7 +625,7 @@ func TestSwitchForwardSettleAfterFullAdd(t *testing.T) {
|
||||
// Create request which should be forwarded from Alice channel link to
|
||||
// bob channel link.
|
||||
preimage := [sha256.Size]byte{1}
|
||||
rhash := fastsha256.Sum256(preimage[:])
|
||||
rhash := sha256.Sum256(preimage[:])
|
||||
ogPacket := &htlcPacket{
|
||||
incomingChanID: aliceChannelLink.ShortChanID(),
|
||||
incomingHTLCID: 0,
|
||||
@ -824,7 +823,7 @@ func TestSwitchForwardDropAfterFullAdd(t *testing.T) {
|
||||
// Create request which should be forwarded from Alice channel link to
|
||||
// bob channel link.
|
||||
preimage := [sha256.Size]byte{1}
|
||||
rhash := fastsha256.Sum256(preimage[:])
|
||||
rhash := sha256.Sum256(preimage[:])
|
||||
ogPacket := &htlcPacket{
|
||||
incomingChanID: aliceChannelLink.ShortChanID(),
|
||||
incomingHTLCID: 0,
|
||||
@ -991,7 +990,7 @@ func TestSwitchForwardFailAfterHalfAdd(t *testing.T) {
|
||||
// Create request which should be forwarded from Alice channel link to
|
||||
// bob channel link.
|
||||
preimage := [sha256.Size]byte{1}
|
||||
rhash := fastsha256.Sum256(preimage[:])
|
||||
rhash := sha256.Sum256(preimage[:])
|
||||
ogPacket := &htlcPacket{
|
||||
incomingChanID: aliceChannelLink.ShortChanID(),
|
||||
incomingHTLCID: 0,
|
||||
@ -1157,7 +1156,7 @@ func TestSwitchForwardCircuitPersistence(t *testing.T) {
|
||||
// Create request which should be forwarded from Alice channel link to
|
||||
// bob channel link.
|
||||
preimage := [sha256.Size]byte{1}
|
||||
rhash := fastsha256.Sum256(preimage[:])
|
||||
rhash := sha256.Sum256(preimage[:])
|
||||
ogPacket := &htlcPacket{
|
||||
incomingChanID: aliceChannelLink.ShortChanID(),
|
||||
incomingHTLCID: 0,
|
||||
@ -1345,7 +1344,7 @@ type multiHopFwdTest struct {
|
||||
func TestCircularForwards(t *testing.T) {
|
||||
chanID1, aliceChanID := genID()
|
||||
preimage := [sha256.Size]byte{1}
|
||||
hash := fastsha256.Sum256(preimage[:])
|
||||
hash := sha256.Sum256(preimage[:])
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
@ -1623,7 +1622,7 @@ func testSkipIneligibleLinksMultiHopForward(t *testing.T,
|
||||
// Create a new packet that's destined for Bob as an incoming HTLC from
|
||||
// Alice.
|
||||
preimage := [sha256.Size]byte{1}
|
||||
rhash := fastsha256.Sum256(preimage[:])
|
||||
rhash := sha256.Sum256(preimage[:])
|
||||
obfuscator := NewMockObfuscator()
|
||||
packet = &htlcPacket{
|
||||
incomingChanID: aliceChannelLink.ShortChanID(),
|
||||
@ -1716,7 +1715,7 @@ func testSkipLinkLocalForward(t *testing.T, eligible bool,
|
||||
if err != nil {
|
||||
t.Fatalf("unable to generate preimage: %v", err)
|
||||
}
|
||||
rhash := fastsha256.Sum256(preimage[:])
|
||||
rhash := sha256.Sum256(preimage[:])
|
||||
addMsg := &lnwire.UpdateAddHTLC{
|
||||
PaymentHash: rhash,
|
||||
Amount: 1,
|
||||
@ -1783,7 +1782,7 @@ func TestSwitchCancel(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to generate preimage: %v", err)
|
||||
}
|
||||
rhash := fastsha256.Sum256(preimage[:])
|
||||
rhash := sha256.Sum256(preimage[:])
|
||||
request := &htlcPacket{
|
||||
incomingChanID: aliceChannelLink.ShortChanID(),
|
||||
incomingHTLCID: 0,
|
||||
@ -1898,7 +1897,7 @@ func TestSwitchAddSamePayment(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to generate preimage: %v", err)
|
||||
}
|
||||
rhash := fastsha256.Sum256(preimage[:])
|
||||
rhash := sha256.Sum256(preimage[:])
|
||||
request := &htlcPacket{
|
||||
incomingChanID: aliceChannelLink.ShortChanID(),
|
||||
incomingHTLCID: 0,
|
||||
@ -2051,7 +2050,7 @@ func TestSwitchSendPayment(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to generate preimage: %v", err)
|
||||
}
|
||||
rhash := fastsha256.Sum256(preimage[:])
|
||||
rhash := sha256.Sum256(preimage[:])
|
||||
update := &lnwire.UpdateAddHTLC{
|
||||
PaymentHash: rhash,
|
||||
Amount: 1,
|
||||
@ -2594,7 +2593,7 @@ func TestInvalidFailure(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to generate preimage: %v", err)
|
||||
}
|
||||
rhash := fastsha256.Sum256(preimage[:])
|
||||
rhash := sha256.Sum256(preimage[:])
|
||||
update := &lnwire.UpdateAddHTLC{
|
||||
PaymentHash: rhash,
|
||||
Amount: 1,
|
||||
|
@ -20,7 +20,6 @@ import (
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/btcsuite/fastsha256"
|
||||
"github.com/go-errors/errors"
|
||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
@ -598,7 +597,7 @@ func generatePayment(invoiceAmt, htlcAmt lnwire.MilliSatoshi, timelock uint32,
|
||||
}
|
||||
copy(preimage[:], r)
|
||||
|
||||
rhash := fastsha256.Sum256(preimage[:])
|
||||
rhash := sha256.Sum256(preimage[:])
|
||||
return generatePaymentWithPreimage(
|
||||
invoiceAmt, htlcAmt, timelock, blob, preimage, rhash,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user