zoukankan      html  css  js  c++  java
  • 以太坊:测试合约

    测试合约

    Framework

    Truffle comes standard with an automated testing framework to make testing your contracts a breeze. This framework lets you write simple and manageable tests in two different ways:

    • In Javascript and TypeScript, for exercising your contracts from the outside world, just like your application.

    • In Solidity, for exercising your contracts in advanced, bare-to-the-metal scenarios.

    Both styles of tests have their advantages and drawbacks. See the next two sections for a discussion of each one.

    Location

    All test files should be located in the ./test directory. Truffle will only run test files with the following file extensions: .js.ts.es.es6, and .jsx, and .sol. All other files are ignored.

    Command

    To run all tests, simply run:

    $ truffle test
    

    Alternatively, you can specify a path to a specific file you want to run, e.g.,

    $ truffle test ./path/to/test/file.js
    

    Clean-room environment

    Truffle provides a clean room environment when running your test files. When running your tests against Ganache or Truffle Develop, Truffle will use advanced snapshotting features to ensure your test files don’t share state with each other. When running against other Ethereum clients like go-ethereum, Truffle will re-deploy all of your migrations at the beginning of every test file to ensure you have a fresh set of contracts to test against.

    Speed and reliability considerations

    Both Ganache and Truffle Develop are significantly faster than other clients when running automated tests. Moreover, they contain special features which Truffle takes advantage of to speed up test runtime by almost 90%. As a general workflow, we recommend you use Ganache or Truffle Develop during normal development and testing, and then run your tests once against go-ethereum or another official Ethereum client when you’re gearing up to deploy to live or production networks.

  • 相关阅读:
    TextOut和DrawText
    VC中字符串定义
    #define new DEBUG_NEW
    洛谷【P2257】 YY的GCD
    Lizards and Basements 2 解题报告
    在windows服务中添加WCF
    从数据库中获得表的字段和描述信息
    sql格式化工具
    在XPSP3中添允许多个远程桌面的步骤
    无法连接到WCF的异常
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13313076.html
Copyright © 2011-2022 走看看