Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/erc777 #1159 #1684

Merged
merged 68 commits into from
Apr 16, 2019
Merged
Changes from 1 commit
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
fe15d14
IERC777 from specs, constants returned, up to defaultOperators. (#1159)
utgarda Oct 7, 2018
1d26da3
IERC777 oprarator approvals (#1159)
utgarda Oct 7, 2018
ebb4fad
ERC777 oprarator approvals fixes and tests
utgarda Oct 9, 2018
73ac6af
IERC777 send and receive with ERC820 (#1159)
Oct 24, 2018
9a6ed29
ERC777 Add burn functions and fix send functions (#1159)
Oct 27, 2018
2fc7b4d
ERC777 Make expectEvent compatible with web3.js 1.0 (#1159)
Nov 3, 2018
5920482
ERC777 Add ERC820 deploy script (#1159)
Nov 3, 2018
fc63684
ERC777 Complete implementation of ERC777 (#1159)
Nov 3, 2018
be6fcd1
ERC777 Update ERC820 Registry contract to final version (#1159)
Jan 31, 2019
2db4656
ERC777 Move contracts to 'drafts' folder (#1159)
Jan 31, 2019
d9e53d9
ERC777: Update to ERC1820 registry and linter error fix (#1159)
Mar 15, 2019
e54490a
ERC777: implement recent changes of EIP777 (#1159)
Mar 15, 2019
5695639
ERC777 Fix formatting (#1159)
Mar 17, 2019
9965393
Merge branch 'master' into feature/ERC777-#1159
Mar 17, 2019
2582a2a
ERC777 Update to solc 0.5.2 (#1159)
Mar 17, 2019
7f7d296
ERC777 Fix travis CI errors (#1159)
Mar 21, 2019
990073f
ERC777 Fix linter errors again... (#1159)
Mar 21, 2019
17930e5
ERC777 Fix unit test (#1159)
Mar 21, 2019
65257d5
ERC777 Fix unit test again (#1159)
Mar 21, 2019
d98ef86
Remove extra newlines.
nventuro Mar 26, 2019
831b367
Rename ERC777Base to ERC777.
nventuro Mar 26, 2019
f1df62d
Remove 'Token' from contract names.
nventuro Mar 26, 2019
00df2b6
Replace ops for operators.
nventuro Mar 26, 2019
5a0195a
Move operator check out of _send.
nventuro Mar 26, 2019
06fd3a9
Remove ERC777Burnable.
nventuro Mar 26, 2019
b354c5e
Merge branch 'master' into feature/ERC777-#1159
nventuro Mar 26, 2019
4528200
Remove ERC1820Client, now using the interface directly.
nventuro Mar 26, 2019
9d44f7c
Minor internal refactors in contracts.
nventuro Mar 26, 2019
4d383d4
Delete extra test helpers.
nventuro Mar 26, 2019
dc91c59
Simplified tests.
nventuro Mar 27, 2019
5538764
Add basic 777 tests.
nventuro Mar 27, 2019
e9936f7
Add granularity send test.
nventuro Mar 27, 2019
5c0ee8a
Add first operator send tests.
nventuro Mar 27, 2019
824cb94
Add burn tests.
nventuro Mar 27, 2019
de529bb
Refactor send and burn tests.
nventuro Mar 27, 2019
ee159b4
Improve send burn refactor.
nventuro Mar 27, 2019
f9ada94
Greatly improve test module.
nventuro Mar 28, 2019
37ad5d5
Burn instead of send removed tokens.
nventuro Mar 28, 2019
a76a1cc
Add operator tests.
nventuro Mar 28, 2019
1823108
Improve send tests under changing operators.
nventuro Mar 28, 2019
0e78a62
Refactor and merge send and burn tests.
nventuro Mar 28, 2019
6cdaa1f
Add missing and not-implemented tests.
nventuro Apr 4, 2019
29134fe
Make _burn private.
nventuro Apr 4, 2019
d272f5b
Fix typo.
nventuro Apr 4, 2019
b39d65e
Greatly improve tokensToSend tests.
nventuro Apr 6, 2019
a6d39ce
Refactor hook tests.
nventuro Apr 6, 2019
71c8698
Fix hook tests.
nventuro Apr 9, 2019
060119f
Update openzeppelin-test-helpers and ERC1820 address.
nventuro Apr 11, 2019
01c74fb
Fix natspec indentation.
nventuro Apr 11, 2019
100a1cb
Make interface functions external.
nventuro Apr 11, 2019
b17f6c5
Remove redundant private revoke and authorize functions.
nventuro Apr 11, 2019
2945463
Improved readability of if statement.
nventuro Apr 11, 2019
029a021
Remove unnecessary asserts.
nventuro Apr 11, 2019
db2b2f5
Add non-one granularity test.
nventuro Apr 11, 2019
3518525
Fix hook call order in _mint.
nventuro Apr 11, 2019
7e91c3f
Fix _mint not reverting on failure to implement tokensReceived.
nventuro Apr 11, 2019
2cff2ce
Remove special case in operatorFn when from is 0.
nventuro Apr 11, 2019
cec8ebe
Refactor ERC777SenderMock.
nventuro Apr 11, 2019
8e2af46
Add tokensReceived tests.
nventuro Apr 11, 2019
ad40a92
switch to updated ganache-cli-coverage fork
frangio Apr 6, 2019
480407b
Merge branch 'master' into feature/ERC777-#1159
nventuro Apr 11, 2019
1f8b3d6
Fix linter errors.
nventuro Apr 11, 2019
343cc51
Merge branch 'feature/ERC777-#1159' of github.com:catageek/openzeppel…
nventuro Apr 11, 2019
1feeac3
Add mint tests.
nventuro Apr 12, 2019
1b04f88
Fix linter errors.
nventuro Apr 12, 2019
455e84a
Fix tests.
nventuro Apr 15, 2019
3dd46a0
Update test/drafts/ERC777/ERC777.test.js
frangio Apr 15, 2019
d7be2a6
Add changelog entry.
nventuro Apr 16, 2019
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
Prev Previous commit
Next Next commit
Add basic 777 tests.
nventuro committed Mar 27, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 55387641139201e3c1e6ff40c907e945fe86c6d0
16 changes: 16 additions & 0 deletions contracts/mocks/ERC777Mock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
pragma solidity ^0.5.2;

import "../drafts/ERC777/ERC777.sol";

contract ERC777Mock is ERC777 {
constructor (
address initialHolder,
uint256 initialBalance,
string memory name,
string memory symbol,
uint256 granularity,
address[] memory defaultOperators
) ERC777(name, symbol, granularity, defaultOperators) public {
_mint(msg.sender, initialHolder, initialBalance, "", "");
}
}
96 changes: 90 additions & 6 deletions test/drafts/ERC777/ERC777.test.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
const { BN, constants, shouldFail, singletons } = require('openzeppelin-test-helpers');
const { BN, constants, expectEvent, shouldFail, singletons } = require('openzeppelin-test-helpers');
const { ZERO_ADDRESS } = constants;

const ERC777 = artifacts.require('ERC777');
const ERC777 = artifacts.require('ERC777Mock');

contract.only('ERC777', function ([_, registryFunder, initialHolder, defaultOperatorA, defaultOperatorB, operator, anyone]) {
const initialSupply = new BN('10000');
const name = 'ERC777Test';
const symbol = '777T';
const data = web3.utils.sha3('OZ777TestData');

const defaultOperators = [defaultOperatorA, defaultOperatorB];

before(async function () {
this.erc1820 = await singletons.ERC1820Registry(registryFunder);
});

it('reverts with a granularity of zero', async function () {
await shouldFail.reverting(ERC777.new(name, symbol, 0, []));
await shouldFail.reverting(ERC777.new(initialHolder, initialSupply, name, symbol, 0, []));
});

context('with default operators', function () {
beforeEach(async function () {
this.token = await ERC777.new(name, symbol, 1, [defaultOperatorA, defaultOperatorB]);
this.token = await ERC777.new(initialHolder, initialSupply, name, symbol, 1, defaultOperators);
});

describe('basic information', function () {
@@ -33,15 +37,95 @@ contract.only('ERC777', function ([_, registryFunder, initialHolder, defaultOper
(await this.token.granularity()).should.be.bignumber.equal('1');
});

it('returns the default operators', async function () {
(await this.token.defaultOperators()).should.deep.equal(defaultOperators);
});

it('default operators are operators for all accounts', async function () {
for (let operator of defaultOperators) {
(await this.token.isOperatorFor(operator, anyone)).should.equal(true);
}
});

it('returns thte total supply', async function () {
(await this.token.totalSupply()).should.be.bignumber.equal(initialSupply);
});

it('is registered in the registry', async function () {
(await this.erc1820.getInterfaceImplementer(this.token.address, )).should.equal(this.token.address);
(await this.erc1820.getInterfaceImplementer(this.token.address, web3.utils.soliditySha3('ERC777Token')))
.should.equal(this.token.address);
});
});

function assertSendSuccess(from, to, amount, data) {
it(`can send an amount of ${amount}`, async function () {
const initialFromBalance = await this.token.balanceOf(from);
const initialToBalance = await this.token.balanceOf(to);

const { logs } = await this.token.send(to, amount, data, { from });
expectEvent.inLogs(logs, 'Sent', {
operator: from,
from,
to,
amount,
data,
operatorData: null,
});

const finalFromBalance = await this.token.balanceOf(from);
const finalToBalance = await this.token.balanceOf(to);

finalToBalance.sub(initialToBalance).should.be.bignumber.equal(amount);
finalFromBalance.sub(initialFromBalance).should.be.bignumber.equal(amount.neg());
});
}

describe('balanceOf', function () {
context('for an account with no tokens', function () {
it('returns zero', async function () {
(await this.token.balanceOf(anyone)).should.be.bignumber.equal('0');
});
});

context('for an account with tokens', function () {
it('returns their balance', async function () {
(await this.token.balanceOf(initialHolder)).should.be.bignumber.equal(initialSupply);
});
});
});

describe('send', function () {
context('when the sender has no tokens', async function () {
const from = anyone;

assertSendSuccess(from, initialHolder, new BN('0'), data);

it('reverts when sending a non-zero amount', async function () {
await shouldFail.reverting(this.token.send(initialHolder, new BN('1'), data, { from }));
});
});

context('when the sender has tokens', async function () {
const from = initialHolder;

assertSendSuccess(from, anyone, new BN('0'), data);
assertSendSuccess(from, anyone, new BN('1'), data);

it('reverts when sending more than the balance', async function () {
const balance = await this.token.balanceOf(from);
await shouldFail.reverting(this.token.send(anyone, balance.addn(1), data, { from }));
});

it('reverts when sending to the zero address', async function () {
await shouldFail.reverting(this.token.send(ZERO_ADDRESS, new BN('1'), data, { from }));
});
});
});
});

context('with no default operators', function () {
beforeEach(async function () {
await shouldFail.reverting(ERC777.new(name, symbol, 1, []));
await shouldFail.reverting(ERC777.new(initialHolder, initialSupply, name, symbol, 1, []));
});
});
});