forked from layerx-labs/dappkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherc721-colectibles.spec.ts
More file actions
86 lines (68 loc) · 3 KB
/
erc721-colectibles.spec.ts
File metadata and controls
86 lines (68 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import {defaultWeb3Connection, erc20Deployer, hasTxBlockNumber} from '../utils/';
import {ERC721Collectibles, Web3Connection} from '../../src';
import {toSmartContractDecimals} from '../../src/utils/numbers';
import {expect} from 'chai';
describe(`ERC271Collectibles`, () => {
let contract: ERC721Collectibles;
let purchaseTokenAddress!: string;
let contractAddress!: string;
let accountAddress!: string;
const purchaseTokenCap = toSmartContractDecimals(1000000);
const collectableCap = 10
let web3Connection: Web3Connection;
before(async () => {
web3Connection = await defaultWeb3Connection(true, true);
accountAddress = web3Connection.Account.address;
});
it(`Deploys the contract`, async () => {
const erc20 = await erc20Deployer(`Settler`, `$settler`, purchaseTokenCap, web3Connection)
const deployer = new ERC721Collectibles(web3Connection);
deployer.loadAbi();
const tx = await deployer
.deployJsonAbi(
`Collectible`, `$stamp`,
collectableCap, erc20.contractAddress!,
accountAddress, accountAddress, accountAddress);
expect(tx.blockNumber).to.exist;
contractAddress = tx.contractAddress!;
purchaseTokenAddress = erc20.contractAddress!;
});
describe(`Methods`, () => {
before(async () => {
contract = new ERC721Collectibles(web3Connection, contractAddress!, purchaseTokenAddress);
await contract.loadContract();
});
it(`Asserts that created is limited`, async () => {
expect(await contract.isLimited()).to.be.true;
});
it(`Adds a base tokenURI`, async () => {
await hasTxBlockNumber(contract.setBaseURI('https://domain.tld/'));
expect(await contract.baseURI()).to.have.string('https://domain.tld/')
});
it(`Sets pack price`, async () => {
await hasTxBlockNumber(contract.setPricePerPack(2));
});
it(`Opens a pack`, async () => {
await hasTxBlockNumber(contract.approveERC20Transfer());
await hasTxBlockNumber(contract.openPack(1));
expect(await contract.openedPacks()).to.eql(1)
expect(await contract._currentTokenId()).to.eq(1001) // base is 1000, +1 open pack = 1001
});
it(`Queries tokens held by user`, async () => {
const held = await contract.getRegisteredIDs(accountAddress);
expect(held.length).to.eq(1);
expect(held[0]).to.eq(1000) // base is 1000, we opened 1, thus we opened the first and is the 1000
});
it(`Match ownership of held token`, async () => {
expect(await contract.registeredIDs(accountAddress, 1000)).to.be.true; // we just asserted that base is 1000 and we have it (we bailed otherwise)
expect(await contract.exists(1000)).to.be.false; // we own it, but haven't minted
});
it(`mints the token id`, async () => {
await hasTxBlockNumber(contract.mint(1000));
expect(await contract.exists(1000)).to.be.true;
});
it(`Asserts tokenURI url for tokenId`, async () => {
expect(await contract.tokenURI(1000)).to.have.string(`domain.tld/1000`);
});
});
});