Skip to content

Commit 5128e6b

Browse files
test: use channel response to test received message
1 parent 41f5dbd commit 5128e6b

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

crates/tap-agent/src/agent/sender_account.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,11 @@ pub mod tests {
15641564
sender_account
15651565
.cast(SenderAccountMessage::UpdateAllocationIds(HashSet::new()))
15661566
.unwrap();
1567-
msg_receiver.recv().await.expect("Channel failed");
1567+
let msg = msg_receiver.recv().await.expect("Channel failed");
1568+
assert_eq!(
1569+
msg,
1570+
SenderAccountMessage::UpdateAllocationIds(HashSet::new())
1571+
);
15681572

15691573
let actor_ref = ActorRef::<SenderAllocationMessage>::where_is(sender_allocation_id.clone());
15701574
assert!(actor_ref.is_none());
@@ -2366,7 +2370,14 @@ pub mod tests {
23662370
ReceiptFees::NewReceipt(TRIGGER_VALUE, get_current_timestamp_u64_ns()),
23672371
))
23682372
.unwrap();
2369-
msg_receiver.recv().await.expect("Channel failed");
2373+
let msg = msg_receiver.recv().await.expect("Channel failed");
2374+
assert!(matches!(
2375+
msg,
2376+
SenderAccountMessage::UpdateReceiptFees(
2377+
ALLOCATION_ID_0,
2378+
ReceiptFees::NewReceipt(TRIGGER_VALUE, _)
2379+
)
2380+
));
23702381

23712382
let deny = call!(sender_account, SenderAccountMessage::GetDeny).unwrap();
23722383
assert!(deny, "should be blocked");

crates/tap-agent/tests/sender_account_test.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,17 @@ async fn sender_account_layer_test(pgpool: PgPool) {
4848
.await;
4949

5050
// we expect it to create a sender allocation
51+
let allocation_ids = HashSet::from_iter([AllocationId::Legacy(ALLOCATION_ID_0)]);
5152
sender_account
5253
.cast(SenderAccountMessage::UpdateAllocationIds(
53-
vec![AllocationId::Legacy(ALLOCATION_ID_0)]
54-
.into_iter()
55-
.collect(),
54+
allocation_ids.clone(),
5655
))
5756
.unwrap();
58-
msg_receiver.recv().await.expect("Channel failed");
57+
let msg = msg_receiver.recv().await.expect("Channel failed");
58+
assert_eq!(
59+
msg,
60+
SenderAccountMessage::UpdateAllocationIds(allocation_ids)
61+
);
5962

6063
mock_server
6164
.register(

0 commit comments

Comments
 (0)