Skip to content

Commit 5dd341c

Browse files
authored
Rename sender session events. (#1125)
2 parents f476146 + 5a62fa9 commit 5dd341c

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

payjoin/src/core/send/v2/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl SenderBuilder {
171171
) -> NextStateTransition<SessionEvent, Sender<WithReplyKey>> {
172172
let with_reply_key = WithReplyKey::new(pj_param, psbt_ctx);
173173
NextStateTransition::success(
174-
SessionEvent::CreatedReplyKey(Box::new(with_reply_key.clone())),
174+
SessionEvent::Created(Box::new(with_reply_key.clone())),
175175
Sender { state: with_reply_key },
176176
)
177177
}
@@ -225,7 +225,7 @@ impl SendSession {
225225
event: SessionEvent,
226226
) -> Result<SendSession, ReplayError<Self, SessionEvent>> {
227227
match (self, event) {
228-
(SendSession::WithReplyKey(state), SessionEvent::PollingForProposal()) =>
228+
(SendSession::WithReplyKey(state), SessionEvent::PostedOriginalPsbt()) =>
229229
Ok(state.apply_polling_for_proposal()),
230230
(
231231
SendSession::PollingForProposal(_state),
@@ -342,7 +342,7 @@ impl Sender<WithReplyKey> {
342342
reply_key: post_ctx.reply_key,
343343
};
344344
MaybeFatalTransition::success(
345-
SessionEvent::PollingForProposal(),
345+
SessionEvent::PostedOriginalPsbt(),
346346
Sender { state: polling_for_proposal },
347347
)
348348
}

payjoin/src/core/send/v2/session.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ where
1919
let first_event = logs.next().ok_or(InternalReplayError::NoEvents)?.into();
2020
let mut session_events = vec![first_event.clone()];
2121
let mut sender = match first_event {
22-
SessionEvent::CreatedReplyKey(reply_key) => SendSession::new(*reply_key),
22+
SessionEvent::Created(reply_key) => SendSession::new(*reply_key),
2323
_ => return Err(InternalReplayError::InvalidEvent(Box::new(first_event), None).into()),
2424
};
2525

@@ -61,7 +61,7 @@ impl SessionHistory {
6161
self.events
6262
.iter()
6363
.find_map(|event| match event {
64-
SessionEvent::CreatedReplyKey(proposal) =>
64+
SessionEvent::Created(proposal) =>
6565
Some(proposal.psbt_ctx.original_psbt.clone().extract_tx_unchecked_fee_rate()),
6666
_ => None,
6767
})
@@ -72,7 +72,7 @@ impl SessionHistory {
7272
self.events
7373
.iter()
7474
.find_map(|event| match event {
75-
SessionEvent::CreatedReplyKey(proposal) => Some(&proposal.pj_param),
75+
SessionEvent::Created(proposal) => Some(&proposal.pj_param),
7676
_ => None,
7777
})
7878
.expect("Session event log must contain at least one event with pj_param")
@@ -113,9 +113,9 @@ pub enum SessionStatus {
113113
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
114114
pub enum SessionEvent {
115115
/// Sender was created with a HPKE key pair
116-
CreatedReplyKey(Box<WithReplyKey>),
117-
/// Sender POST'd the original PSBT, and waiting to receive a Proposal PSBT using GET context
118-
PollingForProposal(),
116+
Created(Box<WithReplyKey>),
117+
/// Sender POSTed the Original PSBT and is waiting to receive a Proposal PSBT
118+
PostedOriginalPsbt(),
119119
/// Sender received a Proposal PSBT
120120
ReceivedProposalPsbt(bitcoin::Psbt),
121121
/// Closed successful or failed session
@@ -180,8 +180,8 @@ mod tests {
180180
};
181181

182182
let test_cases = vec![
183-
SessionEvent::CreatedReplyKey(Box::new(sender_with_reply_key.clone())),
184-
SessionEvent::PollingForProposal(),
183+
SessionEvent::Created(Box::new(sender_with_reply_key.clone())),
184+
SessionEvent::PostedOriginalPsbt(),
185185
SessionEvent::ReceivedProposalPsbt(PARSED_ORIGINAL_PSBT.clone()),
186186
SessionEvent::Closed(SessionOutcome::Success),
187187
SessionEvent::Closed(SessionOutcome::Failure),
@@ -259,7 +259,7 @@ mod tests {
259259
};
260260
let persister = InMemoryTestPersister::<SessionEvent>::default();
261261
persister
262-
.save_event(SessionEvent::CreatedReplyKey(Box::new(with_reply_key)))
262+
.save_event(SessionEvent::Created(Box::new(with_reply_key)))
263263
.expect("save_event should succeed");
264264

265265
let err = replay_event_log(&persister).expect_err("session should be expired");
@@ -304,7 +304,7 @@ mod tests {
304304
};
305305
let sender = Sender { state: with_reply_key.clone() };
306306
let test = SessionHistoryTest {
307-
events: vec![SessionEvent::CreatedReplyKey(Box::new(with_reply_key))],
307+
events: vec![SessionEvent::Created(Box::new(with_reply_key))],
308308
expected_session_history: SessionHistoryExpectedOutcome {
309309
fallback_tx,
310310
pj_param,
@@ -352,7 +352,7 @@ mod tests {
352352
};
353353

354354
let events = vec![
355-
SessionEvent::CreatedReplyKey(Box::new(with_reply_key)),
355+
SessionEvent::Created(Box::new(with_reply_key)),
356356
SessionEvent::Closed(SessionOutcome::Success),
357357
];
358358

0 commit comments

Comments
 (0)