forked from layerx-labs/dappkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherc1155-standard.spec.ts
More file actions
64 lines (55 loc) · 2.1 KB
/
erc1155-standard.spec.ts
File metadata and controls
64 lines (55 loc) · 2.1 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
import { defaultWeb3Connection, getPrivateKeyFromFile } from '../utils';
import { ERC1155Standard, Web3Connection } from '../../src';
import { expect } from 'chai';
import { Account } from 'web3-core';
describe(`ERC1155 Standard`, () => {
let contract: ERC1155Standard;
let web3Connection: Web3Connection;
let contractAddress: string;
let alice: Account;
const initial = {
uri: 'https://my.token.uri',
};
before(async () => {
web3Connection = await defaultWeb3Connection(true, true);
alice = web3Connection.Web3.eth.accounts.privateKeyToAccount(
getPrivateKeyFromFile(0)
);
});
it(`Deploys the contract`, async () => {
const deployer = new ERC1155Standard(web3Connection);
deployer.loadAbi();
const tx = await deployer.deployJsonAbi('https://my.token.uri');
expect(tx.blockNumber).to.exist;
contractAddress = tx.contractAddress!;
});
describe(`Methods`, () => {
before(async () => {
contract = new ERC1155Standard(web3Connection, contractAddress!);
await contract.loadContract();
});
it(`Set a new URI for all tokens`, async () => {
const uriBeforeSetting = await contract.uri(0);
await contract.setURI('https://domain.tld/');
const uriAfterSetting = await contract.uri(0);
expect(uriBeforeSetting).to.have.string(initial.uri);
expect(uriAfterSetting).to.have.string('https://domain.tld/');
});
it(`mints the token id`, async () => {
await contract.mint(alice.address, 0, 100, '0x12345678');
expect(await contract.balanceOf(alice.address, 0)).to.be.eq(100);
});
it(`mints a bunch of token ids`, async () => {
const tokenIds = [123, 212, 344];
const amounts = [100, 200, 300];
await contract.mintBatch(alice.address, tokenIds, amounts, '0x12345678');
const expectedAmounts = await contract.balanceOfBatch(
[alice.address, alice.address, alice.address],
tokenIds
);
expect(expectedAmounts[0]).to.be.eq(amounts[0]);
expect(expectedAmounts[1]).to.be.eq(amounts[1]);
expect(expectedAmounts[2]).to.be.eq(amounts[2]);
});
});
});