Skip to content

Commit 37e373f

Browse files
committed
Introduce custom_data test framework for message::ReceiveTlvs
1 parent d79b448 commit 37e373f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lightning/src/onion_message/functional_tests.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ struct TestCustomMessageHandler {
147147
struct OnHandleCustomMessage {
148148
expect: TestCustomMessage,
149149
include_reply_path: bool,
150+
custom_data: Option<Vec<u8>>,
150151
}
151152

152153
impl TestCustomMessageHandler {
@@ -159,6 +160,7 @@ impl TestCustomMessageHandler {
159160
OnHandleCustomMessage {
160161
expect: message,
161162
include_reply_path: false,
163+
custom_data: None,
162164
}
163165
);
164166
}
@@ -168,6 +170,17 @@ impl TestCustomMessageHandler {
168170
OnHandleCustomMessage {
169171
expect: message,
170172
include_reply_path: true,
173+
custom_data: None
174+
}
175+
);
176+
}
177+
178+
fn expect_message_with_custom_data(&self, message: TestCustomMessage, custom_data: Vec<u8>) {
179+
self.expectations.lock().unwrap().push_back(
180+
OnHandleCustomMessage {
181+
expect: message,
182+
include_reply_path: false,
183+
custom_data: Some(custom_data),
171184
}
172185
);
173186
}
@@ -191,6 +204,7 @@ impl CustomOnionMessageHandler for TestCustomMessageHandler {
191204
fn handle_custom_message(&self, msg: Self::CustomMessage, context: Option<Vec<u8>>, custom_data: Option<Vec<u8>>, responder: Option<Responder>) -> Option<(Self::CustomMessage, ResponseInstruction)> {
192205
let expectation = self.get_next_expectation();
193206
assert_eq!(msg, expectation.expect);
207+
assert_eq!(custom_data, expectation.custom_data);
194208

195209
let response = match msg {
196210
TestCustomMessage::Ping => TestCustomMessage::Pong,

0 commit comments

Comments
 (0)