This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
klab build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"address":"5409ed021d9299bf6814279a6a1411a7e866a631", | |
"crypto":{ | |
"cipher":"aes-128-ctr", | |
"ciphertext":"7c7bdd62b303eb3a42d5d8e935825ed5a05a47cb2cef71e346c61b1bd582f1aa", | |
"cipherparams":{ | |
"iv":"7fd6c9d9f9893f2c480735b5386b6d75" | |
}, | |
"kdf":"scrypt", | |
"kdfparams":{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
behaviour transfer of Token | |
interface transfer(address To, uint Value) | |
types | |
FromBal : uint256 | |
ToBal : uint256 | |
storage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('Assigns initial balance', async () => { | |
const {token, wallet} = await loadFixture(fixture); | |
expect(await token.balanceOf(wallet.address)).to.eq(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.eq(7); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function fixture(provider, [wallet]) { | |
const token = await deployContract(wallet, BasicTokenMock, [wallet.address, 1000]); | |
return {token, wallet}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
await expect(() => myContract.transferWei(receiverWallet.address, 2)) | |
.to.changeBalance(receiverWallet, 2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function execute(...) public returns (bytes32) { | |
uint256 startingGas = gasleft(); | |
... | |
to.call.value(...)(...); | |
... | |
uint256 gasUsed = startingGas.sub(gasleft()); | |
refund(gasUsed, gasPrice, gasToken); | |
return ...; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import chai from 'chai'; | |
import {createMockProvider, deployContract, getWallets, solidity} from 'ethereum-waffle'; | |
import BasicTokenMock from './build/BasicTokenMock'; | |
chai.use(solidity); | |
const {expect} = chai; | |
describe('Example', () => { | |
let provider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
await expect(token.transfer(address, 7)) | |
.to.emit(token, 'Transfer') | |
.withArgs(wallet.address, walletTo.address, 7); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
await expect(token.transfer(address, 1)) | |
.to.be.revertedWith('Not enough balance on sender account'); | |