This repository has been archived by the owner on Jan 18, 2023. It is now read-only.
/
core.spec.ts
92 lines (68 loc) 路 2.55 KB
/
core.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
83
84
85
86
87
88
89
90
91
92
require('module-alias/register');
import * as ABIDecoder from 'abi-decoder';
import * as chai from 'chai';
import { Address } from 'set-protocol-utils';
import ChaiSetup from '@utils/chaiSetup';
import { BigNumberSetup } from '@utils/bigNumberSetup';
import { CoreContract, SignatureValidatorContract, TransferProxyContract, VaultContract } from '@utils/contracts';
import { Blockchain } from '@utils/blockchain';
import { getWeb3 } from '@utils/web3Helper';
import { CoreWrapper } from '@utils/wrappers/coreWrapper';
BigNumberSetup.configure();
ChaiSetup.configure();
const web3 = getWeb3();
const { expect } = chai;
const blockchain = new Blockchain(web3);
const Core = artifacts.require('Core');
contract('Core', accounts => {
const [
ownerAccount,
] = accounts;
let transferProxy: TransferProxyContract;
let vault: VaultContract;
let signatureValidator: SignatureValidatorContract;
const coreWrapper = new CoreWrapper(ownerAccount, ownerAccount);
before(async () => {
ABIDecoder.addABI(Core.abi);
});
after(async () => {
ABIDecoder.removeABI(Core.abi);
});
beforeEach(async () => {
await blockchain.saveSnapshotAsync();
});
afterEach(async () => {
await blockchain.revertAsync();
});
describe('#constructor', async () => {
const subjectCaller: Address = ownerAccount;
beforeEach(async () => {
transferProxy = await coreWrapper.deployTransferProxyAsync();
vault = await coreWrapper.deployVaultAsync();
signatureValidator = await coreWrapper.deploySignatureValidatorAsync();
});
async function subject(): Promise<CoreContract> {
return await coreWrapper.deployCoreAsync(
transferProxy,
vault,
signatureValidator,
subjectCaller,
);
}
it('should contain the correct address of the transfer proxy', async () => {
const coreContract = await subject();
const proxyAddress = await coreContract.transferProxy.callAsync();
expect(proxyAddress).to.equal(transferProxy.address);
});
it('should contain the correct address of the vault', async () => {
const coreContract = await subject();
const vaultAddress = await coreContract.vault.callAsync();
expect(vaultAddress).to.equal(vault.address);
});
it('should contain the correct address of the signatureValidator', async () => {
const coreContract = await subject();
const signatureValidatorAddress = await coreContract.signatureValidator.callAsync();
expect(signatureValidatorAddress).to.equal(signatureValidator.address);
});
});
});