mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-03 17:26:57 +01:00
funding: make expectsChanType a pointer
This allows us to expect chanType to be nil, which will be possible after the next commit.
This commit is contained in:
parent
34186dee19
commit
0ae9c63d64
1 changed files with 47 additions and 33 deletions
|
@ -20,7 +20,7 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
|
||||||
localFeatures *lnwire.RawFeatureVector
|
localFeatures *lnwire.RawFeatureVector
|
||||||
remoteFeatures *lnwire.RawFeatureVector
|
remoteFeatures *lnwire.RawFeatureVector
|
||||||
expectsCommitType lnwallet.CommitmentType
|
expectsCommitType lnwallet.CommitmentType
|
||||||
expectsChanType lnwire.ChannelType
|
expectsChanType *lnwire.ChannelType
|
||||||
zeroConf bool
|
zeroConf bool
|
||||||
scidAlias bool
|
scidAlias bool
|
||||||
expectsErr error
|
expectsErr error
|
||||||
|
@ -41,10 +41,12 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
|
||||||
lnwire.AnchorsZeroFeeHtlcTxOptional,
|
lnwire.AnchorsZeroFeeHtlcTxOptional,
|
||||||
),
|
),
|
||||||
expectsCommitType: lnwallet.CommitmentTypeAnchorsZeroFeeHtlcTx,
|
expectsCommitType: lnwallet.CommitmentTypeAnchorsZeroFeeHtlcTx,
|
||||||
expectsChanType: lnwire.ChannelType(*lnwire.NewRawFeatureVector(
|
expectsChanType: (*lnwire.ChannelType)(
|
||||||
lnwire.StaticRemoteKeyRequired,
|
lnwire.NewRawFeatureVector(
|
||||||
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
lnwire.StaticRemoteKeyRequired,
|
||||||
)),
|
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
||||||
|
),
|
||||||
|
),
|
||||||
expectsErr: nil,
|
expectsErr: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -106,8 +108,8 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
|
||||||
lnwire.ExplicitChannelTypeOptional,
|
lnwire.ExplicitChannelTypeOptional,
|
||||||
),
|
),
|
||||||
expectsCommitType: lnwallet.CommitmentTypeScriptEnforcedLease,
|
expectsCommitType: lnwallet.CommitmentTypeScriptEnforcedLease,
|
||||||
expectsChanType: lnwire.ChannelType(
|
expectsChanType: (*lnwire.ChannelType)(
|
||||||
*lnwire.NewRawFeatureVector(
|
lnwire.NewRawFeatureVector(
|
||||||
lnwire.ZeroConfRequired,
|
lnwire.ZeroConfRequired,
|
||||||
lnwire.StaticRemoteKeyRequired,
|
lnwire.StaticRemoteKeyRequired,
|
||||||
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
||||||
|
@ -137,8 +139,8 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
|
||||||
lnwire.ExplicitChannelTypeOptional,
|
lnwire.ExplicitChannelTypeOptional,
|
||||||
),
|
),
|
||||||
expectsCommitType: lnwallet.CommitmentTypeAnchorsZeroFeeHtlcTx,
|
expectsCommitType: lnwallet.CommitmentTypeAnchorsZeroFeeHtlcTx,
|
||||||
expectsChanType: lnwire.ChannelType(
|
expectsChanType: (*lnwire.ChannelType)(
|
||||||
*lnwire.NewRawFeatureVector(
|
lnwire.NewRawFeatureVector(
|
||||||
lnwire.ZeroConfRequired,
|
lnwire.ZeroConfRequired,
|
||||||
lnwire.StaticRemoteKeyRequired,
|
lnwire.StaticRemoteKeyRequired,
|
||||||
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
||||||
|
@ -170,8 +172,8 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
|
||||||
lnwire.ExplicitChannelTypeOptional,
|
lnwire.ExplicitChannelTypeOptional,
|
||||||
),
|
),
|
||||||
expectsCommitType: lnwallet.CommitmentTypeScriptEnforcedLease,
|
expectsCommitType: lnwallet.CommitmentTypeScriptEnforcedLease,
|
||||||
expectsChanType: lnwire.ChannelType(
|
expectsChanType: (*lnwire.ChannelType)(
|
||||||
*lnwire.NewRawFeatureVector(
|
lnwire.NewRawFeatureVector(
|
||||||
lnwire.ScidAliasRequired,
|
lnwire.ScidAliasRequired,
|
||||||
lnwire.StaticRemoteKeyRequired,
|
lnwire.StaticRemoteKeyRequired,
|
||||||
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
||||||
|
@ -201,8 +203,8 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
|
||||||
lnwire.ExplicitChannelTypeOptional,
|
lnwire.ExplicitChannelTypeOptional,
|
||||||
),
|
),
|
||||||
expectsCommitType: lnwallet.CommitmentTypeAnchorsZeroFeeHtlcTx,
|
expectsCommitType: lnwallet.CommitmentTypeAnchorsZeroFeeHtlcTx,
|
||||||
expectsChanType: lnwire.ChannelType(
|
expectsChanType: (*lnwire.ChannelType)(
|
||||||
*lnwire.NewRawFeatureVector(
|
lnwire.NewRawFeatureVector(
|
||||||
lnwire.ScidAliasRequired,
|
lnwire.ScidAliasRequired,
|
||||||
lnwire.StaticRemoteKeyRequired,
|
lnwire.StaticRemoteKeyRequired,
|
||||||
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
||||||
|
@ -228,10 +230,12 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
|
||||||
lnwire.ExplicitChannelTypeOptional,
|
lnwire.ExplicitChannelTypeOptional,
|
||||||
),
|
),
|
||||||
expectsCommitType: lnwallet.CommitmentTypeAnchorsZeroFeeHtlcTx,
|
expectsCommitType: lnwallet.CommitmentTypeAnchorsZeroFeeHtlcTx,
|
||||||
expectsChanType: lnwire.ChannelType(*lnwire.NewRawFeatureVector(
|
expectsChanType: (*lnwire.ChannelType)(
|
||||||
lnwire.StaticRemoteKeyRequired,
|
lnwire.NewRawFeatureVector(
|
||||||
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
lnwire.StaticRemoteKeyRequired,
|
||||||
)),
|
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
||||||
|
),
|
||||||
|
),
|
||||||
expectsErr: nil,
|
expectsErr: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -250,9 +254,11 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
|
||||||
lnwire.ExplicitChannelTypeOptional,
|
lnwire.ExplicitChannelTypeOptional,
|
||||||
),
|
),
|
||||||
expectsCommitType: lnwallet.CommitmentTypeTweakless,
|
expectsCommitType: lnwallet.CommitmentTypeTweakless,
|
||||||
expectsChanType: lnwire.ChannelType(*lnwire.NewRawFeatureVector(
|
expectsChanType: (*lnwire.ChannelType)(
|
||||||
lnwire.StaticRemoteKeyRequired,
|
lnwire.NewRawFeatureVector(
|
||||||
)),
|
lnwire.StaticRemoteKeyRequired,
|
||||||
|
),
|
||||||
|
),
|
||||||
expectsErr: nil,
|
expectsErr: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -269,8 +275,10 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
|
||||||
lnwire.ExplicitChannelTypeOptional,
|
lnwire.ExplicitChannelTypeOptional,
|
||||||
),
|
),
|
||||||
expectsCommitType: lnwallet.CommitmentTypeLegacy,
|
expectsCommitType: lnwallet.CommitmentTypeLegacy,
|
||||||
expectsChanType: lnwire.ChannelType(*lnwire.NewRawFeatureVector()),
|
expectsChanType: (*lnwire.ChannelType)(
|
||||||
expectsErr: nil,
|
lnwire.NewRawFeatureVector(),
|
||||||
|
),
|
||||||
|
expectsErr: nil,
|
||||||
},
|
},
|
||||||
// Both sides signal the explicit chan type bit, so we expect
|
// Both sides signal the explicit chan type bit, so we expect
|
||||||
// that we return the corresponding chan type feature bits,
|
// that we return the corresponding chan type feature bits,
|
||||||
|
@ -289,10 +297,12 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
|
||||||
lnwire.ExplicitChannelTypeOptional,
|
lnwire.ExplicitChannelTypeOptional,
|
||||||
),
|
),
|
||||||
expectsCommitType: lnwallet.CommitmentTypeAnchorsZeroFeeHtlcTx,
|
expectsCommitType: lnwallet.CommitmentTypeAnchorsZeroFeeHtlcTx,
|
||||||
expectsChanType: lnwire.ChannelType(*lnwire.NewRawFeatureVector(
|
expectsChanType: (*lnwire.ChannelType)(
|
||||||
lnwire.StaticRemoteKeyRequired,
|
lnwire.NewRawFeatureVector(
|
||||||
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
lnwire.StaticRemoteKeyRequired,
|
||||||
)),
|
lnwire.AnchorsZeroFeeHtlcTxRequired,
|
||||||
|
),
|
||||||
|
),
|
||||||
expectsErr: nil,
|
expectsErr: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -306,9 +316,11 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
|
||||||
lnwire.StaticRemoteKeyOptional,
|
lnwire.StaticRemoteKeyOptional,
|
||||||
),
|
),
|
||||||
expectsCommitType: lnwallet.CommitmentTypeTweakless,
|
expectsCommitType: lnwallet.CommitmentTypeTweakless,
|
||||||
expectsChanType: lnwire.ChannelType(*lnwire.NewRawFeatureVector(
|
expectsChanType: (*lnwire.ChannelType)(
|
||||||
lnwire.StaticRemoteKeyRequired,
|
lnwire.NewRawFeatureVector(
|
||||||
)),
|
lnwire.StaticRemoteKeyRequired,
|
||||||
|
),
|
||||||
|
),
|
||||||
expectsErr: nil,
|
expectsErr: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -320,8 +332,10 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
|
||||||
lnwire.AnchorsZeroFeeHtlcTxOptional,
|
lnwire.AnchorsZeroFeeHtlcTxOptional,
|
||||||
),
|
),
|
||||||
expectsCommitType: lnwallet.CommitmentTypeLegacy,
|
expectsCommitType: lnwallet.CommitmentTypeLegacy,
|
||||||
expectsChanType: lnwire.ChannelType(*lnwire.NewRawFeatureVector()),
|
expectsChanType: (*lnwire.ChannelType)(
|
||||||
expectsErr: nil,
|
lnwire.NewRawFeatureVector(),
|
||||||
|
),
|
||||||
|
expectsErr: nil,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -402,11 +416,11 @@ func TestCommitmentTypeNegotiation(t *testing.T) {
|
||||||
)
|
)
|
||||||
|
|
||||||
require.Equal(
|
require.Equal(
|
||||||
t, testCase.expectsChanType, *lChan,
|
t, testCase.expectsChanType, lChan,
|
||||||
testCase.name,
|
testCase.name,
|
||||||
)
|
)
|
||||||
require.Equal(
|
require.Equal(
|
||||||
t, testCase.expectsChanType, *rChan,
|
t, testCase.expectsChanType, rChan,
|
||||||
testCase.name,
|
testCase.name,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Reference in a new issue