OpenZeppelin Test Helpers 使用教程

OpenZeppelin Test Helpers 使用教程

openzeppelin-test-helpersAssertion library for Ethereum smart contract testing项目地址:https://gitcode.com/gh_mirrors/op/openzeppelin-test-helpers

1. 项目的目录结构及介绍

OpenZeppelin Test Helpers 是一个用于帮助开发者编写智能合约测试的工具库。以下是其主要目录结构及介绍:

openzeppelin-test-helpers/
├── README.md
├── package.json
├── lib/
│   ├── assert.js
│   ├── balance.js
│   ├── blockchain.js
│   ├── ether.js
│   ├── expectRevert.js
│   ├── expectEvent.js
│   ├── time.js
│   ├── transaction.js
│   └── utils.js
├── test/
│   ├── assert.test.js
│   ├── balance.test.js
│   ├── blockchain.test.js
│   ├── ether.test.js
│   ├── expectRevert.test.js
│   ├── expectEvent.test.js
│   ├── time.test.js
│   ├── transaction.test.js
│   └── utils.test.js
└── .gitignore
  • README.md: 项目介绍文档。
  • package.json: 项目的依赖和脚本配置文件。
  • lib/: 包含所有测试辅助工具的源代码文件。
  • test/: 包含所有测试用例文件。
  • .gitignore: Git 忽略文件配置。

2. 项目的启动文件介绍

OpenZeppelin Test Helpers 没有传统意义上的“启动文件”,因为它是一个库,需要集成到你的测试环境中使用。通常,你会在你的测试文件中引入所需的辅助工具,例如:

const { expectRevert, time } = require('openzeppelin-test-helpers');

3. 项目的配置文件介绍

OpenZeppelin Test Helpers 的配置主要通过 package.json 文件进行管理。以下是 package.json 文件的主要内容:

{
  "name": "openzeppelin-test-helpers",
  "version": "0.5.10",
  "description": "A set of helpers for testing Ethereum smart contracts.",
  "main": "lib/index.js",
  "scripts": {
    "test": "mocha --exit --recursive test"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/OpenZeppelin/openzeppelin-test-helpers.git"
  },
  "keywords": [
    "ethereum",
    "smart",
    "contracts",
    "testing",
    "solidity",
    "zeppelin"
  ],
  "author": "OpenZeppelin Community <maintainers@openzeppelin.org>",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/OpenZeppelin/openzeppelin-test-helpers/issues"
  },
  "homepage": "https://github.com/OpenZeppelin/openzeppelin-test-helpers#readme",
  "dependencies": {
    "bn.js": "^5.1.1",
    "chai": "^4.2.0",
    "chai-bn": "^0.2.1",
    "ethers": "^4.0.47",
    "truffle": "^5.0.38"
  },
  "devDependencies": {
    "mocha": "^6.2.2"
  }
}
  • name: 项目名称。
  • version: 项目版本。
  • description: 项目描述。
  • main: 入口文件。
  • scripts: 包含运行测试的脚本。
  • dependencies: 项目依赖的其他库。
  • devDependencies: 开发环境依赖的其他库。

通过以上配置,你可以安装所需的依赖并运行测试脚本来验证你的智能合约测试。

openzeppelin-test-helpersAssertion library for Ethereum smart contract testing项目地址:https://gitcode.com/gh_mirrors/op/openzeppelin-test-helpers

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

史霁蔷Primrose

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值