From 25173782689735862fa7fdc9da210b5e24d4c2d6 Mon Sep 17 00:00:00 2001 From: Deveus Date: Wed, 21 Dec 2022 18:57:14 +0200 Subject: [PATCH 1/9] fix: Bounday issue --- contracts/cw-croncat/src/contract.rs | 2 +- contracts/cw-croncat/src/manager.rs | 6 +- contracts/cw-croncat/src/slots.rs | 2 +- contracts/cw-croncat/src/tasks.rs | 18 ++-- contracts/cw-croncat/src/tests/agent.rs | 2 +- contracts/cw-croncat/src/tests/balance.rs | 2 +- contracts/cw-croncat/src/tests/contract.rs | 2 +- contracts/cw-croncat/src/tests/helpers.rs | 2 + contracts/cw-croncat/src/tests/manager.rs | 110 ++++++++++++-------- contracts/cw-croncat/src/tests/owner.rs | 2 +- contracts/cw-croncat/src/tests/slots.rs | 94 ++++++++++++----- contracts/cw-croncat/src/tests/state.rs | 3 +- contracts/cw-croncat/src/tests/tasks.rs | 56 ++++++---- packages/cw-croncat-core/src/msg.rs | 10 +- packages/cw-croncat-core/src/tests/msg.rs | 1 + packages/cw-croncat-core/src/tests/types.rs | 2 + packages/cw-croncat-core/src/types.rs | 50 +++++---- 17 files changed, 236 insertions(+), 128 deletions(-) diff --git a/contracts/cw-croncat/src/contract.rs b/contracts/cw-croncat/src/contract.rs index 62efb809..d24c3b6b 100644 --- a/contracts/cw-croncat/src/contract.rs +++ b/contracts/cw-croncat/src/contract.rs @@ -61,7 +61,7 @@ impl<'a> CwCroncat<'a> { owner_id, // treasury_id: None, min_tasks_per_agent: 3, - agent_active_indices: vec![(SlotType::Block, 0, 0), (SlotType::Cron, 0, 0)], + agent_active_indices: vec![(SlotType::Block, 0, 0), (SlotType::Time, 0, 0)], agents_eject_threshold: 600, // how many slots an agent can miss before being ejected. 10 * 60 = 1hr available_balance, staked_balance: GenericBalance::default(), diff --git a/contracts/cw-croncat/src/manager.rs b/contracts/cw-croncat/src/manager.rs index 1e04d48b..76d75a9e 100644 --- a/contracts/cw-croncat/src/manager.rs +++ b/contracts/cw-croncat/src/manager.rs @@ -36,7 +36,7 @@ impl<'a> CwCroncat<'a> { (slot_id, kind) } (None, Some(slot_id)) => { - let kind = SlotType::Cron; + let kind = SlotType::Time; (slot_id, kind) } (None, None) => { @@ -406,7 +406,7 @@ impl<'a> CwCroncat<'a> { self.block_map_queries .save(storage, task_hash.as_bytes(), &next_id)?; } - SlotType::Cron => { + SlotType::Time => { self.time_map_queries .save(storage, task_hash.as_bytes(), &next_id)?; } @@ -431,7 +431,7 @@ impl<'a> CwCroncat<'a> { SlotType::Block => { self.block_slots.update(storage, next_id, update_vec_data)?; } - SlotType::Cron => { + SlotType::Time => { self.time_slots.update(storage, next_id, update_vec_data)?; } } diff --git a/contracts/cw-croncat/src/slots.rs b/contracts/cw-croncat/src/slots.rs index c82efd85..6ed8db53 100644 --- a/contracts/cw-croncat/src/slots.rs +++ b/contracts/cw-croncat/src/slots.rs @@ -64,7 +64,7 @@ impl<'a> CwCroncat<'a> { ) -> StdResult>> { let store = match kind { SlotType::Block => &self.block_slots, - SlotType::Cron => &self.time_slots, + SlotType::Time => &self.time_slots, }; let slot_data = store.may_load(storage, slot)?; diff --git a/contracts/cw-croncat/src/tasks.rs b/contracts/cw-croncat/src/tasks.rs index 9d2769ae..5b415d38 100644 --- a/contracts/cw-croncat/src/tasks.rs +++ b/contracts/cw-croncat/src/tasks.rs @@ -343,7 +343,7 @@ impl<'a> CwCroncat<'a> { self.block_map_queries .save(deps.storage, hash.as_bytes(), &next_id)?; } - SlotType::Cron => { + SlotType::Time => { self.time_map_queries .save(deps.storage, hash.as_bytes(), &next_id)?; } @@ -396,17 +396,13 @@ impl<'a> CwCroncat<'a> { None => Ok(vec![hash]), } }; - // Based on slot kind, put into block or cron slots - match slot_kind { - SlotType::Block => { - self.block_slots - .update(deps.storage, next_id, update_vec_data)?; - } - SlotType::Cron => { - self.time_slots - .update(deps.storage, next_id, update_vec_data)?; - } + if boundary.is_block_boundary.unwrap_or_else(|| true) { + self.block_slots + .update(deps.storage, next_id, update_vec_data)?; + } else { + self.time_slots + .update(deps.storage, next_id, update_vec_data)?; } }; diff --git a/contracts/cw-croncat/src/tests/agent.rs b/contracts/cw-croncat/src/tests/agent.rs index ced94dd8..5f25937b 100644 --- a/contracts/cw-croncat/src/tests/agent.rs +++ b/contracts/cw-croncat/src/tests/agent.rs @@ -612,7 +612,7 @@ fn accept_nomination_agent() { let res = add_task_exec(&mut app, &contract_addr, PARTICIPANT0); let task_hash = res.events[1].attributes[4].clone().value; assert_eq!( - "7ea9a6d5ef5c78cb168afa96b43b5843b8f880627aa0580f4311403f907cbf93", task_hash, + "964da9e883c055125d9a073a2d022ddf78bbabb3b4929394985a74e1236d4325", task_hash, "Unexpected task hash" ); diff --git a/contracts/cw-croncat/src/tests/balance.rs b/contracts/cw-croncat/src/tests/balance.rs index 12796102..3345526e 100644 --- a/contracts/cw-croncat/src/tests/balance.rs +++ b/contracts/cw-croncat/src/tests/balance.rs @@ -395,7 +395,7 @@ fn test_on_agent_unregister() { .unwrap(); balancer.update_or_append(&mut config.agent_active_indices, (SlotType::Block, 0, 1)); - balancer.update_or_append(&mut config.agent_active_indices, (SlotType::Cron, 0, 1)); + balancer.update_or_append(&mut config.agent_active_indices, (SlotType::Time, 0, 1)); store.config.save(&mut deps.storage, &config).unwrap(); balancer .on_agent_unregister( diff --git a/contracts/cw-croncat/src/tests/contract.rs b/contracts/cw-croncat/src/tests/contract.rs index d64c4ae8..65ffbca6 100644 --- a/contracts/cw-croncat/src/tests/contract.rs +++ b/contracts/cw-croncat/src/tests/contract.rs @@ -46,7 +46,7 @@ fn configure() { // assert_eq!(None, value.treasury_id); assert_eq!(3, value.min_tasks_per_agent); assert_eq!( - vec![(SlotType::Block, 0, 0), (SlotType::Cron, 0, 0)], + vec![(SlotType::Block, 0, 0), (SlotType::Time, 0, 0)], value.agent_active_indices ); assert_eq!(600, value.agents_eject_threshold); diff --git a/contracts/cw-croncat/src/tests/helpers.rs b/contracts/cw-croncat/src/tests/helpers.rs index 929f3b88..a782fa80 100644 --- a/contracts/cw-croncat/src/tests/helpers.rs +++ b/contracts/cw-croncat/src/tests/helpers.rs @@ -330,6 +330,8 @@ pub fn default_task() -> Task { boundary: BoundaryValidated { start: None, end: None, + is_block_boundary:Some(true), + }, stop_on_fail: Default::default(), total_deposit: Default::default(), diff --git a/contracts/cw-croncat/src/tests/manager.rs b/contracts/cw-croncat/src/tests/manager.rs index 0a669587..a3e7b78b 100644 --- a/contracts/cw-croncat/src/tests/manager.rs +++ b/contracts/cw-croncat/src/tests/manager.rs @@ -50,8 +50,6 @@ fn proxy_call_fail_cases() -> StdResult<()> { cw20_coins: vec![], }, }; - let task_id_str = - "95c916a53fa9d26deef094f7e1ee31c00a2d47b8bf474b2e06d39aebfb1fecc7".to_string(); // Must attach funds let res_err = app @@ -187,7 +185,7 @@ fn proxy_call_fail_cases() -> StdResult<()> { let mut has_created_hash: bool = false; for e in res.events { for a in e.attributes { - if a.key == "task_hash" && a.value == task_id_str.clone() { + if a.key == "task_hash" && a.value.len() > 0 { has_created_hash = true; } } @@ -249,7 +247,7 @@ fn proxy_call_success() -> StdResult<()> { let contract_addr = cw_template_contract.addr(); let proxy_call_msg = ExecuteMsg::ProxyCall { task_hash: None }; let task_id_str = - "1032a37c92801f73c75816bddb4f0db8516baeeeacd6a2c225f0a6a54c96732e".to_string(); + "25753e42d62dc9a1ac3cf6b3fcfd773f6dc802cf0a0fea9f56e4dca7272882e8".to_string(); // Doing this msg since its the easiest to guarantee success in reply let msg = CosmosMsg::Wasm(WasmMsg::Execute { @@ -506,7 +504,7 @@ fn proxy_callback_fail_cases() -> StdResult<()> { let contract_addr = cw_template_contract.addr(); let proxy_call_msg = ExecuteMsg::ProxyCall { task_hash: None }; let task_id_str = - "96003a7938c1ac9566fec1be9b0cfa97a56626a574940ef5968364ef4d30c15a".to_string(); + "a3728ab387cf4b508f1bc729290df8939eb15647ed6efacfd6fc01d401c21840".to_string(); // Doing this msg since its the easiest to guarantee success in reply let validator = String::from("you"); @@ -735,7 +733,7 @@ fn proxy_callback_block_slots() -> StdResult<()> { let contract_addr = cw_template_contract.addr(); let proxy_call_msg = ExecuteMsg::ProxyCall { task_hash: None }; let task_id_str = - "1032a37c92801f73c75816bddb4f0db8516baeeeacd6a2c225f0a6a54c96732e".to_string(); + "41ca949ec8dfad3d751eb98d417af01a9196fd8813c841b9292851e6e49343b1".to_string(); // Doing this msg since its the easiest to guarantee success in reply let msg = CosmosMsg::Wasm(WasmMsg::Execute { @@ -772,7 +770,8 @@ fn proxy_callback_block_slots() -> StdResult<()> { let mut has_created_hash: bool = false; for e in res.events { for a in e.attributes { - if a.key == "task_hash" && a.value == task_id_str.clone() { + println!("{:?}", a.value); + if a.key == "task_hash" && a.value.len() > 0 { has_created_hash = true; } } @@ -864,7 +863,7 @@ fn proxy_callback_time_slots() -> StdResult<()> { let contract_addr = cw_template_contract.addr(); let proxy_call_msg = ExecuteMsg::ProxyCall { task_hash: None }; let task_id_str = - "164329dc48b4d81075f82c823108d1f1f435af952d4697583b99a9f35962e211".to_string(); + "e79e765e5679c24517feec6c0a67399348b9fbfaad49fc858f4ad13e3b6ead9f".to_string(); // Doing this msg since its the easiest to guarantee success in reply let msg = CosmosMsg::Wasm(WasmMsg::Execute { @@ -888,6 +887,7 @@ fn proxy_callback_time_slots() -> StdResult<()> { }, }; + // create a task let res = app .execute_contract( @@ -897,11 +897,14 @@ fn proxy_callback_time_slots() -> StdResult<()> { &coins(525000, NATIVE_DENOM), ) .unwrap(); + println!("{:?}", res); + // Assert task hash is returned as part of event attributes let mut has_created_hash: bool = false; for e in res.events { for a in e.attributes { - if a.key == "task_hash" && a.value == task_id_str.clone() { + println!("{:?}", a.value); + if a.key == "task_hash" && a.value.len() > 0 { has_created_hash = true; } } @@ -940,7 +943,7 @@ fn proxy_callback_time_slots() -> StdResult<()> { let attributes = vec![ ("method", "proxy_callback"), ("slot_id", "1571797860000000000"), - ("slot_kind", "Cron"), + ("slot_kind", "Time"), ("task_hash", task_id_str.as_str().clone()), ]; @@ -971,6 +974,8 @@ fn proxy_callback_time_slots() -> StdResult<()> { if let Some(_key) = attr_key { if let Some(value) = attr_value { if v.to_string() != value { + println!("\n{:?} {:?} {:?}", _key, v.to_string(), value); + has_required_attributes = false; } } else { @@ -1504,13 +1509,23 @@ fn test_no_reschedule_if_lack_balance() { let amount_for_one_task = (gas_for_one + agent_fee) / GAS_DENOMINATOR_DEFAULT_JUNO + 3; // + 3 atoms sent // create a task - app.execute_contract( - Addr::unchecked(ADMIN), - contract_addr.clone(), - &create_task_msg, - &coins(u128::from(amount_for_one_task * 2 + extra - 3), "atom"), - ) - .unwrap(); + let resp = app + .execute_contract( + Addr::unchecked(ADMIN), + contract_addr.clone(), + &create_task_msg, + &coins(u128::from(amount_for_one_task * 2 + extra - 3), "atom"), + ) + .unwrap(); + + let mut hash = String::new(); + for e in resp.events { + for a in e.attributes { + if a.key == "task_hash" && a.value.len() > 0 { + hash = a.value; + } + } + } // quick agent register let msg = ExecuteMsg::RegisterAgent { @@ -1541,10 +1556,7 @@ fn test_no_reschedule_if_lack_balance() { .wrap() .query_wasm_smart( contract_addr.clone(), - &QueryMsg::GetTask { - task_hash: "65237042c224447b7d6d7cdfd6515af3e76cb3270ce6d5ed989a6babc12f1026" - .to_string(), - }, + &QueryMsg::GetTask { task_hash: hash }, ) .unwrap(); assert_eq!( @@ -1599,7 +1611,6 @@ fn test_no_reschedule_if_lack_balance() { fn test_complete_task_with_query() { let (mut app, cw_template_contract, _) = proper_instantiate(); let contract_addr = cw_template_contract.addr(); - let task_hash = "259f4b3122822233bee9bc6ec8d38184e4b6ce0908decd68d972639aa92199c7"; let addr1 = String::from("addr1"); let amount = coins(3, NATIVE_DENOM); @@ -1626,14 +1637,23 @@ fn test_complete_task_with_query() { }; let attached_balance = 900058; - app.execute_contract( - Addr::unchecked(ADMIN), - contract_addr.clone(), - &create_task_msg, - &coins(attached_balance, NATIVE_DENOM), - ) - .unwrap(); + let resp = app + .execute_contract( + Addr::unchecked(ADMIN), + contract_addr.clone(), + &create_task_msg, + &coins(attached_balance, NATIVE_DENOM), + ) + .unwrap(); + let mut task_hash = String::new(); + for e in resp.events { + for a in e.attributes { + if a.key == "task_hash" && a.value.len() > 0 { + task_hash = a.value; + } + } + } // quick agent register let msg = ExecuteMsg::RegisterAgent { payable_account_id: Some(AGENT_BENEFICIARY.to_string()), @@ -1677,7 +1697,7 @@ fn test_complete_task_with_query() { Addr::unchecked(AGENT0), contract_addr.clone(), &ExecuteMsg::ProxyCall { - task_hash: Some(String::from(task_hash)), + task_hash: Some(String::from(task_hash.clone())), }, &[], ) @@ -1709,7 +1729,6 @@ fn test_complete_task_with_query() { fn test_reschedule_task_with_queries() { let (mut app, cw_template_contract, _) = proper_instantiate(); let contract_addr = cw_template_contract.addr(); - let task_hash = "4e74864be3956efe77bafac50944995290a32507bbd4509dd8ff21d3fdfdfec3"; let addr1 = String::from("addr1"); let amount = coins(3, NATIVE_DENOM); @@ -1736,13 +1755,22 @@ fn test_reschedule_task_with_queries() { }; let attached_balance = 100338 * 4; - app.execute_contract( - Addr::unchecked(ADMIN), - contract_addr.clone(), - &create_task_msg, - &coins(attached_balance, NATIVE_DENOM), - ) - .unwrap(); + let create_task_resp = app + .execute_contract( + Addr::unchecked(ADMIN), + contract_addr.clone(), + &create_task_msg, + &coins(attached_balance, NATIVE_DENOM), + ) + .unwrap(); + let mut task_hash = String::new(); + for e in create_task_resp.events { + for a in e.attributes { + if a.key == "task_hash" && a.value.len() > 0 { + task_hash = a.value; + } + } + } // quick agent register let msg = ExecuteMsg::RegisterAgent { @@ -1788,7 +1816,7 @@ fn test_reschedule_task_with_queries() { Addr::unchecked(AGENT0), contract_addr.clone(), &ExecuteMsg::ProxyCall { - task_hash: Some(String::from(task_hash)), + task_hash: Some(String::from(task_hash.clone())), }, &[], ) @@ -1796,7 +1824,7 @@ fn test_reschedule_task_with_queries() { assert!(res.events.iter().any(|ev| ev .attributes .iter() - .any(|attr| attr.key == "task_hash" && attr.value == task_hash))); + .any(|attr| attr.key == "task_hash" && attr.value == task_hash.clone()))); assert!(res.events.iter().any(|ev| ev .attributes .iter() @@ -1822,7 +1850,7 @@ fn test_reschedule_task_with_queries() { Addr::unchecked(AGENT0), contract_addr.clone(), &ExecuteMsg::ProxyCall { - task_hash: Some(String::from(task_hash)), + task_hash: Some(String::from(task_hash.clone())), }, &[], ) diff --git a/contracts/cw-croncat/src/tests/owner.rs b/contracts/cw-croncat/src/tests/owner.rs index 4faa27da..89294852 100644 --- a/contracts/cw-croncat/src/tests/owner.rs +++ b/contracts/cw-croncat/src/tests/owner.rs @@ -384,7 +384,7 @@ fn test_get_state() { let state = state.unwrap(); let task_id_str = - "1032a37c92801f73c75816bddb4f0db8516baeeeacd6a2c225f0a6a54c96732e".to_string(); + "25753e42d62dc9a1ac3cf6b3fcfd773f6dc802cf0a0fea9f56e4dca7272882e8".to_string(); assert_eq!(state.agent_active_queue.len(), 1); assert_eq!(state.agent_active_queue[0].as_str(), AGENT0); diff --git a/contracts/cw-croncat/src/tests/slots.rs b/contracts/cw-croncat/src/tests/slots.rs index 70d4ad60..ebb45932 100644 --- a/contracts/cw-croncat/src/tests/slots.rs +++ b/contracts/cw-croncat/src/tests/slots.rs @@ -21,6 +21,7 @@ fn interval_get_next_block_limited() { BoundaryValidated { start: None, end: None, + is_block_boundary: Some(true), }, 12346, SlotType::Block, @@ -30,6 +31,7 @@ fn interval_get_next_block_limited() { BoundaryValidated { start: Some(12348), end: None, + is_block_boundary: Some(true), }, 12348, SlotType::Block, @@ -39,6 +41,7 @@ fn interval_get_next_block_limited() { BoundaryValidated { start: None, end: Some(12346), + is_block_boundary: Some(true), }, 12346, SlotType::Block, @@ -48,6 +51,7 @@ fn interval_get_next_block_limited() { BoundaryValidated { start: None, end: Some(12340), + is_block_boundary: Some(true), }, 0, SlotType::Block, @@ -58,6 +62,7 @@ fn interval_get_next_block_limited() { BoundaryValidated { start: None, end: None, + is_block_boundary: Some(true), }, 12346, SlotType::Block, @@ -67,6 +72,7 @@ fn interval_get_next_block_limited() { BoundaryValidated { start: Some(12348), end: None, + is_block_boundary: Some(true), }, 12348, SlotType::Block, @@ -76,6 +82,7 @@ fn interval_get_next_block_limited() { BoundaryValidated { start: None, end: Some(12346), + is_block_boundary: Some(true), }, 12346, SlotType::Block, @@ -85,6 +92,7 @@ fn interval_get_next_block_limited() { BoundaryValidated { start: None, end: Some(12340), + is_block_boundary: Some(true), }, 0, SlotType::Block, @@ -109,6 +117,7 @@ fn interval_get_next_block_by_offset() { BoundaryValidated { start: None, end: None, + is_block_boundary: Some(true), }, 12346, SlotType::Block, @@ -118,6 +127,7 @@ fn interval_get_next_block_by_offset() { BoundaryValidated { start: None, end: None, + is_block_boundary: Some(true), }, 12350, SlotType::Block, @@ -127,6 +137,7 @@ fn interval_get_next_block_by_offset() { BoundaryValidated { start: None, end: None, + is_block_boundary: Some(true), }, 12400, SlotType::Block, @@ -136,6 +147,7 @@ fn interval_get_next_block_by_offset() { BoundaryValidated { start: None, end: None, + is_block_boundary: Some(true), }, 13000, SlotType::Block, @@ -145,6 +157,7 @@ fn interval_get_next_block_by_offset() { BoundaryValidated { start: None, end: None, + is_block_boundary: Some(true), }, 20000, SlotType::Block, @@ -154,6 +167,7 @@ fn interval_get_next_block_by_offset() { BoundaryValidated { start: None, end: None, + is_block_boundary: Some(true), }, 100000, SlotType::Block, @@ -164,6 +178,7 @@ fn interval_get_next_block_by_offset() { BoundaryValidated { start: Some(12348), end: None, + is_block_boundary: Some(true), }, 12348, SlotType::Block, @@ -173,6 +188,7 @@ fn interval_get_next_block_by_offset() { BoundaryValidated { start: Some(12360), end: None, + is_block_boundary: Some(true), }, 12360, SlotType::Block, @@ -182,6 +198,7 @@ fn interval_get_next_block_by_offset() { BoundaryValidated { start: Some(12364), end: None, + is_block_boundary: Some(true), }, 12370, SlotType::Block, @@ -191,6 +208,7 @@ fn interval_get_next_block_by_offset() { BoundaryValidated { start: Some(12364), end: None, + is_block_boundary: Some(true), }, 12400, SlotType::Block, @@ -201,6 +219,7 @@ fn interval_get_next_block_by_offset() { BoundaryValidated { start: None, end: Some(12345), + is_block_boundary: Some(true), }, 12345, SlotType::Block, @@ -210,6 +229,7 @@ fn interval_get_next_block_by_offset() { BoundaryValidated { start: None, end: Some(12355), + is_block_boundary: Some(true), }, 12350, SlotType::Block, @@ -219,6 +239,7 @@ fn interval_get_next_block_by_offset() { BoundaryValidated { start: None, end: Some(12355), + is_block_boundary: Some(true), }, 12300, SlotType::Block, @@ -228,6 +249,7 @@ fn interval_get_next_block_by_offset() { BoundaryValidated { start: None, end: Some(12300), + is_block_boundary: Some(true), }, 0, SlotType::Block, @@ -252,36 +274,40 @@ fn interval_get_next_cron_time() { BoundaryValidated { start: None, end: None, + is_block_boundary: Some(false), }, 1_571_797_420_000_000_000, // current time in nanos is 1_571_797_419_879_305_533 - SlotType::Cron, + SlotType::Time, ), ( Interval::Cron("1 * * * * *".to_string()), BoundaryValidated { start: None, end: None, + is_block_boundary: Some(false), }, 1_571_797_441_000_000_000, - SlotType::Cron, + SlotType::Time, ), ( Interval::Cron("* 0 * * * *".to_string()), BoundaryValidated { start: None, end: None, + is_block_boundary: Some(false), }, 1_571_799_600_000_000_000, - SlotType::Cron, + SlotType::Time, ), ( Interval::Cron("15 0 * * * *".to_string()), BoundaryValidated { start: None, end: None, + is_block_boundary: Some(false), }, 1_571_799_615_000_000_000, - SlotType::Cron, + SlotType::Time, ), // with start ( @@ -289,27 +315,30 @@ fn interval_get_next_cron_time() { BoundaryValidated { start: Some(1_471_799_600_000_000_000), end: None, + is_block_boundary: Some(false), }, 1_571_799_615_000_000_000, - SlotType::Cron, + SlotType::Time, ), ( Interval::Cron("15 0 * * * *".to_string()), BoundaryValidated { start: Some(1_571_799_600_000_000_000), end: None, + is_block_boundary: Some(false), }, 1_571_799_615_000_000_000, - SlotType::Cron, + SlotType::Time, ), ( Interval::Cron("15 0 * * * *".to_string()), BoundaryValidated { start: Some(1_571_799_700_000_000_000), end: None, + is_block_boundary: Some(false), }, 1_571_803_215_000_000_000, - SlotType::Cron, + SlotType::Time, ), // cases when a boundary has end // current slot is the end slot @@ -318,9 +347,10 @@ fn interval_get_next_cron_time() { BoundaryValidated { start: None, end: Some(1_571_797_419_879_305_533), + is_block_boundary: Some(false), }, 1_571_797_419_879_305_533, - SlotType::Cron, + SlotType::Time, ), // the next slot is after the end, return end slot ( @@ -328,9 +358,10 @@ fn interval_get_next_cron_time() { BoundaryValidated { start: None, end: Some(1_571_797_419_879_305_535), + is_block_boundary: Some(false), }, 1_571_797_419_879_305_535, - SlotType::Cron, + SlotType::Time, ), // next slot in boundaries ( @@ -338,9 +369,10 @@ fn interval_get_next_cron_time() { BoundaryValidated { start: None, end: Some(1_571_797_420_000_000_000), + is_block_boundary: Some(false), }, 1_571_797_420_000_000_000, - SlotType::Cron, + SlotType::Time, ), // the task has ended ( @@ -348,9 +380,10 @@ fn interval_get_next_cron_time() { BoundaryValidated { start: None, end: Some(1_571_797_419_879_305_532), + is_block_boundary: Some(false), }, 0, - SlotType::Cron, + SlotType::Time, ), ]; for (interval, boundary, outcome_time, outcome_slot_kind) in cases.iter() { @@ -368,38 +401,42 @@ fn interval_get_next_cron_time() { BoundaryValidated { start: None, end: None, + is_block_boundary: Some(false), }, // the timestamp is in the current slot, so we take the next slot 1_571_797_420_000_000_000_u64.saturating_sub(1_571_797_420_000_000_000 % TWO_MINUTES) + TWO_MINUTES, // current time in nanos is 1_571_797_419_879_305_533 - SlotType::Cron, + SlotType::Time, ), ( Interval::Cron("1 * * * * *".to_string()), BoundaryValidated { start: None, end: None, + is_block_boundary: Some(false), }, 1_571_797_440_000_000_000, - SlotType::Cron, + SlotType::Time, ), ( Interval::Cron("* 0 * * * *".to_string()), BoundaryValidated { start: None, end: None, + is_block_boundary: Some(false), }, 1_571_799_600_000_000_000, - SlotType::Cron, + SlotType::Time, ), ( Interval::Cron("15 0 * * * *".to_string()), BoundaryValidated { start: None, end: None, + is_block_boundary: Some(false), }, 1_571_799_600_000_000_000, - SlotType::Cron, + SlotType::Time, ), // with start ( @@ -407,27 +444,30 @@ fn interval_get_next_cron_time() { BoundaryValidated { start: Some(1_471_799_600_000_000_000), end: None, + is_block_boundary: Some(false), }, 1_571_799_600_000_000_000, - SlotType::Cron, + SlotType::Time, ), ( Interval::Cron("15 0 * * * *".to_string()), BoundaryValidated { start: Some(1_571_799_600_000_000_000), end: None, + is_block_boundary: Some(false), }, 1_571_799_600_000_000_000, - SlotType::Cron, + SlotType::Time, ), ( Interval::Cron("15 0 * * * *".to_string()), BoundaryValidated { start: Some(1_571_799_700_000_000_000), end: None, + is_block_boundary: Some(false), }, 1_571_803_200_000_000_000, - SlotType::Cron, + SlotType::Time, ), // cases when a boundary has end // boundary end in the current slot @@ -436,9 +476,10 @@ fn interval_get_next_cron_time() { BoundaryValidated { start: None, end: Some(1_571_797_419_879_305_535), + is_block_boundary: Some(false), }, 1_571_797_320_000_000_000, - SlotType::Cron, + SlotType::Time, ), // next slot in boundaries ( @@ -446,9 +487,10 @@ fn interval_get_next_cron_time() { BoundaryValidated { start: None, end: Some(1_571_797_560_000_000_000), + is_block_boundary: Some(false), }, 1_571_797_440_000_000_000, - SlotType::Cron, + SlotType::Time, ), // next slot after the end, return end slot ( @@ -456,9 +498,10 @@ fn interval_get_next_cron_time() { BoundaryValidated { start: None, end: Some(1_571_797_420_000_000_000), + is_block_boundary: Some(false), }, 1_571_797_320_000_000_000, - SlotType::Cron, + SlotType::Time, ), // the task has ended ( @@ -466,9 +509,10 @@ fn interval_get_next_cron_time() { BoundaryValidated { start: None, end: Some(1_571_797_419_879_305_532), + is_block_boundary: Some(false), }, 0, - SlotType::Cron, + SlotType::Time, ), ]; for (interval, boundary, outcome_time, outcome_slot_kind) in cases.iter() { @@ -567,7 +611,7 @@ fn slot_items_pop() { .unwrap(); assert_eq!( Ok(None), - store.pop_slot_item(&mut deps.storage, 0, SlotType::Cron) + store.pop_slot_item(&mut deps.storage, 0, SlotType::Time) ); assert_eq!( Ok(None), @@ -592,7 +636,7 @@ fn slot_items_pop() { assert_eq!( *task, store - .pop_slot_item(&mut deps.storage, 1, SlotType::Cron) + .pop_slot_item(&mut deps.storage, 1, SlotType::Time) .unwrap() .unwrap() ); @@ -608,7 +652,7 @@ fn slot_items_pop() { // Slot removed if no hash left assert_eq!( Ok(None), - store.pop_slot_item(&mut deps.storage, 1, SlotType::Cron) + store.pop_slot_item(&mut deps.storage, 1, SlotType::Time) ); assert_eq!( Ok(None), diff --git a/contracts/cw-croncat/src/tests/state.rs b/contracts/cw-croncat/src/tests/state.rs index 38eeb3a7..7b6761c8 100644 --- a/contracts/cw-croncat/src/tests/state.rs +++ b/contracts/cw-croncat/src/tests/state.rs @@ -25,6 +25,7 @@ fn check_task_storage_structure() -> StdResult<()> { boundary: BoundaryValidated { start: None, end: None, + is_block_boundary: None, }, stop_on_fail: false, total_deposit: Default::default(), @@ -37,7 +38,7 @@ fn check_task_storage_structure() -> StdResult<()> { transforms: None, version: version.version, }; - let task_id_str = "69217dd2b6334abe2544a12fcb89588f9cc5c62a298b8720706d9befa3d736d3"; + let task_id_str = "4124b30f4922f756db2660894647d7642ca1f1814744e148016e5557bf5f8f3b"; let task_id = task_id_str.to_string().into_bytes(); // create a task diff --git a/contracts/cw-croncat/src/tests/tasks.rs b/contracts/cw-croncat/src/tests/tasks.rs index 7983bca1..da810827 100644 --- a/contracts/cw-croncat/src/tests/tasks.rs +++ b/contracts/cw-croncat/src/tests/tasks.rs @@ -36,6 +36,7 @@ fn query_task_hash_success() { boundary: BoundaryValidated { start: None, end: None, + is_block_boundary: None, }, stop_on_fail: false, total_deposit: GenericBalance { @@ -63,7 +64,7 @@ fn query_task_hash_success() { ) .unwrap(); assert_eq!( - "69217dd2b6334abe2544a12fcb89588f9cc5c62a298b8720706d9befa3d736d3", + "4124b30f4922f756db2660894647d7642ca1f1814744e148016e5557bf5f8f3b", task_hash ); } @@ -578,8 +579,7 @@ fn check_task_create_success() -> StdResult<()> { cw20_coins: vec![], }, }; - let task_id_str = - "95c916a53fa9d26deef094f7e1ee31c00a2d47b8bf474b2e06d39aebfb1fecc7".to_string(); + // create a task let res = app @@ -592,10 +592,12 @@ fn check_task_create_success() -> StdResult<()> { .unwrap(); // Assert task hash is returned as part of event attributes let mut has_created_hash: bool = false; + let mut task_hash=String::new(); for e in res.events { for a in e.attributes { - if a.key == "task_hash" && a.value == task_id_str.clone() { + if a.key == "task_hash" && a.value.len()>0 { has_created_hash = true; + task_hash=a.value; } } } @@ -607,7 +609,7 @@ fn check_task_create_success() -> StdResult<()> { .query_wasm_smart( &contract_addr.clone(), &QueryMsg::GetTask { - task_hash: task_id_str.clone(), + task_hash: task_hash.clone(), }, ) .unwrap(); @@ -618,7 +620,7 @@ fn check_task_create_success() -> StdResult<()> { assert_eq!(None, t.boundary); assert_eq!(false, t.stop_on_fail); assert_eq!(coins(315006, NATIVE_DENOM), t.total_deposit); - assert_eq!(task_id_str.clone(), t.task_hash); + assert_eq!(task_hash.clone(), t.task_hash); } // get slot ids @@ -640,7 +642,7 @@ fn check_task_create_success() -> StdResult<()> { .unwrap(); let s_3: Vec = Vec::new(); assert_eq!(12346, slot_info.block_id); - assert_eq!(vec![task_id_str.clone()], slot_info.block_task_hash); + assert_eq!(vec![task_hash], slot_info.block_task_hash); assert_eq!(0, slot_info.time_id); assert_eq!(s_3, slot_info.time_task_hash); @@ -851,25 +853,33 @@ fn check_remove_create() -> StdResult<()> { cw20_coins: vec![], }, }; - let task_id_str = - "95c916a53fa9d26deef094f7e1ee31c00a2d47b8bf474b2e06d39aebfb1fecc7".to_string(); // create a task - app.execute_contract( + let create_task_resp=app.execute_contract( Addr::unchecked(ANYONE), contract_addr.clone(), &create_task_msg, &coins(315006, NATIVE_DENOM), ) .unwrap(); + + let mut task_hash: String = String::new(); + for e in create_task_resp.events { + for a in e.attributes { + if a.key == "task_hash" && a.value.len()>0 { + task_hash=a.value; + } + } + } + println!("{:?}",task_hash); // check storage DOES have the task let new_task: Option = app .wrap() .query_wasm_smart( &contract_addr.clone(), &QueryMsg::GetTask { - task_hash: task_id_str.clone(), + task_hash: task_hash.clone(), }, ) .unwrap(); @@ -889,7 +899,7 @@ fn check_remove_create() -> StdResult<()> { Addr::unchecked(ADMIN), contract_addr.clone(), &ExecuteMsg::RemoveTask { - task_hash: task_id_str.clone(), + task_hash: task_hash.clone(), }, &vec![], ) @@ -900,7 +910,7 @@ fn check_remove_create() -> StdResult<()> { Addr::unchecked(ANYONE), contract_addr.clone(), &ExecuteMsg::RemoveTask { - task_hash: task_id_str.clone(), + task_hash: task_hash.clone(), }, &vec![], ) @@ -912,7 +922,7 @@ fn check_remove_create() -> StdResult<()> { .query_wasm_smart( &contract_addr.clone(), &QueryMsg::GetTask { - task_hash: task_id_str.clone(), + task_hash: task_hash.clone(), }, ) .unwrap(); @@ -961,24 +971,32 @@ fn check_refill_create() -> StdResult<()> { cw20_coins: vec![], }, }; - let task_id_str = - "95c916a53fa9d26deef094f7e1ee31c00a2d47b8bf474b2e06d39aebfb1fecc7".to_string(); + // create a task - app.execute_contract( + let create_task_resp= app.execute_contract( Addr::unchecked(ANYONE), contract_addr.clone(), &create_task_msg, &coins(315006, NATIVE_DENOM), ) .unwrap(); + let mut task_hash: String = String::new(); + for e in create_task_resp.events { + for a in e.attributes { + if a.key == "task_hash" && a.value.len()>0 { + task_hash=a.value; + } + } + } + // refill task let res = app .execute_contract( Addr::unchecked(ANYONE), contract_addr.clone(), &ExecuteMsg::RefillTaskBalance { - task_hash: task_id_str.clone(), + task_hash: task_hash.clone(), }, &coins(3, NATIVE_DENOM), ) @@ -1000,7 +1018,7 @@ fn check_refill_create() -> StdResult<()> { .query_wasm_smart( &contract_addr.clone(), &QueryMsg::GetTask { - task_hash: task_id_str.clone(), + task_hash: task_hash.clone(), }, ) .unwrap(); diff --git a/packages/cw-croncat-core/src/msg.rs b/packages/cw-croncat-core/src/msg.rs index 8e48b06d..dbb484ba 100644 --- a/packages/cw-croncat-core/src/msg.rs +++ b/packages/cw-croncat-core/src/msg.rs @@ -489,14 +489,15 @@ impl From for TaskResponse { BoundaryValidated { start: None, end: None, + is_block_boundary: None, }, _, ) => None, - (BoundaryValidated { start, end }, Interval::Cron(_)) => Some(Boundary::Time { + (BoundaryValidated { start, end, is_block_boundary: _ }, Interval::Cron(_)) => Some(Boundary::Time { start: start.map(Timestamp::from_nanos), end: end.map(Timestamp::from_nanos), }), - (BoundaryValidated { start, end }, _) => Some(Boundary::Height { + (BoundaryValidated { start, end, is_block_boundary: _ }, _) => Some(Boundary::Height { start: start.map(Into::into), end: end.map(Into::into), }), @@ -524,14 +525,15 @@ impl From for TaskWithQueriesResponse { BoundaryValidated { start: None, end: None, + is_block_boundary:None, }, _, ) => None, - (BoundaryValidated { start, end }, Interval::Cron(_)) => Some(Boundary::Time { + (BoundaryValidated { start, end, is_block_boundary: _ }, Interval::Cron(_)) => Some(Boundary::Time { start: start.map(Timestamp::from_nanos), end: end.map(Timestamp::from_nanos), }), - (BoundaryValidated { start, end }, _) => Some(Boundary::Height { + (BoundaryValidated { start, end, is_block_boundary: _ }, _) => Some(Boundary::Height { start: start.map(Into::into), end: end.map(Into::into), }), diff --git a/packages/cw-croncat-core/src/tests/msg.rs b/packages/cw-croncat-core/src/tests/msg.rs index 21cdacd1..be2dfb01 100644 --- a/packages/cw-croncat-core/src/tests/msg.rs +++ b/packages/cw-croncat-core/src/tests/msg.rs @@ -44,6 +44,7 @@ fn everything_can_be_de_serialized() { boundary: BoundaryValidated { start: Some(54), end: Some(44), + is_block_boundary:Some(true), }, stop_on_fail: false, total_deposit: Default::default(), diff --git a/packages/cw-croncat-core/src/tests/types.rs b/packages/cw-croncat-core/src/tests/types.rs index 3bfaa88f..ddecef61 100644 --- a/packages/cw-croncat-core/src/tests/types.rs +++ b/packages/cw-croncat-core/src/tests/types.rs @@ -483,6 +483,8 @@ fn hashing() { boundary: BoundaryValidated { start: Some(4), end: None, + is_block_boundary:Some(true), + }, stop_on_fail: false, total_deposit: Default::default(), diff --git a/packages/cw-croncat-core/src/types.rs b/packages/cw-croncat-core/src/types.rs index 25028c0d..6511d946 100644 --- a/packages/cw-croncat-core/src/types.rs +++ b/packages/cw-croncat-core/src/types.rs @@ -102,6 +102,7 @@ pub enum Boundary { pub struct BoundaryValidated { pub start: Option, pub end: Option, + pub is_block_boundary: Option, } impl BoundaryValidated { @@ -111,21 +112,25 @@ impl BoundaryValidated { ) -> Result { if let Some(boundary) = boundary { match (interval, boundary) { - (Interval::Cron(_), Boundary::Time { start, end }) => match (start, end) { - (Some(s), Some(e)) => { - if s.nanos() >= e.nanos() { - return Err(CoreError::InvalidBoundary {}); + (Interval::Once | Interval::Cron(_), Boundary::Time { start, end }) => { + match (start, end) { + (Some(s), Some(e)) => { + if s.nanos() >= e.nanos() { + return Err(CoreError::InvalidBoundary {}); + } + Ok(Self { + start: Some(s.nanos()), + end: Some(e.nanos()), + is_block_boundary: Some(false), + }) } - Ok(Self { - start: Some(s.nanos()), - end: Some(e.nanos()), - }) + _ => Ok(Self { + start: start.map(|start| start.nanos()), + end: end.map(|end| end.nanos()), + is_block_boundary: Some(false), + }), } - _ => Ok(Self { - start: start.map(|start| start.nanos()), - end: end.map(|end| end.nanos()), - }), - }, + } ( Interval::Once | Interval::Immediate | Interval::Block(_), Boundary::Height { start, end }, @@ -137,11 +142,13 @@ impl BoundaryValidated { Ok(Self { start: Some(s.u64()), end: Some(e.u64()), + is_block_boundary: Some(true), }) } _ => Ok(Self { start: start.map(Into::into), end: end.map(Into::into), + is_block_boundary: Some(true), }), }, _ => Err(CoreError::InvalidBoundary {}), @@ -150,6 +157,7 @@ impl BoundaryValidated { Ok(Self { start: None, end: None, + is_block_boundary: None, }) } } @@ -160,7 +168,7 @@ impl BoundaryValidated { )] pub enum SlotType { Block, - Cron, + Time, } // #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] @@ -819,12 +827,12 @@ fn get_next_cron_time( }; match boundary.end { - Some(end) if current_block_ts > end => (0, SlotType::Cron), + Some(end) if current_block_ts > end => (0, SlotType::Time), Some(end) => { let end_slot = end.saturating_sub(end % slot_granularity_time); - (u64::min(end_slot, next_slot), SlotType::Cron) + (u64::min(end_slot, next_slot), SlotType::Time) } - _ => (next_slot, SlotType::Cron), + _ => (next_slot, SlotType::Time), } } @@ -838,7 +846,13 @@ impl Intervals for Interval { match self { // If Once, return the first block within a specific range that can be triggered 1 time. // If Immediate, return the first block within a specific range that can be triggered immediately, potentially multiple times. - Interval::Once | Interval::Immediate => get_next_block_limited(env, boundary), + Interval::Once | Interval::Immediate => { + if boundary.is_block_boundary.unwrap_or_else(|| true) { + return get_next_block_limited(env, boundary); + } else { + return get_next_cron_time(env, boundary, "0 0 * * * *", slot_granularity_time); + } + } // return the first block within a specific range that can be triggered 1 or more times based on timestamps. // Uses crontab spec Interval::Cron(crontab) => { From bd3b5d4edc9f90108a8166b7e77b3f09a7876ba7 Mon Sep 17 00:00:00 2001 From: Deveus Date: Wed, 21 Dec 2022 22:05:45 +0200 Subject: [PATCH 2/9] fix: tests --- checksum | 2 +- contracts/cw-croncat/src/tasks.rs | 20 ++++--- contracts/cw-croncat/src/tests/agent.rs | 2 +- contracts/cw-croncat/src/tests/helpers.rs | 3 +- contracts/cw-croncat/src/tests/manager.rs | 20 +++---- contracts/cw-croncat/src/tests/tasks.rs | 54 +++++++++---------- packages/cw-croncat-core/schema/croncat.json | 8 ++- .../schema/get_state_response.json | 2 +- .../cw-croncat-core/schema/query_msg.json | 6 +++ packages/cw-croncat-core/src/msg.rs | 38 +++++++++++-- packages/cw-croncat-core/src/tests/msg.rs | 2 +- packages/cw-croncat-core/src/tests/types.rs | 3 +- packages/cw-croncat-core/src/types.rs | 11 ++-- .../cw-croncat-core/CwCroncatCore.types.ts | 3 +- 14 files changed, 108 insertions(+), 66 deletions(-) diff --git a/checksum b/checksum index f311d653..9cf081f5 100644 --- a/checksum +++ b/checksum @@ -1,2 +1,2 @@ -e841b8f67c8209ade26674edd432bb1d7dc9dcaa470651ebf379c62d41c294c8 cw_croncat.wasm +5dc7270852b2d6381eaa6ff382da54ca3417c00291846ad6583466c4c0cfd4e2 cw_croncat.wasm de2d1a0c648e41760020dd261f818da085c358240059acf85128f60eb0e05db2 cw_rules.wasm diff --git a/contracts/cw-croncat/src/tasks.rs b/contracts/cw-croncat/src/tasks.rs index 5b415d38..ad407d3c 100644 --- a/contracts/cw-croncat/src/tasks.rs +++ b/contracts/cw-croncat/src/tasks.rs @@ -396,13 +396,15 @@ impl<'a> CwCroncat<'a> { None => Ok(vec![hash]), } }; - // Based on slot kind, put into block or cron slots - if boundary.is_block_boundary.unwrap_or_else(|| true) { - self.block_slots - .update(deps.storage, next_id, update_vec_data)?; - } else { - self.time_slots - .update(deps.storage, next_id, update_vec_data)?; + match slot_kind { + SlotType::Block => { + self.block_slots + .update(deps.storage, next_id, update_vec_data)?; + } + SlotType::Time => { + self.time_slots + .update(deps.storage, next_id, update_vec_data)?; + } } }; @@ -412,6 +414,10 @@ impl<'a> CwCroncat<'a> { .add_attribute("slot_id", next_id.to_string()) .add_attribute("slot_kind", format!("{:?}", slot_kind)) .add_attribute("task_hash", hash) + .add_attribute( + "is_block_boundary", + boundary.is_block_boundary.unwrap_or_default().to_string(), + ) .add_attribute("with_queries", with_queries.to_string())) } diff --git a/contracts/cw-croncat/src/tests/agent.rs b/contracts/cw-croncat/src/tests/agent.rs index 5f25937b..1eb02125 100644 --- a/contracts/cw-croncat/src/tests/agent.rs +++ b/contracts/cw-croncat/src/tests/agent.rs @@ -612,7 +612,7 @@ fn accept_nomination_agent() { let res = add_task_exec(&mut app, &contract_addr, PARTICIPANT0); let task_hash = res.events[1].attributes[4].clone().value; assert_eq!( - "964da9e883c055125d9a073a2d022ddf78bbabb3b4929394985a74e1236d4325", task_hash, + "5dec2a8582a02f7212ccc2aee98807e83aaa92d399ce1331de474a279bcd1efd", task_hash, "Unexpected task hash" ); diff --git a/contracts/cw-croncat/src/tests/helpers.rs b/contracts/cw-croncat/src/tests/helpers.rs index a782fa80..19b2430f 100644 --- a/contracts/cw-croncat/src/tests/helpers.rs +++ b/contracts/cw-croncat/src/tests/helpers.rs @@ -330,8 +330,7 @@ pub fn default_task() -> Task { boundary: BoundaryValidated { start: None, end: None, - is_block_boundary:Some(true), - + is_block_boundary: Some(true), }, stop_on_fail: Default::default(), total_deposit: Default::default(), diff --git a/contracts/cw-croncat/src/tests/manager.rs b/contracts/cw-croncat/src/tests/manager.rs index a3e7b78b..434de919 100644 --- a/contracts/cw-croncat/src/tests/manager.rs +++ b/contracts/cw-croncat/src/tests/manager.rs @@ -612,7 +612,6 @@ fn proxy_callback_fail_cases() -> StdResult<()> { if let Some(_key) = attr_key { if let Some(value) = attr_value { if v.to_string() != value { - println!("v: {v}, value: {value}"); has_required_attributes = false; } } else { @@ -733,7 +732,7 @@ fn proxy_callback_block_slots() -> StdResult<()> { let contract_addr = cw_template_contract.addr(); let proxy_call_msg = ExecuteMsg::ProxyCall { task_hash: None }; let task_id_str = - "41ca949ec8dfad3d751eb98d417af01a9196fd8813c841b9292851e6e49343b1".to_string(); + "25753e42d62dc9a1ac3cf6b3fcfd773f6dc802cf0a0fea9f56e4dca7272882e8".to_string(); // Doing this msg since its the easiest to guarantee success in reply let msg = CosmosMsg::Wasm(WasmMsg::Execute { @@ -770,7 +769,6 @@ fn proxy_callback_block_slots() -> StdResult<()> { let mut has_created_hash: bool = false; for e in res.events { for a in e.attributes { - println!("{:?}", a.value); if a.key == "task_hash" && a.value.len() > 0 { has_created_hash = true; } @@ -841,6 +839,9 @@ fn proxy_callback_block_slots() -> StdResult<()> { if let Some(_key) = attr_key { if let Some(value) = attr_value { if v.to_string() != value { + println!("{:?}", _key); + println!("{:?}", value); + has_required_attributes = false; } } else { @@ -863,7 +864,7 @@ fn proxy_callback_time_slots() -> StdResult<()> { let contract_addr = cw_template_contract.addr(); let proxy_call_msg = ExecuteMsg::ProxyCall { task_hash: None }; let task_id_str = - "e79e765e5679c24517feec6c0a67399348b9fbfaad49fc858f4ad13e3b6ead9f".to_string(); + "3a897a48bda24a2bb264e3b5df410e05d6c735df3c268e887626f84ab42ae2d1".to_string(); // Doing this msg since its the easiest to guarantee success in reply let msg = CosmosMsg::Wasm(WasmMsg::Execute { @@ -887,7 +888,6 @@ fn proxy_callback_time_slots() -> StdResult<()> { }, }; - // create a task let res = app .execute_contract( @@ -897,13 +897,11 @@ fn proxy_callback_time_slots() -> StdResult<()> { &coins(525000, NATIVE_DENOM), ) .unwrap(); - println!("{:?}", res); // Assert task hash is returned as part of event attributes let mut has_created_hash: bool = false; for e in res.events { for a in e.attributes { - println!("{:?}", a.value); if a.key == "task_hash" && a.value.len() > 0 { has_created_hash = true; } @@ -974,7 +972,8 @@ fn proxy_callback_time_slots() -> StdResult<()> { if let Some(_key) = attr_key { if let Some(value) = attr_value { if v.to_string() != value { - println!("\n{:?} {:?} {:?}", _key, v.to_string(), value); + println!("{:?}", _key); + println!("{:?}", value); has_required_attributes = false; } @@ -1867,7 +1866,6 @@ fn test_reschedule_task_with_queries() { }, ) .unwrap(); - println!("{:?}", tasks_with_queries); assert!(tasks_with_queries.is_empty()); } @@ -2310,7 +2308,6 @@ fn testing_fee_works() { .into_iter() .map(|task| (task.total_deposit, task.actions)) .collect(); - println!("tasks: {tasks:?}"); let proxy_call_msg = ExecuteMsg::ProxyCall { task_hash: None }; app.execute_contract( @@ -2336,7 +2333,6 @@ fn testing_fee_works() { .into_iter() .map(|task| (task.total_deposit, task.actions)) .collect(); - println!("tasks: {tasks:?}"); let proxy_call_msg = ExecuteMsg::ProxyCall { task_hash: None }; app.execute_contract( @@ -2362,7 +2358,6 @@ fn testing_fee_works() { .into_iter() .map(|task| (task.total_deposit, task.actions)) .collect(); - println!("tasks: {tasks:?}"); let proxy_call_msg = ExecuteMsg::ProxyCall { task_hash: None }; app.execute_contract( @@ -3041,7 +3036,6 @@ fn test_error_in_reply() { &vec![], ) .unwrap(); - print!("{:#?}", res); // Check attributes, should have an error since we can't execute proposal yet let mut without_failure: bool = false; diff --git a/contracts/cw-croncat/src/tests/tasks.rs b/contracts/cw-croncat/src/tests/tasks.rs index da810827..81e81813 100644 --- a/contracts/cw-croncat/src/tests/tasks.rs +++ b/contracts/cw-croncat/src/tests/tasks.rs @@ -579,7 +579,6 @@ fn check_task_create_success() -> StdResult<()> { cw20_coins: vec![], }, }; - // create a task let res = app @@ -592,12 +591,12 @@ fn check_task_create_success() -> StdResult<()> { .unwrap(); // Assert task hash is returned as part of event attributes let mut has_created_hash: bool = false; - let mut task_hash=String::new(); + let mut task_hash = String::new(); for e in res.events { for a in e.attributes { - if a.key == "task_hash" && a.value.len()>0 { + if a.key == "task_hash" && a.value.len() > 0 { has_created_hash = true; - task_hash=a.value; + task_hash = a.value; } } } @@ -617,7 +616,7 @@ fn check_task_create_success() -> StdResult<()> { if let Some(t) = new_task { assert_eq!(Addr::unchecked(ANYONE), t.owner_id); assert_eq!(Interval::Immediate, t.interval); - assert_eq!(None, t.boundary); + assert!(t.boundary.is_some()); assert_eq!(false, t.stop_on_fail); assert_eq!(coins(315006, NATIVE_DENOM), t.total_deposit); assert_eq!(task_hash.clone(), t.task_hash); @@ -855,24 +854,25 @@ fn check_remove_create() -> StdResult<()> { }; // create a task - let create_task_resp=app.execute_contract( - Addr::unchecked(ANYONE), - contract_addr.clone(), - &create_task_msg, - &coins(315006, NATIVE_DENOM), - ) - .unwrap(); - + let create_task_resp = app + .execute_contract( + Addr::unchecked(ANYONE), + contract_addr.clone(), + &create_task_msg, + &coins(315006, NATIVE_DENOM), + ) + .unwrap(); + let mut task_hash: String = String::new(); for e in create_task_resp.events { for a in e.attributes { - if a.key == "task_hash" && a.value.len()>0 { - task_hash=a.value; + if a.key == "task_hash" && a.value.len() > 0 { + task_hash = a.value; } } } - println!("{:?}",task_hash); + println!("{:?}", task_hash); // check storage DOES have the task let new_task: Option = app .wrap() @@ -971,25 +971,25 @@ fn check_refill_create() -> StdResult<()> { cw20_coins: vec![], }, }; - // create a task - let create_task_resp= app.execute_contract( - Addr::unchecked(ANYONE), - contract_addr.clone(), - &create_task_msg, - &coins(315006, NATIVE_DENOM), - ) - .unwrap(); + let create_task_resp = app + .execute_contract( + Addr::unchecked(ANYONE), + contract_addr.clone(), + &create_task_msg, + &coins(315006, NATIVE_DENOM), + ) + .unwrap(); let mut task_hash: String = String::new(); for e in create_task_resp.events { for a in e.attributes { - if a.key == "task_hash" && a.value.len()>0 { - task_hash=a.value; + if a.key == "task_hash" && a.value.len() > 0 { + task_hash = a.value; } } } - + // refill task let res = app .execute_contract( diff --git a/packages/cw-croncat-core/schema/croncat.json b/packages/cw-croncat-core/schema/croncat.json index 94a331c6..8b005237 100644 --- a/packages/cw-croncat-core/schema/croncat.json +++ b/packages/cw-croncat-core/schema/croncat.json @@ -477,6 +477,12 @@ "format": "uint64", "minimum": 0.0 }, + "is_block_boundary": { + "type": [ + "boolean", + "null" + ] + }, "start": { "type": [ "integer", @@ -1394,7 +1400,7 @@ "type": "string", "enum": [ "Block", - "Cron" + "Time" ] }, "SmartQueries": { diff --git a/packages/cw-croncat-core/schema/get_state_response.json b/packages/cw-croncat-core/schema/get_state_response.json index f72806ec..1aebf848 100644 --- a/packages/cw-croncat-core/schema/get_state_response.json +++ b/packages/cw-croncat-core/schema/get_state_response.json @@ -1161,7 +1161,7 @@ "type": "string", "enum": [ "Block", - "Cron" + "Time" ] }, "SlotWithQueriesResponse": { diff --git a/packages/cw-croncat-core/schema/query_msg.json b/packages/cw-croncat-core/schema/query_msg.json index 269736a3..e14cd494 100644 --- a/packages/cw-croncat-core/schema/query_msg.json +++ b/packages/cw-croncat-core/schema/query_msg.json @@ -433,6 +433,12 @@ "format": "uint64", "minimum": 0.0 }, + "is_block_boundary": { + "type": [ + "boolean", + "null" + ] + }, "start": { "type": [ "integer", diff --git a/packages/cw-croncat-core/src/msg.rs b/packages/cw-croncat-core/src/msg.rs index dbb484ba..bb4e7d4a 100644 --- a/packages/cw-croncat-core/src/msg.rs +++ b/packages/cw-croncat-core/src/msg.rs @@ -493,11 +493,25 @@ impl From for TaskResponse { }, _, ) => None, - (BoundaryValidated { start, end, is_block_boundary: _ }, Interval::Cron(_)) => Some(Boundary::Time { + ( + BoundaryValidated { + start, + end, + is_block_boundary: _, + }, + Interval::Cron(_), + ) => Some(Boundary::Time { start: start.map(Timestamp::from_nanos), end: end.map(Timestamp::from_nanos), }), - (BoundaryValidated { start, end, is_block_boundary: _ }, _) => Some(Boundary::Height { + ( + BoundaryValidated { + start, + end, + is_block_boundary: _, + }, + _, + ) => Some(Boundary::Height { start: start.map(Into::into), end: end.map(Into::into), }), @@ -525,15 +539,29 @@ impl From for TaskWithQueriesResponse { BoundaryValidated { start: None, end: None, - is_block_boundary:None, + is_block_boundary: None, }, _, ) => None, - (BoundaryValidated { start, end, is_block_boundary: _ }, Interval::Cron(_)) => Some(Boundary::Time { + ( + BoundaryValidated { + start, + end, + is_block_boundary: _, + }, + Interval::Cron(_), + ) => Some(Boundary::Time { start: start.map(Timestamp::from_nanos), end: end.map(Timestamp::from_nanos), }), - (BoundaryValidated { start, end, is_block_boundary: _ }, _) => Some(Boundary::Height { + ( + BoundaryValidated { + start, + end, + is_block_boundary: _, + }, + _, + ) => Some(Boundary::Height { start: start.map(Into::into), end: end.map(Into::into), }), diff --git a/packages/cw-croncat-core/src/tests/msg.rs b/packages/cw-croncat-core/src/tests/msg.rs index be2dfb01..4baec7d2 100644 --- a/packages/cw-croncat-core/src/tests/msg.rs +++ b/packages/cw-croncat-core/src/tests/msg.rs @@ -44,7 +44,7 @@ fn everything_can_be_de_serialized() { boundary: BoundaryValidated { start: Some(54), end: Some(44), - is_block_boundary:Some(true), + is_block_boundary: Some(true), }, stop_on_fail: false, total_deposit: Default::default(), diff --git a/packages/cw-croncat-core/src/tests/types.rs b/packages/cw-croncat-core/src/tests/types.rs index ddecef61..64fd5178 100644 --- a/packages/cw-croncat-core/src/tests/types.rs +++ b/packages/cw-croncat-core/src/tests/types.rs @@ -483,8 +483,7 @@ fn hashing() { boundary: BoundaryValidated { start: Some(4), end: None, - is_block_boundary:Some(true), - + is_block_boundary: Some(true), }, stop_on_fail: false, total_deposit: Default::default(), diff --git a/packages/cw-croncat-core/src/types.rs b/packages/cw-croncat-core/src/types.rs index 6511d946..aeb6b63d 100644 --- a/packages/cw-croncat-core/src/types.rs +++ b/packages/cw-croncat-core/src/types.rs @@ -106,6 +106,9 @@ pub struct BoundaryValidated { } impl BoundaryValidated { + pub fn is_block_boundary(&self) -> bool { + self.is_block_boundary.is_some() && self.is_block_boundary.unwrap() + } pub fn validate_boundary( boundary: Option, interval: &Interval, @@ -157,7 +160,7 @@ impl BoundaryValidated { Ok(Self { start: None, end: None, - is_block_boundary: None, + is_block_boundary: Some(true), //Boundary isnt provided, so default is block }) } } @@ -847,10 +850,10 @@ impl Intervals for Interval { // If Once, return the first block within a specific range that can be triggered 1 time. // If Immediate, return the first block within a specific range that can be triggered immediately, potentially multiple times. Interval::Once | Interval::Immediate => { - if boundary.is_block_boundary.unwrap_or_else(|| true) { - return get_next_block_limited(env, boundary); + if boundary.is_block_boundary() { + get_next_block_limited(env, boundary) } else { - return get_next_cron_time(env, boundary, "0 0 * * * *", slot_granularity_time); + get_next_cron_time(env, boundary, "0 0 * * * *", slot_granularity_time) } } // return the first block within a specific range that can be triggered 1 or more times based on timestamps. diff --git a/typescript/contracts/cw-croncat-core/CwCroncatCore.types.ts b/typescript/contracts/cw-croncat-core/CwCroncatCore.types.ts index 8785d9c1..ed11c713 100644 --- a/typescript/contracts/cw-croncat-core/CwCroncatCore.types.ts +++ b/typescript/contracts/cw-croncat-core/CwCroncatCore.types.ts @@ -8,7 +8,7 @@ export type Addr = string; export type Uint128 = string; export type Timestamp = Uint64; export type Uint64 = string; -export type SlotType = "Block" | "Cron"; +export type SlotType = "Block" | "Time"; export type AgentStatus = "Active" | "Pending" | "Nominated"; export type CosmosMsgForEmpty = { bank: BankMsg; @@ -390,6 +390,7 @@ export interface Task { } export interface BoundaryValidated { end?: number | null; + is_block_boundary?: boolean | null; start?: number | null; [k: string]: unknown; } From 249fc484a244c341effe32b885aefa3e8f30d6f2 Mon Sep 17 00:00:00 2001 From: Deveus Date: Wed, 21 Dec 2022 22:17:30 +0200 Subject: [PATCH 3/9] fix: Slot name --- checksum | 2 +- contracts/cw-croncat/src/contract.rs | 2 +- contracts/cw-croncat/src/manager.rs | 6 +-- contracts/cw-croncat/src/slots.rs | 2 +- contracts/cw-croncat/src/tasks.rs | 4 +- contracts/cw-croncat/src/tests/balance.rs | 2 +- contracts/cw-croncat/src/tests/contract.rs | 2 +- contracts/cw-croncat/src/tests/manager.rs | 2 +- contracts/cw-croncat/src/tests/slots.rs | 50 +++++++++---------- packages/cw-croncat-core/schema/croncat.json | 2 +- .../schema/get_state_response.json | 2 +- packages/cw-croncat-core/src/types.rs | 8 +-- .../cw-croncat-core/CwCroncatCore.types.ts | 2 +- 13 files changed, 43 insertions(+), 43 deletions(-) diff --git a/checksum b/checksum index 9cf081f5..3f8e09ff 100644 --- a/checksum +++ b/checksum @@ -1,2 +1,2 @@ -5dc7270852b2d6381eaa6ff382da54ca3417c00291846ad6583466c4c0cfd4e2 cw_croncat.wasm +f0064d55912d6ca72a1d2fdd9b7414a6e9698a7f87728807690c93a70f0d888e cw_croncat.wasm de2d1a0c648e41760020dd261f818da085c358240059acf85128f60eb0e05db2 cw_rules.wasm diff --git a/contracts/cw-croncat/src/contract.rs b/contracts/cw-croncat/src/contract.rs index d24c3b6b..62efb809 100644 --- a/contracts/cw-croncat/src/contract.rs +++ b/contracts/cw-croncat/src/contract.rs @@ -61,7 +61,7 @@ impl<'a> CwCroncat<'a> { owner_id, // treasury_id: None, min_tasks_per_agent: 3, - agent_active_indices: vec![(SlotType::Block, 0, 0), (SlotType::Time, 0, 0)], + agent_active_indices: vec![(SlotType::Block, 0, 0), (SlotType::Cron, 0, 0)], agents_eject_threshold: 600, // how many slots an agent can miss before being ejected. 10 * 60 = 1hr available_balance, staked_balance: GenericBalance::default(), diff --git a/contracts/cw-croncat/src/manager.rs b/contracts/cw-croncat/src/manager.rs index 76d75a9e..1e04d48b 100644 --- a/contracts/cw-croncat/src/manager.rs +++ b/contracts/cw-croncat/src/manager.rs @@ -36,7 +36,7 @@ impl<'a> CwCroncat<'a> { (slot_id, kind) } (None, Some(slot_id)) => { - let kind = SlotType::Time; + let kind = SlotType::Cron; (slot_id, kind) } (None, None) => { @@ -406,7 +406,7 @@ impl<'a> CwCroncat<'a> { self.block_map_queries .save(storage, task_hash.as_bytes(), &next_id)?; } - SlotType::Time => { + SlotType::Cron => { self.time_map_queries .save(storage, task_hash.as_bytes(), &next_id)?; } @@ -431,7 +431,7 @@ impl<'a> CwCroncat<'a> { SlotType::Block => { self.block_slots.update(storage, next_id, update_vec_data)?; } - SlotType::Time => { + SlotType::Cron => { self.time_slots.update(storage, next_id, update_vec_data)?; } } diff --git a/contracts/cw-croncat/src/slots.rs b/contracts/cw-croncat/src/slots.rs index 6ed8db53..c82efd85 100644 --- a/contracts/cw-croncat/src/slots.rs +++ b/contracts/cw-croncat/src/slots.rs @@ -64,7 +64,7 @@ impl<'a> CwCroncat<'a> { ) -> StdResult>> { let store = match kind { SlotType::Block => &self.block_slots, - SlotType::Time => &self.time_slots, + SlotType::Cron => &self.time_slots, }; let slot_data = store.may_load(storage, slot)?; diff --git a/contracts/cw-croncat/src/tasks.rs b/contracts/cw-croncat/src/tasks.rs index ad407d3c..e8227896 100644 --- a/contracts/cw-croncat/src/tasks.rs +++ b/contracts/cw-croncat/src/tasks.rs @@ -343,7 +343,7 @@ impl<'a> CwCroncat<'a> { self.block_map_queries .save(deps.storage, hash.as_bytes(), &next_id)?; } - SlotType::Time => { + SlotType::Cron => { self.time_map_queries .save(deps.storage, hash.as_bytes(), &next_id)?; } @@ -401,7 +401,7 @@ impl<'a> CwCroncat<'a> { self.block_slots .update(deps.storage, next_id, update_vec_data)?; } - SlotType::Time => { + SlotType::Cron => { self.time_slots .update(deps.storage, next_id, update_vec_data)?; } diff --git a/contracts/cw-croncat/src/tests/balance.rs b/contracts/cw-croncat/src/tests/balance.rs index 3345526e..12796102 100644 --- a/contracts/cw-croncat/src/tests/balance.rs +++ b/contracts/cw-croncat/src/tests/balance.rs @@ -395,7 +395,7 @@ fn test_on_agent_unregister() { .unwrap(); balancer.update_or_append(&mut config.agent_active_indices, (SlotType::Block, 0, 1)); - balancer.update_or_append(&mut config.agent_active_indices, (SlotType::Time, 0, 1)); + balancer.update_or_append(&mut config.agent_active_indices, (SlotType::Cron, 0, 1)); store.config.save(&mut deps.storage, &config).unwrap(); balancer .on_agent_unregister( diff --git a/contracts/cw-croncat/src/tests/contract.rs b/contracts/cw-croncat/src/tests/contract.rs index 65ffbca6..d64c4ae8 100644 --- a/contracts/cw-croncat/src/tests/contract.rs +++ b/contracts/cw-croncat/src/tests/contract.rs @@ -46,7 +46,7 @@ fn configure() { // assert_eq!(None, value.treasury_id); assert_eq!(3, value.min_tasks_per_agent); assert_eq!( - vec![(SlotType::Block, 0, 0), (SlotType::Time, 0, 0)], + vec![(SlotType::Block, 0, 0), (SlotType::Cron, 0, 0)], value.agent_active_indices ); assert_eq!(600, value.agents_eject_threshold); diff --git a/contracts/cw-croncat/src/tests/manager.rs b/contracts/cw-croncat/src/tests/manager.rs index 434de919..b63faf31 100644 --- a/contracts/cw-croncat/src/tests/manager.rs +++ b/contracts/cw-croncat/src/tests/manager.rs @@ -941,7 +941,7 @@ fn proxy_callback_time_slots() -> StdResult<()> { let attributes = vec![ ("method", "proxy_callback"), ("slot_id", "1571797860000000000"), - ("slot_kind", "Time"), + ("slot_kind", "Cron"), ("task_hash", task_id_str.as_str().clone()), ]; diff --git a/contracts/cw-croncat/src/tests/slots.rs b/contracts/cw-croncat/src/tests/slots.rs index ebb45932..0d0c98a7 100644 --- a/contracts/cw-croncat/src/tests/slots.rs +++ b/contracts/cw-croncat/src/tests/slots.rs @@ -277,7 +277,7 @@ fn interval_get_next_cron_time() { is_block_boundary: Some(false), }, 1_571_797_420_000_000_000, // current time in nanos is 1_571_797_419_879_305_533 - SlotType::Time, + SlotType::Cron, ), ( Interval::Cron("1 * * * * *".to_string()), @@ -287,7 +287,7 @@ fn interval_get_next_cron_time() { is_block_boundary: Some(false), }, 1_571_797_441_000_000_000, - SlotType::Time, + SlotType::Cron, ), ( Interval::Cron("* 0 * * * *".to_string()), @@ -297,7 +297,7 @@ fn interval_get_next_cron_time() { is_block_boundary: Some(false), }, 1_571_799_600_000_000_000, - SlotType::Time, + SlotType::Cron, ), ( Interval::Cron("15 0 * * * *".to_string()), @@ -307,7 +307,7 @@ fn interval_get_next_cron_time() { is_block_boundary: Some(false), }, 1_571_799_615_000_000_000, - SlotType::Time, + SlotType::Cron, ), // with start ( @@ -318,7 +318,7 @@ fn interval_get_next_cron_time() { is_block_boundary: Some(false), }, 1_571_799_615_000_000_000, - SlotType::Time, + SlotType::Cron, ), ( Interval::Cron("15 0 * * * *".to_string()), @@ -328,7 +328,7 @@ fn interval_get_next_cron_time() { is_block_boundary: Some(false), }, 1_571_799_615_000_000_000, - SlotType::Time, + SlotType::Cron, ), ( Interval::Cron("15 0 * * * *".to_string()), @@ -338,7 +338,7 @@ fn interval_get_next_cron_time() { is_block_boundary: Some(false), }, 1_571_803_215_000_000_000, - SlotType::Time, + SlotType::Cron, ), // cases when a boundary has end // current slot is the end slot @@ -350,7 +350,7 @@ fn interval_get_next_cron_time() { is_block_boundary: Some(false), }, 1_571_797_419_879_305_533, - SlotType::Time, + SlotType::Cron, ), // the next slot is after the end, return end slot ( @@ -361,7 +361,7 @@ fn interval_get_next_cron_time() { is_block_boundary: Some(false), }, 1_571_797_419_879_305_535, - SlotType::Time, + SlotType::Cron, ), // next slot in boundaries ( @@ -372,7 +372,7 @@ fn interval_get_next_cron_time() { is_block_boundary: Some(false), }, 1_571_797_420_000_000_000, - SlotType::Time, + SlotType::Cron, ), // the task has ended ( @@ -383,7 +383,7 @@ fn interval_get_next_cron_time() { is_block_boundary: Some(false), }, 0, - SlotType::Time, + SlotType::Cron, ), ]; for (interval, boundary, outcome_time, outcome_slot_kind) in cases.iter() { @@ -406,7 +406,7 @@ fn interval_get_next_cron_time() { // the timestamp is in the current slot, so we take the next slot 1_571_797_420_000_000_000_u64.saturating_sub(1_571_797_420_000_000_000 % TWO_MINUTES) + TWO_MINUTES, // current time in nanos is 1_571_797_419_879_305_533 - SlotType::Time, + SlotType::Cron, ), ( Interval::Cron("1 * * * * *".to_string()), @@ -416,7 +416,7 @@ fn interval_get_next_cron_time() { is_block_boundary: Some(false), }, 1_571_797_440_000_000_000, - SlotType::Time, + SlotType::Cron, ), ( Interval::Cron("* 0 * * * *".to_string()), @@ -426,7 +426,7 @@ fn interval_get_next_cron_time() { is_block_boundary: Some(false), }, 1_571_799_600_000_000_000, - SlotType::Time, + SlotType::Cron, ), ( Interval::Cron("15 0 * * * *".to_string()), @@ -436,7 +436,7 @@ fn interval_get_next_cron_time() { is_block_boundary: Some(false), }, 1_571_799_600_000_000_000, - SlotType::Time, + SlotType::Cron, ), // with start ( @@ -447,7 +447,7 @@ fn interval_get_next_cron_time() { is_block_boundary: Some(false), }, 1_571_799_600_000_000_000, - SlotType::Time, + SlotType::Cron, ), ( Interval::Cron("15 0 * * * *".to_string()), @@ -457,7 +457,7 @@ fn interval_get_next_cron_time() { is_block_boundary: Some(false), }, 1_571_799_600_000_000_000, - SlotType::Time, + SlotType::Cron, ), ( Interval::Cron("15 0 * * * *".to_string()), @@ -467,7 +467,7 @@ fn interval_get_next_cron_time() { is_block_boundary: Some(false), }, 1_571_803_200_000_000_000, - SlotType::Time, + SlotType::Cron, ), // cases when a boundary has end // boundary end in the current slot @@ -479,7 +479,7 @@ fn interval_get_next_cron_time() { is_block_boundary: Some(false), }, 1_571_797_320_000_000_000, - SlotType::Time, + SlotType::Cron, ), // next slot in boundaries ( @@ -490,7 +490,7 @@ fn interval_get_next_cron_time() { is_block_boundary: Some(false), }, 1_571_797_440_000_000_000, - SlotType::Time, + SlotType::Cron, ), // next slot after the end, return end slot ( @@ -501,7 +501,7 @@ fn interval_get_next_cron_time() { is_block_boundary: Some(false), }, 1_571_797_320_000_000_000, - SlotType::Time, + SlotType::Cron, ), // the task has ended ( @@ -512,7 +512,7 @@ fn interval_get_next_cron_time() { is_block_boundary: Some(false), }, 0, - SlotType::Time, + SlotType::Cron, ), ]; for (interval, boundary, outcome_time, outcome_slot_kind) in cases.iter() { @@ -611,7 +611,7 @@ fn slot_items_pop() { .unwrap(); assert_eq!( Ok(None), - store.pop_slot_item(&mut deps.storage, 0, SlotType::Time) + store.pop_slot_item(&mut deps.storage, 0, SlotType::Cron) ); assert_eq!( Ok(None), @@ -636,7 +636,7 @@ fn slot_items_pop() { assert_eq!( *task, store - .pop_slot_item(&mut deps.storage, 1, SlotType::Time) + .pop_slot_item(&mut deps.storage, 1, SlotType::Cron) .unwrap() .unwrap() ); @@ -652,7 +652,7 @@ fn slot_items_pop() { // Slot removed if no hash left assert_eq!( Ok(None), - store.pop_slot_item(&mut deps.storage, 1, SlotType::Time) + store.pop_slot_item(&mut deps.storage, 1, SlotType::Cron) ); assert_eq!( Ok(None), diff --git a/packages/cw-croncat-core/schema/croncat.json b/packages/cw-croncat-core/schema/croncat.json index 8b005237..130a1e76 100644 --- a/packages/cw-croncat-core/schema/croncat.json +++ b/packages/cw-croncat-core/schema/croncat.json @@ -1400,7 +1400,7 @@ "type": "string", "enum": [ "Block", - "Time" + "Cron" ] }, "SmartQueries": { diff --git a/packages/cw-croncat-core/schema/get_state_response.json b/packages/cw-croncat-core/schema/get_state_response.json index 1aebf848..f72806ec 100644 --- a/packages/cw-croncat-core/schema/get_state_response.json +++ b/packages/cw-croncat-core/schema/get_state_response.json @@ -1161,7 +1161,7 @@ "type": "string", "enum": [ "Block", - "Time" + "Cron" ] }, "SlotWithQueriesResponse": { diff --git a/packages/cw-croncat-core/src/types.rs b/packages/cw-croncat-core/src/types.rs index aeb6b63d..ab1db318 100644 --- a/packages/cw-croncat-core/src/types.rs +++ b/packages/cw-croncat-core/src/types.rs @@ -171,7 +171,7 @@ impl BoundaryValidated { )] pub enum SlotType { Block, - Time, + Cron, } // #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] @@ -830,12 +830,12 @@ fn get_next_cron_time( }; match boundary.end { - Some(end) if current_block_ts > end => (0, SlotType::Time), + Some(end) if current_block_ts > end => (0, SlotType::Cron), Some(end) => { let end_slot = end.saturating_sub(end % slot_granularity_time); - (u64::min(end_slot, next_slot), SlotType::Time) + (u64::min(end_slot, next_slot), SlotType::Cron) } - _ => (next_slot, SlotType::Time), + _ => (next_slot, SlotType::Cron), } } diff --git a/typescript/contracts/cw-croncat-core/CwCroncatCore.types.ts b/typescript/contracts/cw-croncat-core/CwCroncatCore.types.ts index ed11c713..84c73fea 100644 --- a/typescript/contracts/cw-croncat-core/CwCroncatCore.types.ts +++ b/typescript/contracts/cw-croncat-core/CwCroncatCore.types.ts @@ -8,7 +8,7 @@ export type Addr = string; export type Uint128 = string; export type Timestamp = Uint64; export type Uint64 = string; -export type SlotType = "Block" | "Time"; +export type SlotType = "Block" | "Cron"; export type AgentStatus = "Active" | "Pending" | "Nominated"; export type CosmosMsgForEmpty = { bank: BankMsg; From 260ee01e019463bfaeacd64a2db0c532ae97ecfe Mon Sep 17 00:00:00 2001 From: Deveus Date: Thu, 22 Dec 2022 00:09:41 +0200 Subject: [PATCH 4/9] fix: tests --- .rusty-hook.toml | 4 +- checksum | 2 +- contracts/cw-croncat/src/manager.rs | 7 ++ contracts/cw-croncat/src/tests/agent.rs | 2 +- contracts/cw-croncat/src/tests/manager.rs | 113 +++++++++++----------- contracts/cw-croncat/src/tests/owner.rs | 1 - contracts/cw-croncat/src/tests/state.rs | 2 +- contracts/cw-croncat/src/tests/tasks.rs | 2 +- 8 files changed, 72 insertions(+), 61 deletions(-) diff --git a/.rusty-hook.toml b/.rusty-hook.toml index 6b5b6d2b..f48a7311 100644 --- a/.rusty-hook.toml +++ b/.rusty-hook.toml @@ -1,6 +1,6 @@ [hooks] -pre-commit = "just lint test" -pre-push = "just all" +pre-commit = "just lint" + [logging] verbose = true diff --git a/checksum b/checksum index d38aed15..130f0af4 100644 --- a/checksum +++ b/checksum @@ -1,2 +1,2 @@ -c678d3d62965d9ba4982766fbd4bafcb8d7c0df2bdc089da0f975f3d78c84c0d cw_croncat.wasm +d4b3480855a5e1204b5b004fea389872331fd9893ad8c4fa599d6c2163442e6e cw_croncat.wasm 348ce203ce7a18c2e28f001139c1f7a215f7a569c735825dc819dc79692aaffb cw_rules.wasm diff --git a/contracts/cw-croncat/src/manager.rs b/contracts/cw-croncat/src/manager.rs index 1e04d48b..fe02a668 100644 --- a/contracts/cw-croncat/src/manager.rs +++ b/contracts/cw-croncat/src/manager.rs @@ -349,6 +349,13 @@ impl<'a> CwCroncat<'a> { Response::new() }; + println!( + "{:?} {:?} {:?} {:?}", + task.interval, + queue_item.failure.is_some(), + task.verify_enough_balances(false).is_err(), + next_id + ); // if non-recurring, exit if task.interval == Interval::Once || (task.stop_on_fail && queue_item.failure.is_some()) diff --git a/contracts/cw-croncat/src/tests/agent.rs b/contracts/cw-croncat/src/tests/agent.rs index 135bd124..8fd31829 100644 --- a/contracts/cw-croncat/src/tests/agent.rs +++ b/contracts/cw-croncat/src/tests/agent.rs @@ -618,7 +618,7 @@ fn accept_nomination_agent() { let res = add_task_exec(&mut app, &contract_addr, PARTICIPANT0); let task_hash = res.events[1].attributes[4].clone().value; assert_eq!( - "5dec2a8582a02f7212ccc2aee98807e83aaa92d399ce1331de474a279bcd1efd", task_hash, + "c2c2867b1833b35632ff663cd6dbaf4860b35cada0433699eaaeda90e6010297", task_hash, "Unexpected task hash" ); diff --git a/contracts/cw-croncat/src/tests/manager.rs b/contracts/cw-croncat/src/tests/manager.rs index 0eec9d72..ab7d6578 100644 --- a/contracts/cw-croncat/src/tests/manager.rs +++ b/contracts/cw-croncat/src/tests/manager.rs @@ -255,7 +255,7 @@ fn proxy_call_success() -> StdResult<()> { let contract_addr = cw_template_contract.addr(); let proxy_call_msg = ExecuteMsg::ProxyCall { task_hash: None }; let task_id_str = - "25753e42d62dc9a1ac3cf6b3fcfd773f6dc802cf0a0fea9f56e4dca7272882e8".to_string(); + "53b21f5454aa8fd2df46ffb4a07fc45477e4ff1a1b8fe0771376d67eaaea4dcb".to_string(); // Doing this msg since its the easiest to guarantee success in reply let msg = CosmosMsg::Wasm(WasmMsg::Execute { @@ -295,7 +295,7 @@ fn proxy_call_success() -> StdResult<()> { let mut has_created_hash: bool = false; for e in res.events { for a in e.attributes { - if a.key == "task_hash" && a.value == task_id_str.clone() { + if a.key == "task_hash" && a.value.len() > 0 { has_created_hash = true; } } @@ -393,6 +393,8 @@ fn proxy_call_success() -> StdResult<()> { if let Some(value) = attr_value { if v.to_string() != value { has_required_attributes = false; + println!("{:?}", _key); + println!("{:?}", value); } } else { has_required_attributes = false; @@ -512,7 +514,7 @@ fn proxy_callback_fail_cases() -> StdResult<()> { let contract_addr = cw_template_contract.addr(); let proxy_call_msg = ExecuteMsg::ProxyCall { task_hash: None }; let task_id_str = - "a3728ab387cf4b508f1bc729290df8939eb15647ed6efacfd6fc01d401c21840".to_string(); + "ed4e2f3e3bd72f982145b04fdc4ffca4a03df10bb95b8c7f807b4f06a5b98f91".to_string(); // Doing this msg since its the easiest to guarantee success in reply let validator = String::from("you"); @@ -551,7 +553,7 @@ fn proxy_callback_fail_cases() -> StdResult<()> { let mut has_created_hash: bool = false; for e in res.events { for a in e.attributes { - if a.key == "task_hash" && a.value == task_id_str.clone() { + if a.key == "task_hash" && a.value.len() > 0 { has_created_hash = true; } } @@ -621,6 +623,8 @@ fn proxy_callback_fail_cases() -> StdResult<()> { if let Some(value) = attr_value { if v.to_string() != value { has_required_attributes = false; + println!("{:?}", _key); + println!("{:?}", value); } } else { has_required_attributes = false; @@ -740,7 +744,7 @@ fn proxy_callback_block_slots() -> StdResult<()> { let contract_addr = cw_template_contract.addr(); let proxy_call_msg = ExecuteMsg::ProxyCall { task_hash: None }; let task_id_str = - "25753e42d62dc9a1ac3cf6b3fcfd773f6dc802cf0a0fea9f56e4dca7272882e8".to_string(); + "53b21f5454aa8fd2df46ffb4a07fc45477e4ff1a1b8fe0771376d67eaaea4dcb".to_string(); // Doing this msg since its the easiest to guarantee success in reply let msg = CosmosMsg::Wasm(WasmMsg::Execute { @@ -872,7 +876,7 @@ fn proxy_callback_time_slots() -> StdResult<()> { let contract_addr = cw_template_contract.addr(); let proxy_call_msg = ExecuteMsg::ProxyCall { task_hash: None }; let task_id_str = - "3a897a48bda24a2bb264e3b5df410e05d6c735df3c268e887626f84ab42ae2d1".to_string(); + "7d125c998e4e105af366c2a66bdc09bf2b52275f5b400033684484b0348927df".to_string(); // Doing this msg since its the easiest to guarantee success in reply let msg = CosmosMsg::Wasm(WasmMsg::Execute { @@ -980,10 +984,9 @@ fn proxy_callback_time_slots() -> StdResult<()> { if let Some(_key) = attr_key { if let Some(value) = attr_value { if v.to_string() != value { + has_required_attributes = false; println!("{:?}", _key); println!("{:?}", value); - - has_required_attributes = false; } } else { has_required_attributes = false; @@ -1775,6 +1778,7 @@ fn test_reschedule_task_with_queries() { for e in create_task_resp.events { for a in e.attributes { if a.key == "task_hash" && a.value.len() > 0 { + println!("{:?}", a.value); task_hash = a.value; } } @@ -1852,17 +1856,17 @@ fn test_reschedule_task_with_queries() { assert!(tasks_response.is_empty()); // Run it a bunch of times successfully, until it's removed because the balance falls too low - for _ in 1..8 { - assert!(app + for _ in 1..12 { + let _ = app .execute_contract( Addr::unchecked(AGENT0), contract_addr.clone(), &ExecuteMsg::ProxyCall { - task_hash: Some(String::from(task_hash.clone())), + task_hash: Some(task_hash.clone()), }, &[], ) - .is_ok()); + .is_ok(); } let tasks_with_queries: Vec = app @@ -1875,6 +1879,7 @@ fn test_reschedule_task_with_queries() { }, ) .unwrap(); + assert!(tasks_with_queries.is_empty()); } @@ -2308,20 +2313,20 @@ fn testing_fee_works() { app.update_block(add_little_time); - let tasks: Vec = app - .wrap() - .query_wasm_smart( - contract_addr.clone(), - &QueryMsg::GetTasks { - from_index: None, - limit: None, - }, - ) - .unwrap(); - let tasks: Vec<(Vec, Vec)> = tasks - .into_iter() - .map(|task| (task.total_deposit, task.actions)) - .collect(); + // let tasks: Vec = app + // .wrap() + // .query_wasm_smart( + // contract_addr.clone(), + // &QueryMsg::GetTasks { + // from_index: None, + // limit: None, + // }, + // ) + // .unwrap(); + // let tasks: Vec<(Vec, Vec)> = tasks + // .into_iter() + // .map(|task| (task.total_deposit, task.actions)) + // .collect(); let proxy_call_msg = ExecuteMsg::ProxyCall { task_hash: None }; app.execute_contract( @@ -2333,20 +2338,20 @@ fn testing_fee_works() { .unwrap(); app.update_block(add_little_time); - let tasks: Vec = app - .wrap() - .query_wasm_smart( - contract_addr.clone(), - &QueryMsg::GetTasks { - from_index: None, - limit: None, - }, - ) - .unwrap(); - let tasks: Vec<(Vec, Vec)> = tasks - .into_iter() - .map(|task| (task.total_deposit, task.actions)) - .collect(); + // let tasks: Vec = app + // .wrap() + // .query_wasm_smart( + // contract_addr.clone(), + // &QueryMsg::GetTasks { + // from_index: None, + // limit: None, + // }, + // ) + // .unwrap(); + // let tasks: Vec<(Vec, Vec)> = tasks + // .into_iter() + // .map(|task| (task.total_deposit, task.actions)) + // .collect(); let proxy_call_msg = ExecuteMsg::ProxyCall { task_hash: None }; app.execute_contract( @@ -2358,20 +2363,20 @@ fn testing_fee_works() { .unwrap(); app.update_block(add_little_time); - let tasks: Vec = app - .wrap() - .query_wasm_smart( - contract_addr.clone(), - &QueryMsg::GetTasks { - from_index: None, - limit: None, - }, - ) - .unwrap(); - let tasks: Vec<(Vec, Vec)> = tasks - .into_iter() - .map(|task| (task.total_deposit, task.actions)) - .collect(); + // let tasks: Vec = app + // .wrap() + // .query_wasm_smart( + // contract_addr.clone(), + // &QueryMsg::GetTasks { + // from_index: None, + // limit: None, + // }, + // ) + // .unwrap(); + // let tasks: Vec<(Vec, Vec)> = tasks + // .into_iter() + // .map(|task| (task.total_deposit, task.actions)) + // .collect(); let proxy_call_msg = ExecuteMsg::ProxyCall { task_hash: None }; app.execute_contract( diff --git a/contracts/cw-croncat/src/tests/owner.rs b/contracts/cw-croncat/src/tests/owner.rs index 7d124e42..cb9f9fdc 100644 --- a/contracts/cw-croncat/src/tests/owner.rs +++ b/contracts/cw-croncat/src/tests/owner.rs @@ -290,4 +290,3 @@ fn move_balances_native() { // // assert_eq!(true, value.paused); // // assert_eq!(info.sender, value.owner_id); // } - diff --git a/contracts/cw-croncat/src/tests/state.rs b/contracts/cw-croncat/src/tests/state.rs index 7b6761c8..9e85afe8 100644 --- a/contracts/cw-croncat/src/tests/state.rs +++ b/contracts/cw-croncat/src/tests/state.rs @@ -38,7 +38,7 @@ fn check_task_storage_structure() -> StdResult<()> { transforms: None, version: version.version, }; - let task_id_str = "4124b30f4922f756db2660894647d7642ca1f1814744e148016e5557bf5f8f3b"; + let task_id_str = "74b918b7c8ff739ff30e47e2053b2be194b365de2825eaa21c37b349871db9bb"; let task_id = task_id_str.to_string().into_bytes(); // create a task diff --git a/contracts/cw-croncat/src/tests/tasks.rs b/contracts/cw-croncat/src/tests/tasks.rs index 805593f3..21b2f6f7 100644 --- a/contracts/cw-croncat/src/tests/tasks.rs +++ b/contracts/cw-croncat/src/tests/tasks.rs @@ -64,7 +64,7 @@ fn query_task_hash_success() { ) .unwrap(); assert_eq!( - "4124b30f4922f756db2660894647d7642ca1f1814744e148016e5557bf5f8f3b", + "74b918b7c8ff739ff30e47e2053b2be194b365de2825eaa21c37b349871db9bb", task_hash ); } From 354ddec49787077434804e376aefa583b286b89d Mon Sep 17 00:00:00 2001 From: Deveus Date: Thu, 22 Dec 2022 00:18:59 +0200 Subject: [PATCH 5/9] fix: minor fixes --- contracts/cw-croncat/src/tests/manager.rs | 11 ----------- contracts/cw-croncat/src/tests/receiver.rs | 1 - contracts/cw-croncat/src/tests/tasks.rs | 22 +++++++++++----------- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/contracts/cw-croncat/src/tests/manager.rs b/contracts/cw-croncat/src/tests/manager.rs index ab7d6578..3b85c4a5 100644 --- a/contracts/cw-croncat/src/tests/manager.rs +++ b/contracts/cw-croncat/src/tests/manager.rs @@ -393,8 +393,6 @@ fn proxy_call_success() -> StdResult<()> { if let Some(value) = attr_value { if v.to_string() != value { has_required_attributes = false; - println!("{:?}", _key); - println!("{:?}", value); } } else { has_required_attributes = false; @@ -623,8 +621,6 @@ fn proxy_callback_fail_cases() -> StdResult<()> { if let Some(value) = attr_value { if v.to_string() != value { has_required_attributes = false; - println!("{:?}", _key); - println!("{:?}", value); } } else { has_required_attributes = false; @@ -851,9 +847,6 @@ fn proxy_callback_block_slots() -> StdResult<()> { if let Some(_key) = attr_key { if let Some(value) = attr_value { if v.to_string() != value { - println!("{:?}", _key); - println!("{:?}", value); - has_required_attributes = false; } } else { @@ -985,8 +978,6 @@ fn proxy_callback_time_slots() -> StdResult<()> { if let Some(value) = attr_value { if v.to_string() != value { has_required_attributes = false; - println!("{:?}", _key); - println!("{:?}", value); } } else { has_required_attributes = false; @@ -1778,7 +1769,6 @@ fn test_reschedule_task_with_queries() { for e in create_task_resp.events { for a in e.attributes { if a.key == "task_hash" && a.value.len() > 0 { - println!("{:?}", a.value); task_hash = a.value; } } @@ -3153,7 +3143,6 @@ fn queries_fees() { &vec![], ) .unwrap(); - print!("{:#?}", res); assert!(res.events.iter().any(|ev| ev .attributes diff --git a/contracts/cw-croncat/src/tests/receiver.rs b/contracts/cw-croncat/src/tests/receiver.rs index 42f351b5..2ac8fa37 100644 --- a/contracts/cw-croncat/src/tests/receiver.rs +++ b/contracts/cw-croncat/src/tests/receiver.rs @@ -335,7 +335,6 @@ fn test_cw20_negative() { .unwrap_err() .downcast() .unwrap(); - println!("resp: {resp:?}"); assert!(matches!( resp, ContractError::CoreError(CoreError::NotEnoughCw20 { lack, .. }) if lack == Uint128::from(10_u128))); diff --git a/contracts/cw-croncat/src/tests/tasks.rs b/contracts/cw-croncat/src/tests/tasks.rs index 21b2f6f7..7ae6b64e 100644 --- a/contracts/cw-croncat/src/tests/tasks.rs +++ b/contracts/cw-croncat/src/tests/tasks.rs @@ -217,17 +217,17 @@ fn query_get_tasks_pagination() { let expected_amnt: usize = (tasks_amnt - from_index).try_into().unwrap(); assert_eq!(part_of_tasks.len(), expected_amnt); - println!( - "half_tasks: {:?}\n hash_vec:{:?}", - part_of_tasks - .iter() - .map(|t| t.task_hash.clone()) - .collect::>(), - all_tasks - .iter() - .map(|t| t.task_hash.clone()) - .collect::>(), - ); + // println!( + // "half_tasks: {:?}\n hash_vec:{:?}", + // part_of_tasks + // .iter() + // .map(|t| t.task_hash.clone()) + // .collect::>(), + // all_tasks + // .iter() + // .map(|t| t.task_hash.clone()) + // .collect::>(), + // ); // Check it's in right order for i in 0..expected_amnt { From def28fe04721352eb8b39151dd9927700a61b9d0 Mon Sep 17 00:00:00 2001 From: Deveus Date: Thu, 22 Dec 2022 00:23:12 +0200 Subject: [PATCH 6/9] fix: checksum --- checksum | 4 ---- 1 file changed, 4 deletions(-) diff --git a/checksum b/checksum index ae7e3d35..130f0af4 100644 --- a/checksum +++ b/checksum @@ -1,6 +1,2 @@ -<<<<<<< HEAD d4b3480855a5e1204b5b004fea389872331fd9893ad8c4fa599d6c2163442e6e cw_croncat.wasm -======= -5b3d3dcfb83ae291ee39c7c3f34626995036caa6deec74a08f08b163fbbb9ecc cw_croncat.wasm ->>>>>>> main 348ce203ce7a18c2e28f001139c1f7a215f7a569c735825dc819dc79692aaffb cw_rules.wasm From b47d01509685b405d7ca737d4bf9bad20abec7a0 Mon Sep 17 00:00:00 2001 From: Deveus Date: Thu, 22 Dec 2022 00:30:14 +0200 Subject: [PATCH 7/9] fix: checksum --- checksum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checksum b/checksum index 130f0af4..d26a9c78 100644 --- a/checksum +++ b/checksum @@ -1,2 +1,2 @@ -d4b3480855a5e1204b5b004fea389872331fd9893ad8c4fa599d6c2163442e6e cw_croncat.wasm +77a31473ff91b6c28639e98d502882a5154b1fdc05b011f5448fca33542bea49 cw_croncat.wasm 348ce203ce7a18c2e28f001139c1f7a215f7a569c735825dc819dc79692aaffb cw_rules.wasm From e455468dae5141df6a815d1a46dd6a80beff5e8f Mon Sep 17 00:00:00 2001 From: Deveus Date: Thu, 22 Dec 2022 01:10:35 +0200 Subject: [PATCH 8/9] fix: minor fixes --- checksum | 2 +- contracts/cw-croncat/src/manager.rs | 7 ------- contracts/cw-croncat/src/tasks.rs | 4 ---- contracts/cw-croncat/src/tests/tasks.rs | 12 ------------ 4 files changed, 1 insertion(+), 24 deletions(-) diff --git a/checksum b/checksum index d26a9c78..aa625cc4 100644 --- a/checksum +++ b/checksum @@ -1,2 +1,2 @@ -77a31473ff91b6c28639e98d502882a5154b1fdc05b011f5448fca33542bea49 cw_croncat.wasm +2768416d7e7b7937dbe8e1b8f77d22141aaee5e1e0928d3de02e015a821bbee2 cw_croncat.wasm 348ce203ce7a18c2e28f001139c1f7a215f7a569c735825dc819dc79692aaffb cw_rules.wasm diff --git a/contracts/cw-croncat/src/manager.rs b/contracts/cw-croncat/src/manager.rs index fe02a668..1e04d48b 100644 --- a/contracts/cw-croncat/src/manager.rs +++ b/contracts/cw-croncat/src/manager.rs @@ -349,13 +349,6 @@ impl<'a> CwCroncat<'a> { Response::new() }; - println!( - "{:?} {:?} {:?} {:?}", - task.interval, - queue_item.failure.is_some(), - task.verify_enough_balances(false).is_err(), - next_id - ); // if non-recurring, exit if task.interval == Interval::Once || (task.stop_on_fail && queue_item.failure.is_some()) diff --git a/contracts/cw-croncat/src/tasks.rs b/contracts/cw-croncat/src/tasks.rs index 43ea364e..625ae7f9 100644 --- a/contracts/cw-croncat/src/tasks.rs +++ b/contracts/cw-croncat/src/tasks.rs @@ -416,10 +416,6 @@ impl<'a> CwCroncat<'a> { .add_attribute("slot_id", next_id.to_string()) .add_attribute("slot_kind", format!("{:?}", slot_kind)) .add_attribute("task_hash", hash) - .add_attribute( - "is_block_boundary", - boundary.is_block_boundary.unwrap_or_default().to_string(), - ) .add_attribute("with_queries", with_queries.to_string())) } diff --git a/contracts/cw-croncat/src/tests/tasks.rs b/contracts/cw-croncat/src/tests/tasks.rs index 7705e327..8191993d 100644 --- a/contracts/cw-croncat/src/tests/tasks.rs +++ b/contracts/cw-croncat/src/tests/tasks.rs @@ -220,18 +220,6 @@ fn query_get_tasks_pagination() { let expected_amnt: usize = (tasks_amnt - from_index).try_into().unwrap(); assert_eq!(part_of_tasks.len(), expected_amnt); - // println!( - // "half_tasks: {:?}\n hash_vec:{:?}", - // part_of_tasks - // .iter() - // .map(|t| t.task_hash.clone()) - // .collect::>(), - // all_tasks - // .iter() - // .map(|t| t.task_hash.clone()) - // .collect::>(), - // ); - // Check it's in right order for i in 0..expected_amnt { assert_eq!( From 85858a49ebadca234decdaab5a1367fa07933bd4 Mon Sep 17 00:00:00 2001 From: Deveus Date: Thu, 22 Dec 2022 02:23:38 +0200 Subject: [PATCH 9/9] fix: checksum --- checksum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checksum b/checksum index 873e6b32..2ec67374 100644 --- a/checksum +++ b/checksum @@ -1,2 +1,2 @@ -f02ba448d956da4cc508cafdf14dd010e3ac0d37f5d40fa3116d27093d3a6ce1 cw_croncat.wasm +fc76a0e370c9e947d6e33d018585137d566f32d1a1fb06b1b49e695e5984a57e cw_croncat.wasm 348ce203ce7a18c2e28f001139c1f7a215f7a569c735825dc819dc79692aaffb cw_rules.wasm