mirror of
https://github.com/zhigang1992/liquid-stacking.git
synced 2026-04-30 21:12:41 +08:00
moved lisa-rebase/rebase-1 into lqstx-mint-endpoint
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { tx } from '@hirosystems/clarinet-sdk';
|
||||
import { IntegerType } from '@stacks/common';
|
||||
import { BufferCV, Cl, ResponseOkCV, UIntCV } from '@stacks/transactions';
|
||||
import { Cl, ResponseOkCV, UIntCV } from '@stacks/transactions';
|
||||
|
||||
export const createClientMockSetup = () => {
|
||||
const accounts = simnet.getAccounts();
|
||||
|
||||
@@ -4,7 +4,7 @@ import { Cl } from '@stacks/transactions';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { createClientMockSetup } from './clients/mock-client';
|
||||
|
||||
const { contracts, prepareTest, requestMint, requestBurn, goToNextCycle, liSTXBalance, user, bot } =
|
||||
const { contracts, prepareTest, requestMint, requestBurn, goToNextCycle, liSTXBalance, goToNextRequestCycle, fundStrategy, user, bot } =
|
||||
createClientMockSetup();
|
||||
|
||||
const mintDelay = 14;
|
||||
@@ -31,15 +31,16 @@ describe('LiSTX NFT', () => {
|
||||
it('user can transfer nft before finalize mint', () => {
|
||||
prepareTest().map((e: any) => expect(e.result).toBeOk(Cl.bool(true)));
|
||||
let response = requestMint(100e6);
|
||||
console.log(response.events);
|
||||
expect(response.result).toBeOk(Cl.uint(1));
|
||||
|
||||
// transfer nft to bot
|
||||
response = transferMintNFT(1, bot);
|
||||
expect(response.result).toBeOk(Cl.bool(true));
|
||||
// finalize mint
|
||||
goToNextRequestCycle();
|
||||
expect(fundStrategy(100e6).result).toBeOk(Cl.uint(100e6));
|
||||
goToNextCycle();
|
||||
simnet.mineEmptyBlocks(mintDelay);
|
||||
simnet.mineEmptyBlocks(mintDelay + 1);
|
||||
simnet.callPublicFn(contracts.endpoint, 'finalize-mint', [Cl.uint(1)], bot);
|
||||
|
||||
// check that bot received liquid stx
|
||||
@@ -71,8 +72,10 @@ describe('LiSTX NFT', () => {
|
||||
// request and finalize mint
|
||||
response = requestMint(100e6);
|
||||
expect(response.result).toBeOk(Cl.uint(1));
|
||||
goToNextRequestCycle();
|
||||
expect(fundStrategy(1e6).result).toBeOk(Cl.uint(1e6));
|
||||
goToNextCycle();
|
||||
simnet.mineEmptyBlocks(mintDelay);
|
||||
simnet.mineEmptyBlocks(mintDelay + 1);
|
||||
response = simnet.callPublicFn(contracts.endpoint, 'finalize-mint', [Cl.uint(1)], bot);
|
||||
expect(response.result).toBeOk(Cl.bool(true));
|
||||
|
||||
@@ -81,7 +84,7 @@ describe('LiSTX NFT', () => {
|
||||
expect(response.result).toBeOk(
|
||||
Cl.tuple({ 'request-id': Cl.uint(1), status: Cl.bufferFromHex('01') })
|
||||
);
|
||||
response = requestBurn(40e6);
|
||||
response = requestBurn(39e6);
|
||||
expect(response.result).toBeOk(
|
||||
Cl.tuple({ 'request-id': Cl.uint(2), status: Cl.bufferFromHex('01') })
|
||||
);
|
||||
@@ -98,6 +101,6 @@ describe('LiSTX NFT', () => {
|
||||
|
||||
// check that bot received stx
|
||||
expect(simnet.getAssetsMap().get('STX')?.get(bot)).toBe(100000000000000n);
|
||||
expect(simnet.getAssetsMap().get('STX')?.get(user)).toBe(100000000000000n);
|
||||
expect(simnet.getAssetsMap().get('STX')?.get(user)).toBe(99999999000000n);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -11,6 +11,7 @@ const { contracts, user, user2, oracle, bot, manager,
|
||||
|
||||
// 1m STX
|
||||
const mintAmount = 1_000_000e6;
|
||||
|
||||
const mintDelay = 432;
|
||||
|
||||
describe(contracts.endpoint, () => {
|
||||
@@ -87,7 +88,7 @@ describe(contracts.endpoint, () => {
|
||||
simnet.mineEmptyBlocks(mintDelay + 1);
|
||||
expect(finalizeMint(1).result).toBeOk(Cl.bool(true));
|
||||
|
||||
expect(requestBurn(mintAmount).result).toBeOk(
|
||||
expect(requestBurn(1e6).result).toBeOk(
|
||||
Cl.tuple({ 'request-id': Cl.uint(1), status: Cl.bufferFromHex('00') })
|
||||
);
|
||||
|
||||
|
||||
@@ -2,16 +2,20 @@ import { Cl } from '@stacks/transactions';
|
||||
import { beforeEach, describe, expect } from 'vitest';
|
||||
import { createClientMockSetup } from './clients/mock-client';
|
||||
import { sip10Tests } from './clients/sip10-client.ts';
|
||||
const { goToNextCycle, requestMint, prepareTest, contracts, bot } = createClientMockSetup();
|
||||
const { goToNextCycle, goToNextRequestCycle, fundStrategy, requestMint, prepareTest, contracts, bot } = createClientMockSetup();
|
||||
const mintDelay = 14;
|
||||
|
||||
describe('lisa token', () => {
|
||||
beforeEach(() => {
|
||||
prepareTest().map(r => expect(r.result).toBeOk(Cl.bool(true)));
|
||||
requestMint(100e6);
|
||||
let response = requestMint(100e6);
|
||||
expect(response.result).toBeOk(Cl.uint(1));
|
||||
goToNextRequestCycle();
|
||||
expect(fundStrategy(1e6).result).toBeOk(Cl.uint(1e6));
|
||||
goToNextCycle();
|
||||
simnet.mineEmptyBlocks(mintDelay);
|
||||
simnet.callPublicFn(contracts.endpoint, 'finalize-mint', [Cl.uint(1)], bot);
|
||||
simnet.mineEmptyBlocks(mintDelay + 1);
|
||||
response = simnet.callPublicFn(contracts.endpoint, 'finalize-mint', [Cl.uint(1)], bot);
|
||||
expect(response.result).toBeOk(Cl.bool(true));
|
||||
});
|
||||
|
||||
sip10Tests(contracts.lqstx);
|
||||
|
||||
Reference in New Issue
Block a user