Skip to content

Commit

Permalink
add mintable tests for erc721 and erc1155
Browse files Browse the repository at this point in the history
  • Loading branch information
Aniket-Engg committed Oct 31, 2023
1 parent fa61850 commit a4c630b
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 3 deletions.
8 changes: 7 additions & 1 deletion libs/remix-ws-templates/src/templates/ozerc1155/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ export default async (opts) => {
// If no options is selected, opts.upgradeable will be undefined
// We do not show test file for upgradeable contract
// @ts-ignore
if (!opts || opts.upgradeable === undefined || !opts.upgradeable) filesObj['tests/MyToken_test.sol'] = (await import('raw-loader!./tests/MyToken_test.sol')).default
if (!opts || opts.upgradeable === undefined || !opts.upgradeable) {
// @ts-ignore
if (erc1155.defaults.mintable) filesObj['tests/MyToken_test.sol'] = (await import('raw-loader!./tests/MyToken_mintable_test.sol')).default
// @ts-ignore
else filesObj['tests/MyToken_test.sol'] = (await import('raw-loader!./tests/MyToken_test.sol')).default
}

return filesObj
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;
import "remix_tests.sol";
import "remix_accounts.sol";
import "../contracts/MyToken.sol";

contract MyTokenTest {

MyToken s;

function beforeAll () public {
address acc0 = TestsAccounts.getAccount(0);
// acc0 will be set as initial owner
s = new MyToken(acc0);
}

function testSetURI () public {
string memory uri = "https://testuri.io/token";
s.setURI(uri);
Assert.equal(s.uri(1), uri, "uri did not match");
}
}
1 change: 0 additions & 1 deletion libs/remix-ws-templates/src/templates/ozerc20/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export default async (opts) => {
if (erc20.defaults.mintable) filesObj['tests/MyToken_test.sol'] = (await import('raw-loader!./tests/MyToken_mintable_test.sol')).default
// @ts-ignore
else filesObj['tests/MyToken_test.sol'] = (await import('raw-loader!./tests/MyToken_test.sol')).default

}
return filesObj
}
7 changes: 6 additions & 1 deletion libs/remix-ws-templates/src/templates/ozerc721/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export default async (opts) => {
// If no options is selected, opts.upgradeable will be undefined
// We do not show test file for upgradeable contract
// @ts-ignore
if (!opts || opts.upgradeable === undefined || !opts.upgradeable) filesObj['tests/MyToken_test.sol'] = (await import('raw-loader!./tests/MyToken_test.sol')).default
if (!opts || opts.upgradeable === undefined || !opts.upgradeable) {
// @ts-ignore
if (erc721.defaults.mintable) filesObj['tests/MyToken_test.sol'] = (await import('raw-loader!./tests/MyToken_mintable_test.sol')).default
// @ts-ignore
else filesObj['tests/MyToken_test.sol'] = (await import('raw-loader!./tests/MyToken_test.sol')).default
}
return filesObj
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.7.0 <0.9.0;
import "remix_tests.sol";
import "remix_accounts.sol";
import "../contracts/MyToken.sol";

contract MyTokenTest {

MyToken s;

function beforeAll () public {
address acc0 = TestsAccounts.getAccount(0);
// acc0 will be set as initial owner
s = new MyToken(acc0);
}

function testTokenNameAndSymbol () public {
Assert.equal(s.name(), "MyToken", "token name did not match");
Assert.equal(s.symbol(), "MTK", "token symbol did not match");
}
}

0 comments on commit a4c630b

Please sign in to comment.