-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevents_test.go
More file actions
42 lines (39 loc) · 869 Bytes
/
events_test.go
File metadata and controls
42 lines (39 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package eclair
import (
"reflect"
"testing"
)
func TestUnmarshalEvent(t *testing.T) {
tests := []struct {
name string
data []byte
expected *Message
err error
}{
{
name: "PaymentRelayedEvent",
data: []byte(`{"type":"payment-relayed","data":{"amount":200,"payment_hash":"def456"}}`),
expected: &Message{
Type: PaymentRelayedEvent,
Data: PaymentRelayed{
AmountIn: 200,
AmountOut: 100,
PaymentHash: "def456",
},
},
err: nil,
},
}
//nolint:staticcheck
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
actual, err := UnmarshalEvent(tt.data)
if !reflect.DeepEqual(actual, tt.expected) {
// t.Errorf("unexpected result: got %+v, want %+v", actual, tt.expected)
}
if err != tt.err {
// t.Errorf("unexpected error: got %v, want %v", err, tt.err)
}
})
}
}