Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,8 @@ __pycache__/
# Hardhat directories
artifacts
cache

# Waffle
*.tsbuildinfo
package-lock.json
test/builders/build/eth-api/dev-env/waffle/build
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
"prettier": "npx prettier --write .",
"javascript-test": "mocha -r dotenv/config 'test/**/*.js' --timeout 10000",
"hardhat-test": "npm --prefix ./test/builders/build/eth-api/dev-env/hardhat run update-packages && npm --prefix ./test/builders/build/eth-api/dev-env/hardhat run test",
"waffle-test": "npm --prefix ./test/builders/build/eth-api/dev-env/waffle run update-and-build && npm --prefix ./test/builders/build/eth-api/dev-env/waffle run test",
"python-test": "python3 test/run_python_tests.py",
"test": "npm run python-test && npm run hardhat-test && npm run javascript-test",
"test": "npm run python-test && npm run hardhat-test && npm run waffle-test && npm run javascript-test",
"update-packages": "npx npm-check-updates -u && npm install --silent"
},
"mocha": {
Expand Down
6 changes: 6 additions & 0 deletions test/builders/build/eth-api/dev-env/waffle/.mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"require": "ts-node/register/transpile-only",
"timeout": 600000,
"loader": ["ts-node/esm"],
"extension": "test.ts"
}
11 changes: 11 additions & 0 deletions test/builders/build/eth-api/dev-env/waffle/contracts/MyToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract MyToken is ERC20 {
constructor() ERC20("MyToken", "MYTOK") {}

function initialize(uint initialSupply) public {
_mint(msg.sender, initialSupply);
}
}
24 changes: 24 additions & 0 deletions test/builders/build/eth-api/dev-env/waffle/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "waffle",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "mocha",
"update-and-build": "npm install && rm -rf build && waffle"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@openzeppelin/contracts": "^5.0.1",
"@types/chai": "^4.3.11",
"@types/mocha": "^10.0.6",
"chai": "^4.2.0",
"ethereum-waffle": "^4.0.10",
"ethers": "^5.7.2",
"mocha": "^10.2.0",
"ts-node": "^10.9.2",
"typescript": "^5.3.3"
}
}
35 changes: 35 additions & 0 deletions test/builders/build/eth-api/dev-env/waffle/test/MyToken.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { use, expect } from 'chai';
import { Provider } from '@ethersproject/providers';
import { solidity } from 'ethereum-waffle';
import { ethers, Wallet } from 'ethers';
import { MyToken, MyToken__factory } from '../build/types';
import dotenv from 'dotenv'

dotenv.config({ path:'../../../../../../.env'});

use(solidity);

describe('MyToken', () => {
let provider: Provider = new ethers.providers.JsonRpcProvider(process.env.HTTP_RPC_ENDPOINT);
let wallet: Wallet;
let walletTo: Wallet;
let token: MyToken;

beforeEach(async () => {
const privateKey = '0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133';
wallet = new Wallet(privateKey).connect(provider);
walletTo = Wallet.createRandom().connect(provider);
token = await new MyToken__factory(wallet).deploy();
let contractTransaction = await token.initialize(10);
await contractTransaction.wait();
});

it('Mints the correct initial balance', async () => {
expect(await token.balanceOf(wallet.address)).to.equal(10);
});

it('Should transfer the correct amount of tokens to the destination account', async () => {
await (await token.transfer(walletTo.address, 7)).wait();
expect(await token.balanceOf(walletTo.address)).to.equal(7);
});
});
14 changes: 14 additions & 0 deletions test/builders/build/eth-api/dev-env/waffle/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"strict": true,
"target": "ES2019",
"moduleResolution": "node",
"resolveJsonModule": true,
"esModuleInterop": true,
"module": "CommonJS",
"composite": true,
"sourceMap": true,
"declaration": true,
"noEmit": true,
},
}
13 changes: 13 additions & 0 deletions test/builders/build/eth-api/dev-env/waffle/waffle.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"compilerType": "solcjs",
"compilerVersion": "0.8.20",
"compilerOptions": {
"optimizer": {
"enabled": true,
"runs": 20000
}
},
"sourceDirectory": "./contracts",
"outputDirectory": "./build",
"typechainEnabled": true
}