From ca70e2d88333fe281f93630343396b8577bfe6f7 Mon Sep 17 00:00:00 2001 From: mqxf Date: Sat, 4 Nov 2023 11:02:17 +0100 Subject: [PATCH] Removed singal constructor --- .../src/scheme/demo_exit_handle.rs | 6 ++- .../constructor/src/scheme/demo_exit_init.rs | 11 +++++- examples/constructor/src/scheme/demo_ping.rs | 6 ++- .../src/scheme/demo_proxy_with_gas.rs | 11 +++++- .../src/scheme/demo_reply_deposit.rs | 5 +++ .../src/scheme/demo_wait_init_exit_reply.rs | 6 ++- examples/constructor/src/scheme/mod.rs | 16 +++----- pallets/gear/src/tests.rs | 37 +++++++++++++++---- 8 files changed, 75 insertions(+), 23 deletions(-) diff --git a/examples/constructor/src/scheme/demo_exit_handle.rs b/examples/constructor/src/scheme/demo_exit_handle.rs index a7b6a508057..4a6ba5a3fb2 100644 --- a/examples/constructor/src/scheme/demo_exit_handle.rs +++ b/examples/constructor/src/scheme/demo_exit_handle.rs @@ -22,6 +22,10 @@ pub fn handle_reply() -> Calls { Calls::builder().noop() } +pub fn handle_signal() -> Calls { + Calls::builder().noop() +} + pub fn scheme() -> Scheme { - Scheme::predefined(init(), handle(), handle_reply()) + Scheme::predefined(init(), handle(), handle_reply(), handle_signal()) } diff --git a/examples/constructor/src/scheme/demo_exit_init.rs b/examples/constructor/src/scheme/demo_exit_init.rs index 74a6af4f6bf..9e191c164d4 100644 --- a/examples/constructor/src/scheme/demo_exit_init.rs +++ b/examples/constructor/src/scheme/demo_exit_init.rs @@ -29,6 +29,15 @@ pub fn handle_reply() -> Calls { Calls::builder().noop() } +pub fn handle_signal() -> Calls { + Calls::builder().noop() +} + pub fn scheme(send_before_exit: bool) -> Scheme { - Scheme::predefined(init(send_before_exit), handle(), handle_reply()) + Scheme::predefined( + init(send_before_exit), + handle(), + handle_reply(), + handle_signal(), + ) } diff --git a/examples/constructor/src/scheme/demo_ping.rs b/examples/constructor/src/scheme/demo_ping.rs index c0601efbff5..d05bee2fa01 100644 --- a/examples/constructor/src/scheme/demo_ping.rs +++ b/examples/constructor/src/scheme/demo_ping.rs @@ -29,6 +29,10 @@ pub fn handle_reply() -> Calls { Calls::builder().noop() } +pub fn handle_signal() -> Calls { + Calls::builder().noop() +} + pub fn scheme() -> Scheme { - Scheme::predefined(init(), handle(), handle_reply()) + Scheme::predefined(init(), handle(), handle_reply(), handle_signal()) } diff --git a/examples/constructor/src/scheme/demo_proxy_with_gas.rs b/examples/constructor/src/scheme/demo_proxy_with_gas.rs index 70b7e2a1ba5..7b893716d5e 100644 --- a/examples/constructor/src/scheme/demo_proxy_with_gas.rs +++ b/examples/constructor/src/scheme/demo_proxy_with_gas.rs @@ -65,6 +65,15 @@ pub fn handle_reply() -> Calls { ) } +pub fn handle_signal() -> Calls { + Calls::builder().noop() +} + pub fn scheme(destination: [u8; 32], delay: u32) -> Scheme { - Scheme::predefined(init(destination, delay), handle(), handle_reply()) + Scheme::predefined( + init(destination, delay), + handle(), + handle_reply(), + handle_signal(), + ) } diff --git a/examples/constructor/src/scheme/demo_reply_deposit.rs b/examples/constructor/src/scheme/demo_reply_deposit.rs index a7313e6b23a..5de12a39092 100644 --- a/examples/constructor/src/scheme/demo_reply_deposit.rs +++ b/examples/constructor/src/scheme/demo_reply_deposit.rs @@ -31,10 +31,15 @@ pub fn handle_reply(checker: [u8; 32]) -> Calls { .send_wgas(checker, Arg::bytes(SUCCESS_MESSAGE), 10_000) } +pub fn handle_signal() -> Calls { + Calls::builder().noop() +} + pub fn scheme(checker: [u8; 32], destination: [u8; 32], gas_to_send: u64) -> Scheme { Scheme::predefined( init(), handle(destination, gas_to_send), handle_reply(checker), + handle_signal(), ) } diff --git a/examples/constructor/src/scheme/demo_wait_init_exit_reply.rs b/examples/constructor/src/scheme/demo_wait_init_exit_reply.rs index bea2b68c1b6..e44eb574f62 100644 --- a/examples/constructor/src/scheme/demo_wait_init_exit_reply.rs +++ b/examples/constructor/src/scheme/demo_wait_init_exit_reply.rs @@ -42,6 +42,10 @@ pub fn handle_reply() -> Calls { .exit(source_var) } +pub fn handle_signal() -> Calls { + Calls::builder().noop() +} + pub fn scheme() -> Scheme { - Scheme::predefined(init(), handle(), handle_reply()) + Scheme::predefined(init(), handle(), handle_reply(), handle_signal()) } diff --git a/examples/constructor/src/scheme/mod.rs b/examples/constructor/src/scheme/mod.rs index 75d78ccb542..280c5682875 100644 --- a/examples/constructor/src/scheme/mod.rs +++ b/examples/constructor/src/scheme/mod.rs @@ -38,16 +38,12 @@ impl Scheme { Self::Direct(init.calls()) } - pub fn predefined(init: Calls, handle: Calls, handle_reply: Calls) -> Self { - Self::Predefined( - init.calls(), - handle.calls(), - handle_reply.calls(), - Default::default(), - ) - } - - pub fn signal(init: Calls, handle: Calls, handle_reply: Calls, handle_signal: Calls) -> Self { + pub fn predefined( + init: Calls, + handle: Calls, + handle_reply: Calls, + handle_signal: Calls, + ) -> Self { Self::Predefined( init.calls(), handle.calls(), diff --git a/pallets/gear/src/tests.rs b/pallets/gear/src/tests.rs index 5ccae9dc5f5..90e85e5506e 100644 --- a/pallets/gear/src/tests.rs +++ b/pallets/gear/src/tests.rs @@ -16,6 +16,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +use crate::tests::utils::ProgramCodeKind::Default; use crate::{ internal::HoldBoundBuilder, manager::HandleKind, @@ -167,7 +168,12 @@ fn value_counter_set_correctly_for_interruptions() { .send_value(Arg::new([0u8; 32]), Arg::new(vec![]), "value_store") .wait_for(1); - let scheme = Scheme::predefined(Calls::builder().noop(), handle, Calls::builder().noop()); + let scheme = Scheme::predefined( + Calls::builder().noop(), + handle, + Calls::builder().noop(), + Calls::builder().noop(), + ); init_logger(); new_test_ext().execute_with(|| { @@ -5937,7 +5943,12 @@ fn pause_terminated_exited_program() { let (_, terminated_pid) = submit_constructor_with_args( USER_1, DEFAULT_SALT, - Scheme::predefined(init, Default::default(), Default::default()), + Scheme::predefined( + init, + Default::default(), + Default::default(), + Default::default(), + ), 0, ); @@ -8555,7 +8566,7 @@ fn demo_constructor_is_demo_ping() { let handle_reply = Calls::builder().panic("I don't like replies"); - let scheme = Scheme::predefined(init, handle, handle_reply); + let scheme = Scheme::predefined(init, handle, handle_reply, Default::default()); // checking init let (_init_mid, constructor_id) = utils::init_constructor(scheme); @@ -14105,7 +14116,12 @@ fn double_read_works() { .load("read2") .bytes_eq("is_eq", "read1", "read2") .if_else("is_eq", noop_branch, panic_branch); - let predefined_scheme = Scheme::predefined(Default::default(), handle, Default::default()); + let predefined_scheme = Scheme::predefined( + Default::default(), + handle, + Default::default(), + Default::default(), + ); let (_, pid) = utils::init_constructor(predefined_scheme); @@ -14334,7 +14350,7 @@ fn test_send_to_terminated_from_program() { // Using `USER_2` not to pollute `USER_1` mailbox to make test easier. USER_2, b"salt1", - Scheme::predefined(init, handle, Calls::default()), + Scheme::predefined(init, handle, Calls::default(), Calls::default()), 0, ); @@ -14351,7 +14367,7 @@ fn test_send_to_terminated_from_program() { // Using `USER_2` not to pollute `USER_1` mailbox to make test easier. USER_2, b"salt2", - Scheme::predefined(Calls::default(), handle, handle_reply), + Scheme::predefined(Calls::default(), handle, handle_reply, Calls::default()), 0, ); @@ -14650,7 +14666,7 @@ fn test_gas_info_of_terminated_program() { let (_, pid_dead) = utils::submit_constructor_with_args( USER_1, b"salt1", - Scheme::predefined(init_dead, handle_dead, Calls::default()), + Scheme::predefined(init_dead, handle_dead, Calls::default(), Calls::default()), 0, ); @@ -14659,7 +14675,12 @@ fn test_gas_info_of_terminated_program() { let (_, proxy_pid) = utils::submit_constructor_with_args( USER_1, b"salt2", - Scheme::predefined(Calls::default(), handle_proxy, Calls::default()), + Scheme::predefined( + Calls::default(), + handle_proxy, + Calls::default(), + Calls::default(), + ), 0, );