Skip to content

Commit 5b5e7ef

Browse files
committed
Introduce custom_data test framework for message::ReceiveTlvs
1 parent 9bd8ae5 commit 5b5e7ef

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

lightning/src/onion_message/functional_tests.rs

+20-3
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ struct TestCustomMessageHandler {
154154
struct OnHandleCustomMessage {
155155
expect: TestCustomMessage,
156156
include_reply_path: bool,
157+
custom_data: Option<Vec<u8>>,
157158
}
158159

159160
impl TestCustomMessageHandler {
@@ -162,13 +163,28 @@ impl TestCustomMessageHandler {
162163
}
163164

164165
fn expect_message(&self, message: TestCustomMessage) {
165-
let expectation = OnHandleCustomMessage { expect: message, include_reply_path: false };
166+
let expectation = OnHandleCustomMessage { expect: message, include_reply_path: false, custom_data: None };
166167
self.expectations.lock().unwrap().push_back(expectation);
167168
}
168169

169170
fn expect_message_and_response(&self, message: TestCustomMessage) {
170-
let expectation = OnHandleCustomMessage { expect: message, include_reply_path: true };
171-
self.expectations.lock().unwrap().push_back(expectation);
171+
self.expectations.lock().unwrap().push_back(
172+
OnHandleCustomMessage {
173+
expect: message,
174+
include_reply_path: true,
175+
custom_data: None,
176+
}
177+
);
178+
}
179+
180+
fn expect_message_with_custom_data(&self, message: TestCustomMessage, custom_data: Vec<u8>) {
181+
self.expectations.lock().unwrap().push_back(
182+
OnHandleCustomMessage {
183+
expect: message,
184+
include_reply_path: false,
185+
custom_data: Some(custom_data),
186+
}
187+
);
172188
}
173189

174190
fn get_next_expectation(&self) -> OnHandleCustomMessage {
@@ -192,6 +208,7 @@ impl CustomOnionMessageHandler for TestCustomMessageHandler {
192208
) -> Option<(Self::CustomMessage, ResponseInstruction)> {
193209
let expectation = self.get_next_expectation();
194210
assert_eq!(msg, expectation.expect);
211+
assert_eq!(custom_data, expectation.custom_data);
195212

196213
let response = match msg {
197214
TestCustomMessage::Ping => TestCustomMessage::Pong,

0 commit comments

Comments
 (0)