Git Product home page Git Product logo

dss-test's Introduction

dss-test

Modern test framework for Maker repositories. Get up and running with MCD faster.

Getting Started

First do forge install makerdao/dss-test (or dapp equivalent) in your newly setup repository.

Sample test:

pragma solidity 0.8.9;

import "dss-test/DSSTest.sol";

contract IntegrationTest is DSSTest {

    using GodMode for *;

    MCDUser myUser;

    function setupEnv() internal virtual override returns (MCD) {
        return autoDetectEnv();
    }

    function postSetup() internal virtual override {
        myUser = mcd.newUser();
    }

    function test_give_tokens() public {
        mcd.dai().setBalance(address(this), 100 ether);
        assertEq(mcd.dai().balanceOf(address(this)), 100 ether);
    }

    function test_create_liquidation() public {
        uint256 prevKicks = mcd.wethAClip().kicks();
        myUser.createAuction(mcd.wethAJoin(), 100 ether);
        assertEq(mcd.wethAClip().kicks(), prevKicks + 1);
    }

}

setupEnv() and postSetup() are hooks which allow you to configure both the environment you are in (mainnet, goerli, mocked) as well as an setup stuff that would normally go in setUp(). There is a special GodMode library which provides useful functions such as giving auth access to an arbitrary contract or setting token balances to any amount. You can also use GodMode.vm() to access all the underlying vm cheat codes.

MCD

An MCD instance is mostly just for keeping a bundle of references to all the common mcd contracts. If you are doing integration testing this can be set by either instantiating MCDMainnet or MCDGoerli or just use autoDetectEnv() to do this automatically. MCD also provides some high level functions:

  • deployIlk(address join) - This will deploy a new ilk to the vat along with standard liquidation and oracle components.

MCDUser

MCDUser instances can be used to interact with MCD. They represent the end users and can perform any number of actions. Usually what you will want to do is inherit this contract and extend the functionality to whatever library you are building. MCDUser provides some high level functions:

  • createAuction(address join, uint256 amount) - Kicks off a new auction for the specified join adapter for the amount of collateral specified.

dss-test's People

Contributors

hexonaut avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.