|
2 | 2 | (define-constant ERR_UNWRAP u998)
|
3 | 3 | (define-constant ERR_UNEXPECTED_RESULT u997)
|
4 | 4 |
|
| 5 | +(define-data-var last-iteration-claimed uint u0) |
5 | 6 | (define-data-var minted-initial bool false)
|
6 | 7 |
|
7 | 8 | ;; Helper to set up the Rendezvous testing environment. This should be called
|
|
20 | 21 | )
|
21 | 22 | )
|
22 | 23 |
|
| 24 | +;; Helper to transfer extra STX amounts to the contract. In combination with |
| 25 | +;; other tests, this ensures that extra transfers do not break the vesting |
| 26 | +;; schedule. |
| 27 | +(define-public (test-helper-transfer-to-contract (ustx-amount uint)) |
| 28 | + (ok |
| 29 | + (and |
| 30 | + (not (is-eq tx-sender 'ST3FFKYTTB975A3JC3F99MM7TXZJ406R3GKE6JV56)) |
| 31 | + (> ustx-amount u0) |
| 32 | + (>= (stx-get-balance tx-sender) ustx-amount) |
| 33 | + (try! (stx-transfer? ustx-amount tx-sender (as-contract tx-sender))) |
| 34 | + ) |
| 35 | + ) |
| 36 | +) |
| 37 | + |
23 | 38 | ;; Tests that the recipient is updated if the caller is allowed.
|
24 | 39 | (define-public (test-update-recipient-allowed (new-recipient principal))
|
25 | 40 | (ok
|
|
111 | 126 | (let (
|
112 | 127 | (recipient-balance-before (stx-get-balance (var-get recipient)))
|
113 | 128 | (claimable (calc-claimable-amount burn-block-height))
|
| 129 | + (current-iteration (/ (- burn-block-height DEPLOY_BLOCK_HEIGHT) INITIAL_MINT_VESTING_ITERATION_BLOCKS)) |
114 | 130 | )
|
115 | 131 | (and
|
116 | 132 | (is-eq (var-get recipient) contract-caller tx-sender)
|
|
123 | 139 | )
|
124 | 140 | (err ERR_FAILED_ASSERTION)
|
125 | 141 | )
|
| 142 | + (var-set last-iteration-claimed current-iteration) |
| 143 | + ) |
| 144 | + ) |
| 145 | + ) |
| 146 | +) |
| 147 | + |
| 148 | +;; Tests that the claimable amount is greater than the STX per iteration if the |
| 149 | +;; last iteration claimed is less than the current iteration. |
| 150 | +(define-public (test-claimable-amount-gt-iteration-stx) |
| 151 | + (ok |
| 152 | + (let ( |
| 153 | + (recipient-balance-before (stx-get-balance (var-get recipient))) |
| 154 | + (claimable (calc-claimable-amount burn-block-height)) |
| 155 | + (current-iteration (/ (- burn-block-height DEPLOY_BLOCK_HEIGHT) INITIAL_MINT_VESTING_ITERATION_BLOCKS)) |
| 156 | + ) |
| 157 | + (and |
| 158 | + (is-eq (var-get recipient) contract-caller tx-sender) |
| 159 | + (> claimable u0) |
| 160 | + (> current-iteration (var-get last-iteration-claimed)) |
| 161 | + (asserts! (>= claimable STX_PER_ITERATION) (err claimable)) |
126 | 162 | )
|
127 | 163 | )
|
128 | 164 | )
|
|
0 commit comments