Skip to content

Commit 2998f5b

Browse files
authored
Merge pull request #9644 from ziggie1984/payment-unit-test
Add unit test to record pkg
2 parents d1093cd + 3952cf3 commit 2998f5b

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

record/custom_records_test.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package record
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/require"
7+
)
8+
9+
// TestCustomRecordKeysend tests that a keysend entry is always detected in a
10+
// custom record set.
11+
func TestCustomRecordKeysend(t *testing.T) {
12+
tests := []struct {
13+
name string
14+
records CustomSet
15+
expectedKeySend bool
16+
}{
17+
{
18+
name: "empty custom set",
19+
records: make(CustomSet),
20+
expectedKeySend: false,
21+
},
22+
{
23+
name: "contains keysend record",
24+
records: CustomSet{
25+
KeySendType: []byte{1, 2, 3},
26+
},
27+
expectedKeySend: true,
28+
},
29+
{
30+
name: "contains other records but no keysend",
31+
records: CustomSet{
32+
CustomTypeStart: []byte{1, 2, 3},
33+
},
34+
expectedKeySend: false,
35+
},
36+
{
37+
name: "contains keysend and other records",
38+
records: CustomSet{
39+
KeySendType: []byte{1},
40+
CustomTypeStart: []byte{2},
41+
},
42+
expectedKeySend: true,
43+
},
44+
}
45+
46+
for _, test := range tests {
47+
t.Run(test.name, func(t *testing.T) {
48+
t.Parallel()
49+
50+
result := test.records.IsKeysend()
51+
require.Equal(t, test.expectedKeySend, result)
52+
})
53+
}
54+
}

0 commit comments

Comments
 (0)