mirror of
https://github.com/zhigang1992/liquid-stacking.git
synced 2026-01-12 17:23:23 +08:00
chore: add test for request cycle
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
{extension: .lqstx-mint-endpoint, enabled: false}
|
||||
{extension: .lqstx-mint-endpoint-v1-02, enabled: true}
|
||||
{extension: .lisa-rebase-v1-02, enabled: true}
|
||||
{extension: .rebase-1-v1-02, enabled: true}
|
||||
{extension: .rebase-mock, enabled: true}
|
||||
{extension: .mock-strategy-manager, enabled: true}
|
||||
{extension: .lqstx-vault, enabled: true}
|
||||
{extension: .operators, enabled: true}
|
||||
|
||||
@@ -54,9 +54,6 @@ plan:
|
||||
emulated-sender: SP3FBR2AGK5H9QBDH3EEN6DF8EK8JY7RX8QJ5SVTE
|
||||
path: "./.cache/requirements/SP3FBR2AGK5H9QBDH3EEN6DF8EK8JY7RX8QJ5SVTE.sip-010-trait-ft-standard.clar"
|
||||
clarity-version: 1
|
||||
epoch: "2.0"
|
||||
- id: 1
|
||||
transactions:
|
||||
- emulated-contract-publish:
|
||||
contract-name: trait-sip-010
|
||||
emulated-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
|
||||
@@ -102,8 +99,8 @@ plan:
|
||||
emulated-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
|
||||
path: contracts_modules/alex_v1/traits/trait-vault.clar
|
||||
clarity-version: 1
|
||||
epoch: "2.05"
|
||||
- id: 2
|
||||
epoch: "2.1"
|
||||
- id: 1
|
||||
transactions:
|
||||
- emulated-contract-publish:
|
||||
contract-name: pox-pools-1-cycle-v2
|
||||
@@ -231,7 +228,7 @@ plan:
|
||||
path: contracts/strategies/public-pools/xverse-member.clar
|
||||
clarity-version: 2
|
||||
epoch: "2.4"
|
||||
- id: 3
|
||||
- id: 2
|
||||
transactions:
|
||||
- emulated-contract-publish:
|
||||
contract-name: xverse-member10
|
||||
@@ -359,7 +356,7 @@ plan:
|
||||
path: contracts/rules/rebase-1.clar
|
||||
clarity-version: 2
|
||||
epoch: "2.4"
|
||||
- id: 4
|
||||
- id: 3
|
||||
transactions:
|
||||
- emulated-contract-publish:
|
||||
contract-name: rebase-mock
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
import { tx } from '@hirosystems/clarinet-sdk';
|
||||
import { Cl, ResponseOkCV, UIntCV } from '@stacks/transactions';
|
||||
import { Cl, ResponseOkCV, UIntCV, cvToString } from '@stacks/transactions';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
const accounts = simnet.getAccounts();
|
||||
@@ -64,6 +63,23 @@ const getRewardCycle = () => {
|
||||
).value.value;
|
||||
};
|
||||
|
||||
const getRequestCycle = () => {
|
||||
return (
|
||||
simnet.callReadOnlyFn(
|
||||
contracts.endpoint,
|
||||
'get-request-cycle',
|
||||
[Cl.uint(simnet.blockHeight)],
|
||||
user
|
||||
).result as ResponseOkCV<UIntCV>
|
||||
).value.value;
|
||||
};
|
||||
|
||||
const getRequestCutoff = () => {
|
||||
return (
|
||||
simnet.callReadOnlyFn(contracts.endpoint, 'get-request-cutoff', [], user)
|
||||
.result as ResponseOkCV<UIntCV>
|
||||
).value;
|
||||
};
|
||||
const getBlocksToStartOfCycle = (cycle: bigint) => {
|
||||
return (
|
||||
Number(
|
||||
@@ -356,4 +372,24 @@ describe(contracts.endpoint, () => {
|
||||
expect(responses[0].result).toBeErr(Cl.uint(1001));
|
||||
expect(responses[1].result).toBeOk(Cl.bool(true));
|
||||
});
|
||||
|
||||
it('request cycle respects cutoff', () => {
|
||||
expect(getRequestCycle()).toBe(0n);
|
||||
// cycle length - prepare cycle length - cutoff - blocks for deployment
|
||||
simnet.mineEmptyBlocks(1050 - 50 - 100 - 4 - 1);
|
||||
// we are at the end of request cycle 0
|
||||
expect(simnet.blockHeight).toBe(899);
|
||||
expect(getRequestCycle()).toBe(0n);
|
||||
|
||||
simnet.mineEmptyBlocks(1050); // cycle length
|
||||
// we are at end of request cycle 1
|
||||
expect(simnet.blockHeight).toBe(1949);
|
||||
expect(getRequestCycle()).toBe(1n);
|
||||
|
||||
simnet.mineEmptyBlocks(1);
|
||||
// we are at beginning of request cycle 2
|
||||
// that is 1050 + 1050 - 50 - 100
|
||||
expect(simnet.blockHeight).toBe(1950);
|
||||
expect(getRequestCycle()).toBe(2n);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user