@@ -77,3 +77,53 @@ func TestAuxDataParser(t *testing.T) {
77
77
require .NotNil (t , resp )
78
78
require .Equal (t , []byte {0x00 , 0x00 }, resp .CustomChannelData )
79
79
}
80
+
81
+ // TestRpcCommitmentType tests the rpcCommitmentType returns the corect
82
+ // commitment type given a channel type.
83
+ func TestRpcCommitmentType (t * testing.T ) {
84
+ tests := []struct {
85
+ name string
86
+ chanType channeldb.ChannelType
87
+ want lnrpc.CommitmentType
88
+ }{
89
+ {
90
+ name : "tapscript overlay" ,
91
+ chanType : channeldb .SimpleTaprootFeatureBit |
92
+ channeldb .TapscriptRootBit ,
93
+ want : lnrpc .CommitmentType_SIMPLE_TAPROOT_OVERLAY ,
94
+ },
95
+ {
96
+ name : "simple taproot" ,
97
+ chanType : channeldb .SimpleTaprootFeatureBit ,
98
+ want : lnrpc .CommitmentType_SIMPLE_TAPROOT ,
99
+ },
100
+ {
101
+ name : "lease expiration" ,
102
+ chanType : channeldb .LeaseExpirationBit ,
103
+ want : lnrpc .CommitmentType_SCRIPT_ENFORCED_LEASE ,
104
+ },
105
+ {
106
+ name : "anchors" ,
107
+ chanType : channeldb .AnchorOutputsBit ,
108
+ want : lnrpc .CommitmentType_ANCHORS ,
109
+ },
110
+ {
111
+ name : "tweakless" ,
112
+ chanType : channeldb .SingleFunderTweaklessBit ,
113
+ want : lnrpc .CommitmentType_STATIC_REMOTE_KEY ,
114
+ },
115
+ {
116
+ name : "legacy" ,
117
+ chanType : channeldb .SingleFunderBit ,
118
+ want : lnrpc .CommitmentType_LEGACY ,
119
+ },
120
+ }
121
+
122
+ for _ , tt := range tests {
123
+ t .Run (tt .name , func (t * testing.T ) {
124
+ require .Equal (
125
+ t , tt .want , rpcCommitmentType (tt .chanType ),
126
+ )
127
+ })
128
+ }
129
+ }
0 commit comments