Skip to content

Commit

Permalink
add more tests to vesting precompile
Browse files Browse the repository at this point in the history
  • Loading branch information
salman01zp committed Jan 18, 2024
1 parent d36a2dc commit 9a8e1fb
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions precompiles/vesting/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(|| {
Expand All @@ -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::<Runtime>::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::<Runtime>::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(());
});
}

0 comments on commit 9a8e1fb

Please sign in to comment.