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

more contract tests #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion packages/contracts/contracts/Entropy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ contract EntropyNFT is ERC721, Ownable {
);
result = operateOr(result, tokenIds[i]);
}
_mint(msg.sender, result);
_safeMint(msg.sender, result);
}

function tokenURI(uint256 tokenId)
Expand Down
35 changes: 33 additions & 2 deletions packages/contracts/test/entropy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,38 @@ contract('Entropy', (accounts) => {
assert.equal("http://localhost:3000/token/0x0000000000000400.json", tokenUri);
})

it('can convert token ids to hex', async function () {
assert.equal(1 == 2)
it('can mint new tokens ids', async function () {
const receipt = await entropy.mintWithTokens(["2251799813685248", "72057594037927936"]);
const logs = receipt.logs[0];
assert.equal(logs.event, "Transfer");
const newTokenId = logs.args.tokenId;
assert.equal("74309393851613184", newTokenId.toString());

const tokenUri = await entropy.tokenURI("74309393851613184");
assert.equal(tokenUri, "http://localhost:3000/token/0x0108000000000000.json")
})

it('can mint many tokens', async function () {
const tokenIdx = [10, 20, 30, 40, 50, 60, 42, 17, 32, 8];
const _ids = tokenIdx.map(async (idx) => {
const tokenId = await entropy.tokenByIndex(idx)
return tokenId.toString()
})

const ids = await Promise.all(_ids);

const firstResult = await entropy.mintWithTokens(ids.slice(0, 5));
const secondResult = await entropy.mintWithTokens(ids.slice(5));

const firstNewToken = firstResult.logs[0].args.tokenId.toString();
const secondNewToken = secondResult.logs[0].args.tokenId.toString();

const combinedRes = await entropy.mintWithTokens([firstNewToken, secondNewToken]);
const combinedId = combinedRes.logs[0].args.tokenId.toString();
const combinedUri = await entropy.tokenURI(combinedId);
assert.equal(combinedId, "2308105813808514304")
assert.equal(combinedUri, "http://localhost:3000/token/0x20080a0240120500.json");

})

});