Skip to content

Commit dcb12fe

Browse files
authored
Merge pull request #217 from MoMannn/master
Breaking dangerous superuser burn into mock and test mocks.
2 parents e3d101d + 6dfc7e8 commit dcb12fe

File tree

4 files changed

+28
-28
lines changed

4 files changed

+28
-28
lines changed

README.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ All contracts and tests are in the [src](src/) folder. There are multiple implem
1818

1919
Other files in the [tokens](src/contracts/tokens) and [utils](src/contracts/utils) directories named like `erc*.sol` are interfaces and define the respective standards.
2020

21+
Mock contract showing basic contract usage are available in [mocks](src/contracts/mocks) folder.
22+
23+
There are also test mocks which can be seen [here](src/tests/mocks). These are specifically made to test different edge cases and behaviours and should NOT be used as a reference for implementation.
24+
2125
## Requirements
2226

2327
* NodeJS 9.0+ is supported
@@ -114,19 +118,6 @@ contract MyArtSale is
114118
super._setTokenUri(_tokenId, _uri);
115119
}
116120
117-
/**
118-
* @dev Removes a NFT from owner.
119-
* @param _tokenId Which NFT we want to remove.
120-
*/
121-
function burn(
122-
uint256 _tokenId
123-
)
124-
external
125-
onlyOwner
126-
{
127-
super._burn(_tokenId);
128-
}
129-
130121
}
131122
```
132123

src/contracts/mocks/nf-token-mock.sol

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,4 @@ contract NFTokenMock is
2626
super._mint(_to, _tokenId);
2727
}
2828

29-
/**
30-
* @dev Removes a NFT from owner.
31-
* @param _tokenId Which NFT we want to remove.
32-
*/
33-
function burn(
34-
uint256 _tokenId
35-
)
36-
external
37-
onlyOwner
38-
{
39-
super._burn(_tokenId);
40-
}
41-
4229
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
pragma solidity 0.5.2;
2+
3+
import "../../contracts/mocks/nf-token-mock.sol";
4+
5+
contract NFTokenTestMock is
6+
NFTokenMock
7+
{
8+
9+
/**
10+
* @dev Removes a NFT from owner.
11+
* @param _tokenId Which NFT we want to remove.
12+
*/
13+
function burn(
14+
uint256 _tokenId
15+
)
16+
external
17+
onlyOwner
18+
{
19+
super._burn(_tokenId);
20+
}
21+
22+
}

src/tests/tokens/nf-token.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ spec.beforeEach(async (ctx) => {
3939

4040
spec.beforeEach(async (ctx) => {
4141
const nfToken = await ctx.deploy({
42-
src: './build/nf-token-mock.json',
43-
contract: 'NFTokenMock',
42+
src: './build/nf-token-test-mock.json',
43+
contract: 'NFTokenTestMock',
4444
});
4545
ctx.set('nfToken', nfToken);
4646
});

0 commit comments

Comments
 (0)