forked from layerx-labs/dappkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreal-fevr-marketplace.spec.ts
82 lines (66 loc) · 2.99 KB
/
real-fevr-marketplace.spec.ts
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
import {defaultWeb3Connection, erc20Deployer, hasTxBlockNumber} from '../utils/';
import {expect} from 'chai';
import {RealFevrOpener} from '@models/real-fevr-opener';
import {RealFevrMarketplace} from '@models/real-fevr-marketplace';
import {toSmartContractDecimals} from '@utils/numbers';
import {Web3Connection} from '../../src';
describe('Marketplace RealFevr', async () => {
let marketplaceContract: RealFevrMarketplace;
let tokenAddress!: string;
let openerAddress!: string;
let contractAddress!: string;
let accountAddress!: string;
const purchaseTokenCap = toSmartContractDecimals(1000000);
let web3Connection: Web3Connection;
before(async () => {
web3Connection = await defaultWeb3Connection(true, true);
accountAddress = web3Connection.Account.address;
});
describe('Contracts', () => {
it(`Deploys the token contract`, async () => {
const erc20 = await erc20Deployer(`Settler`, `$settler`, purchaseTokenCap, web3Connection);
expect(erc20.contractAddress).to.not.be.empty;
tokenAddress = erc20.contractAddress!;
});
it(`Deploys the opener contract`, async () => {
const openerDeployer = new RealFevrOpener(web3Connection);
openerDeployer.loadAbi();
const openerTx = await openerDeployer.deployJsonAbi(`Collectible`, `$stamp`, tokenAddress);
expect(openerTx.blockNumber).to.exist;
expect(openerTx.contractAddress).to.not.be.empty;
openerAddress = openerTx.contractAddress!;
});
it(`Deploys the marketplace contract`, async () => {
const marketplaceDeployer = new RealFevrMarketplace(web3Connection);
marketplaceDeployer.loadAbi();
const marketplaceTx = await marketplaceDeployer.deployJsonAbi(openerAddress, tokenAddress);
expect(marketplaceTx.blockNumber).to.exist;
expect(marketplaceTx.contractAddress).to.not.be.empty;
contractAddress = marketplaceTx.contractAddress;
});
});
describe('Methods', () => {
before(async () => {
marketplaceContract = new RealFevrMarketplace(web3Connection, contractAddress!, openerAddress, tokenAddress);
await marketplaceContract.loadContract();
});
it('should create pack of NFTs', async () => {
await hasTxBlockNumber(marketplaceContract.opener.createPack(1, 1, '', 'foo', 'bar', 1, [ '0x0000000000000000000000000000000000000000' ], [ 100 ], [], []));
});
it('should offer pack to owner', async () => {
await hasTxBlockNumber(marketplaceContract.opener.offerPack(1, accountAddress));
});
it('should open pack', async () => {
await hasTxBlockNumber(marketplaceContract.opener.openPack(1));
});
it('should mint NFT', async () => {
await hasTxBlockNumber(marketplaceContract.opener.mint(1));
});
it('should approve NFT', async () => {
await hasTxBlockNumber(marketplaceContract.opener.approve(contractAddress, 1));
});
it('should put NFT up for sale', async () => {
await hasTxBlockNumber(marketplaceContract.putERC721OnSale(1, 1000));
});
});
});