Liquidswap Docs
GithubDappPontem Network
Liquidswap V0 Docs
Liquidswap V0 Docs
  • Introduction
    • Security Audits
    • Bounty Program
    • Developer Links
  • Protocol Overview
  • Smart Contracts
    • Generics
    • LP Coins
    • Routers
    • Scripts
    • Advanced Topics
    • 💥V0.5 Update
  • Integration
    • Test Coins
    • Let's Swap
    • Create Pool
    • Add Liquidity
    • Burn Liquidity
    • Basic Oracle
    • Flashloans
    • Unit Testing
  • Staking / Harvest
    • Overview
    • Smart Contracts
    • Integration Examples
    • DApp
    • Create your own farming pool
  • SDKs
  • Liquidswap Widget
  • Liquidswap DApp
    • Bridge
    • Testnet
  • Coins Registry
Powered by GitBook
On this page
  1. Integration

Unit Testing

PreviousFlashloansNextStaking / Harvest

Last updated 2 years ago

This part explains how to write unit tests during integration with Liquidswap Smart Contracts.

Testing integration

To be able to run tests, you need to prepare the Liquidswap state in your test. There's a couple of utilities available to help you with that:

  • public fun initialize_liquidity_pool() []

It correctly initialize both Liquidswap and LP<X, Y, Curve> token of the Liquidswap. That process is pretty involved, so we provide this helper function to make it easier. Run it after the genesis::setup() call from Aptos Framework.

  • public fun mint_liquidity<X, Y, Curve>(lp_owner: &signer, coin_x: Coin<X>, coin_y: Coin<Y>): u64 []

Adds coin_x, coin_y to the pool, and automatically deposits returning lp coins to the lp_owner account, handling the edge cases.

An example of the test would be:

More examples

To learn Unit Tests more look at our Liquidswap and .

Unit Tests
Test Helpers
source
source
Example of unit test