小编Edw*_*ova的帖子

使用 @nomiclabs/hardhat-waffle 实现装置

在官方华夫饼文档中,您可能会找到实现装置的下一种方法:

import {expect} from 'chai';
import {loadFixture, deployContract} from 'ethereum-waffle';
import BasicTokenMock from './build/BasicTokenMock';

describe('Fixtures', () => {
  async function fixture([wallet, other], provider) {
    const token = await deployContract(wallet, BasicTokenMock, [
      wallet.address, 1000
    ]);
    return {token, wallet, other};
  }

  it('Assigns initial balance', async () => {
    const {token, wallet} = await loadFixture(fixture);
    expect(await token.balanceOf(wallet.address)).to.equal(1000);
  });

  it('Transfer adds amount to destination account', async () => {
    const {token, other} = await loadFixture(fixture);
    await token.transfer(other.address, 7);
    expect(await token.balanceOf(other.address)).to.equal(7);
  });
});
Run Code Online (Sandbox Code Playgroud)

但是,在安全帽上使用该插件时这将不起作用。插件文档没有给出官方说明。

回答如下。

waffle typescript ethereum solidity hardhat

5
推荐指数
1
解决办法
3301
查看次数

标签 统计

ethereum ×1

hardhat ×1

solidity ×1

typescript ×1

waffle ×1