From 9a8e1fb202a7640c4fdb17a8a14ba1a00e2edd88 Mon Sep 17 00:00:00 2001 From: salman01zp Date: Thu, 18 Jan 2024 19:07:05 +0530 Subject: [PATCH] add more tests to vesting precompile --- precompiles/vesting/src/tests.rs | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/precompiles/vesting/src/tests.rs b/precompiles/vesting/src/tests.rs index 03e8a2254..1e1ad0309 100644 --- a/precompiles/vesting/src/tests.rs +++ b/precompiles/vesting/src/tests.rs @@ -40,6 +40,7 @@ fn test_unimplemented_selector_reverts() { }); } +// Test unlocking any vested funds of the sender account. #[test] fn test_claim_vesting_schedule() { ExtBuilder::default().build().execute_with(|| { @@ -52,3 +53,45 @@ fn test_claim_vesting_schedule() { .execute_returns(()); }); } + +// Test unlocking any vested funds of a `target` account. +#[test] +fn test_vest_other() { + ExtBuilder::default().build().execute_with(|| { + let schedules = + Vesting::::get(sp_core::sr25519::Public::from(TestAccount::Alex)).unwrap(); + assert!(!schedules.is_empty()); + roll_to(1000); + PrecompilesValue::get() + .prepare_test( + TestAccount::Bobo, + H160::from_low_u64_be(1), + PCall::vest_other { + target: sp_core::sr25519::Public::from(TestAccount::Alex).into(), + }, + ) + .execute_returns(()); + }); +} + +// Test vested transfer. +#[test] +fn test_vest_transfer() { + ExtBuilder::default().build().execute_with(|| { + let schedules = + Vesting::::get(sp_core::sr25519::Public::from(TestAccount::Alex)).unwrap(); + assert!(!schedules.is_empty()); + let target = TestAccount::Bobo; + roll_to(1000); + PrecompilesValue::get() + .prepare_test( + TestAccount::Alex, + H160::from_low_u64_be(1), + PCall::vested_transfer { + target: sp_core::sr25519::Public::from(target).into(), + index: 0, + }, + ) + .execute_returns(()); + }); +}