Test: add basic one for internal_transfer_unlocked
This commit is contained in:
parent
5b3d07ffb3
commit
68da83cfa9
|
@ -92,6 +92,16 @@ async fn test_internal_transfer() -> Result<(), TransportError> {
|
|||
let internal_transfer_locked = |source: u8, target: u8, amount: u64| {
|
||||
addin.internal_transfer_locked(®istrar, &voter, &voter_authority, source, target, amount)
|
||||
};
|
||||
let internal_transfer_unlocked = |source: u8, target: u8, amount: u64| {
|
||||
addin.internal_transfer_unlocked(
|
||||
®istrar,
|
||||
&voter,
|
||||
&voter_authority,
|
||||
source,
|
||||
target,
|
||||
amount,
|
||||
)
|
||||
};
|
||||
let time_offset = Arc::new(RefCell::new(0i64));
|
||||
let advance_time = |extra: u64| {
|
||||
*time_offset.borrow_mut() += extra as i64;
|
||||
|
@ -163,6 +173,30 @@ async fn test_internal_transfer() -> Result<(), TransportError> {
|
|||
);
|
||||
assert_eq!(lockup_status(1).await, (hour, 2 * day, 10, 20, 10));
|
||||
|
||||
//
|
||||
// test transfering unlocked funds
|
||||
//
|
||||
|
||||
internal_transfer_unlocked(2, 0, 1000)
|
||||
.await
|
||||
.expect_err("deposit entry not in use");
|
||||
internal_transfer_unlocked(1, 0, 11)
|
||||
.await
|
||||
.expect_err("amount too high");
|
||||
internal_transfer_unlocked(1, 0, 10).await.unwrap();
|
||||
assert_eq!(
|
||||
lockup_status(0).await,
|
||||
(day + 2 * hour, 2 * month, 210, 320, 110)
|
||||
);
|
||||
assert_eq!(lockup_status(1).await, (hour, 2 * day, 10, 10, 0));
|
||||
|
||||
internal_transfer_unlocked(0, 1, 100).await.unwrap();
|
||||
assert_eq!(
|
||||
lockup_status(0).await,
|
||||
(day + 2 * hour, 2 * month, 210, 220, 10)
|
||||
);
|
||||
assert_eq!(lockup_status(1).await, (hour, 2 * day, 10, 110, 100));
|
||||
|
||||
//
|
||||
// test partially moving tokens from constant deposit to cliff
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue