mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-05 08:41:42 +02:00
lnwire: add MergedCopy method to CustomRecords
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
"github.com/lightningnetwork/lnd/fn"
|
||||
"github.com/lightningnetwork/lnd/tlv"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@@ -194,3 +195,54 @@ func serializeRecordProducers(t *testing.T,
|
||||
|
||||
return b.Bytes()
|
||||
}
|
||||
|
||||
func TestCustomRecordsMergedCopy(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
c CustomRecords
|
||||
other CustomRecords
|
||||
want CustomRecords
|
||||
}{
|
||||
{
|
||||
name: "nil records",
|
||||
want: make(CustomRecords),
|
||||
},
|
||||
{
|
||||
name: "empty records",
|
||||
c: make(CustomRecords),
|
||||
other: make(CustomRecords),
|
||||
want: make(CustomRecords),
|
||||
},
|
||||
{
|
||||
name: "distinct records",
|
||||
c: CustomRecords{
|
||||
1: {1, 2, 3},
|
||||
},
|
||||
other: CustomRecords{
|
||||
2: {4, 5, 6},
|
||||
},
|
||||
want: CustomRecords{
|
||||
1: {1, 2, 3},
|
||||
2: {4, 5, 6},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "same records, different values",
|
||||
c: CustomRecords{
|
||||
1: {1, 2, 3},
|
||||
},
|
||||
other: CustomRecords{
|
||||
1: {4, 5, 6},
|
||||
},
|
||||
want: CustomRecords{
|
||||
1: {4, 5, 6},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
result := tt.c.MergedCopy(tt.other)
|
||||
assert.Equal(t, tt.want, result)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user