diff --git a/core/src/events/mod.rs b/core/src/events/mod.rs index 7c05b5f26..7530fbc15 100644 --- a/core/src/events/mod.rs +++ b/core/src/events/mod.rs @@ -93,11 +93,6 @@ pub enum EventPayload { voucher_nullifier: VoucherNullifier, utxo: Utxo, }, - Withdraw { - channel_id: ChannelId, - amount: Value, - utxos: Vec, - }, } impl TryFrom for Events { diff --git a/core/src/mantle/channel.rs b/core/src/mantle/channel.rs index 0d2d0d626..e4152f37e 100644 --- a/core/src/mantle/channel.rs +++ b/core/src/mantle/channel.rs @@ -469,31 +469,7 @@ mod tests { updated.channels.channel_state(&channel_id).unwrap().balance, 4 ); - assert_eq!(events.len(), 1); - let Event::Tx { - tx_hash, - op_id, - payload, - } = events.iter().next().cloned().unwrap() - else { - panic!("expected Tx event") - }; - assert_eq!(tx_hash, [1; 32].into()); - assert_eq!(op_id, withdraw_op.op_id()); - let EventPayload::Withdraw { - channel_id, - amount, - utxos, - } = payload - else { - panic!("expected Withdraw event") - }; - assert_eq!(channel_id, withdraw_op.channel_id); - assert_eq!(amount, 6); - assert_eq!( - utxos, - withdraw_op.outputs.utxos(&withdraw_op).collect::>() - ); + assert!(events.is_empty()); } #[test] diff --git a/core/src/mantle/ops/channel/withdraw.rs b/core/src/mantle/ops/channel/withdraw.rs index 605b9e0cc..061de0d5f 100644 --- a/core/src/mantle/ops/channel/withdraw.rs +++ b/core/src/mantle/ops/channel/withdraw.rs @@ -2,7 +2,7 @@ use nom::IResult; use serde::{Deserialize, Serialize}; use crate::{ - events::{Event, EventPayload, Events}, + events::Events, mantle::{ TxHash, channel::{Channels, Error}, @@ -155,18 +155,6 @@ impl Operation> for ChannelWithdrawOp { // Add the outputs to the ledger ctx.utxos = self.outputs.execute(ctx.utxos, self); - let output_utxos = self.outputs.utxos(self).collect::>(); - let events = Event::from_tx( - ctx.tx_hash, - self.op_id(), - EventPayload::Withdraw { - channel_id: self.channel_id, - amount: amount_withdraw, - utxos: output_utxos, - }, - ) - .into(); - - Ok((ctx, events)) + Ok((ctx, Events::new())) } } diff --git a/ledger/src/lib.rs b/ledger/src/lib.rs index d7238269b..21d75d2fd 100644 --- a/ledger/src/lib.rs +++ b/ledger/src/lib.rs @@ -1238,28 +1238,7 @@ mod tests { .expect("withdraw should have at least one utxo") .id(); assert!(new_state.latest_utxos().contains(&withdraw_utxo)); - assert_eq!(events.len(), 1); - let Event::Tx { - tx_hash, - op_id, - payload, - } = events.iter().next().unwrap().clone() - else { - panic!("expected a Tx event") - }; - assert_eq!(tx_hash, withdraw_tx_hash); - assert_eq!(op_id, withdraw.op_id()); - let EventPayload::Withdraw { - channel_id, - amount, - utxos, - } = payload - else { - panic!("expected Withdraw event") - }; - assert_eq!(channel_id, withdraw.channel_id); - assert_eq!(amount, withdraw_note.value); - assert_eq!(utxos, withdraw.outputs.utxos(&withdraw).collect::>()); + assert!(events.is_empty()); } #[test] diff --git a/tests/src/tests/mantle/channel.rs b/tests/src/tests/mantle/channel.rs index 43daa0909..dd989c1e4 100644 --- a/tests/src/tests/mantle/channel.rs +++ b/tests/src/tests/mantle/channel.rs @@ -201,10 +201,8 @@ async fn channel_deposit() { /// 2. Create a channel with a known signer. /// 3. Deposit funds into that channel. /// 4. Submit a signed channel withdraw transaction. -/// 5. Verify the block containing the withdraw tx exposes a matching `Withdraw` -/// event via the `/cryptarchia/blocks/:id/events` endpoint. -/// 6. Verify the recipient wallet balance increases. -/// 7. Verify the channel balance decreases. +/// 5. Verify the recipient wallet balance increases. +/// 6. Verify the channel balance decreases. #[tokio::test] #[serial] async fn channel_withdraw_updates_wallet_balance() { @@ -281,23 +279,7 @@ async fn channel_withdraw_updates_wallet_balance() { .await .expect("withdraw transaction should be submitted"); - let withdraw_block_id = - wait_for_tx_inclusion(&mut block_stream, withdraw_tx_hash, "withdraw").await; - - let events = fetch_block_events(&validator.client, withdraw_block_id).await; - let payload = find_tx_payload(&events, withdraw_tx_hash) - .expect("block events should include the withdraw tx"); - let EventPayload::Withdraw { - channel_id, - amount, - utxos, - } = payload - else { - panic!("expected Withdraw event") - }; - assert_eq!(channel_id, withdraw.channel_id); - assert_eq!(amount, withdraw_amount); - assert_eq!(utxos, withdraw.outputs.utxos(&withdraw).collect::>()); + wait_for_tx_inclusion(&mut block_stream, withdraw_tx_hash, "withdraw").await; let balance_after_withdraw = wait_for_wallet_balance( &validator.client, @@ -526,15 +508,6 @@ async fn fetch_block_events(node: &NodeHttpClient, block_id: HeaderId) -> Events .expect("block events response should be valid JSON") } -fn find_tx_payload(events: &Events, expected_tx_hash: TxHash) -> Option { - events.iter().find_map(|event| match event { - Event::Tx { - tx_hash, payload, .. - } => (tx_hash == &expected_tx_hash).then(|| payload.clone()), - Event::Ledger(_) => None, - }) -} - async fn get_channel_balance(node: &NodeHttpClient, channel_id: ChannelId) -> u64 { let url = api_url(node, &format!("channel/{channel_id}")); diff --git a/wallet/src/lib.rs b/wallet/src/lib.rs index 3aba3eef7..e2d74e9be 100644 --- a/wallet/src/lib.rs +++ b/wallet/src/lib.rs @@ -441,12 +441,13 @@ fn transform_op(op: &Op, event: Option) -> Option { Op::SDPWithdraw(withdrawal) => Some(WalletOp::Unlock(withdrawal.locked_note_id)), Op::LeaderClaim(_) => match event.expect("event for LeaderClaim op must exist") { EventPayload::LeaderRewardClaimed { utxo, .. } => Some(WalletOp::LeaderClaim(utxo)), - _ => None, - }, - Op::ChannelWithdraw(_) => match event.expect("event for ChannelWithdraw op must exist") { - EventPayload::Withdraw { utxos, .. } => Some(WalletOp::ChannelWithdraw(utxos)), - _ => None, + EventPayload::Deposit { .. } => { + panic!("event for LeaderClaim op must be LeaderRewardClaimed") + } }, + Op::ChannelWithdraw(withdraw) => Some(WalletOp::ChannelWithdraw( + withdraw.outputs.utxos(withdraw).collect(), + )), Op::ChannelInscribe(_) | Op::ChannelConfig(_) | Op::SDPActive(_) => None, } }