diff --git a/gtest/src/log.rs b/gtest/src/log.rs index 05c28829d3f..f5b0c421f2b 100644 --- a/gtest/src/log.rs +++ b/gtest/src/log.rs @@ -122,6 +122,30 @@ impl DecodedCoreLog { reply_to: log.reply_to, }) } + + pub fn id(&self) -> MessageId { + self.id + } + + pub fn source(&self) -> ProgramId { + self.source + } + + pub fn destination(&self) -> ProgramId { + self.destination + } + + pub fn payload(&self) -> &T { + &self.payload + } + + pub fn reply_code(&self) -> Option { + self.reply_code + } + + pub fn reply_to(&self) -> Option { + self.reply_to + } } /// A log that can be emitted by a program. @@ -395,8 +419,7 @@ pub struct BlockRunResult { /// Total messages processed during the current /// execution. pub total_processed: u32, - // TODO #4122 - /// Logs created during the current execution. + /// User message logs (events) created during the current execution. pub log: Vec, /// Mapping gas burned for each message during /// the current block execution. diff --git a/gtest/src/manager/block_exec.rs b/gtest/src/manager/block_exec.rs index 625e36b58bf..07361be7360 100644 --- a/gtest/src/manager/block_exec.rs +++ b/gtest/src/manager/block_exec.rs @@ -108,8 +108,6 @@ impl ExtManager { message_id } - // TODO #4120 Charge for task pool processing the gas from gas allowance - // TODO #4121 pub(crate) fn run_new_block(&mut self, allowance: Gas) -> BlockRunResult { self.gas_allowance = allowance; self.blocks_manager.next_block(); diff --git a/gtest/src/manager/task.rs b/gtest/src/manager/task.rs index 53c58d0f9e0..27c9fc341cc 100644 --- a/gtest/src/manager/task.rs +++ b/gtest/src/manager/task.rs @@ -137,7 +137,9 @@ impl TaskHandler for ExtManager { .unwrap_or_else(|e| unreachable!("GasTree corrupted: {e:?}")); self.dispatches.push_back(trap_dispatch); } else { - // TODO #4122 + let trap_message = + trap_reply.into_stored(program_id, waitlisted.source(), message_id); + self.log.push(trap_message); } } diff --git a/gtest/src/program.rs b/gtest/src/program.rs index 91477e94432..f700b351529 100644 --- a/gtest/src/program.rs +++ b/gtest/src/program.rs @@ -909,7 +909,7 @@ mod tests { } #[test] - fn test_handle_messages_to_failing_program() { + fn test_queued_message_to_failed_program() { let sys = System::new(); sys.init_logger(); @@ -933,6 +933,24 @@ mod tests { assert!(res.contains(&expected_log)); } + #[test] + #[should_panic] + fn test_new_message_to_failed_program() { + let sys = System::new(); + sys.init_logger(); + + let user_id = DEFAULT_USER_ALICE; + + let prog = Program::from_binary_with_id(&sys, 137, demo_futures_unordered::WASM_BINARY); + + let init_msg_payload = String::from("InvalidInput"); + let failed_mid = prog.send(user_id, init_msg_payload); + let res = sys.run_next_block(); + res.assert_panicked_with(failed_mid, "Failed to load destination: Decode(Error)"); + + let _panic = prog.send_bytes(user_id, b""); + } + #[test] fn simple_balance() { let sys = System::new();