Skip to content
This repository was archived by the owner on Apr 3, 2019. It is now read-only.

Commit 0673c82

Browse files
authored
Merge pull request #43 from PolymathNetwork/st-test
St test
2 parents 98194cb + 4fabd0d commit 0673c82

File tree

5 files changed

+476
-221
lines changed

5 files changed

+476
-221
lines changed

src/contract_wrappers/SecurityToken.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,14 @@ export default class SecurityToken extends ContractWrapper {
315315
}
316316

317317
/**
318-
* Add a verified address to the Security Token whitelist
319-
* @param investorAddress Investor address to whitelist
318+
* Voting to freeze the funds of the recipient address
319+
* @param shareHolderAddress shareholder of the security token
320320
* @param recipientAddress User who is getting voted agaisnt to freeze their POLY
321321
*/
322-
async voteToFreeze(investorAddress: string, recipientAddress: string) {
322+
async voteToFreeze(shareHolderAddress: string, recipientAddress: string) {
323323
await this._contract.voteToFreeze(recipientAddress, {
324-
from: investorAddress,
324+
from: shareHolderAddress,
325+
gas : 300000,
325326
});
326327
}
327328

test/Compliance_test.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// @flow
2+
13
import BigNumber from 'bignumber.js';
24
import chai from 'chai';
35
import 'mocha';
@@ -14,13 +16,15 @@ import {
1416
makeTemplateWithFinalized,
1517
makeSecurityTokenThroughRegistrar,
1618
} from './util/make_examples';
17-
import { makeWeb3Wrapper } from './util/web3';
19+
import { makeWeb3Wrapper, makeWeb3 } from './util/web3';
1820
import { fakeAddress } from './util/fake';
1921

2022
const { assert } = chai;
2123

2224
describe('Compliance wrapper', () => {
2325
const web3Wrapper = makeWeb3Wrapper();
26+
const web3 = makeWeb3();
27+
const expiryTime = new BigNumber(web3.eth.getBlock('latest').timestamp).plus(10000);
2428

2529
let accounts;
2630
let polyToken;
@@ -70,24 +74,26 @@ describe('Compliance wrapper', () => {
7074
});
7175

7276
it('createTemplate', async () => {
73-
await makeKYCProvider(customers, accounts[1]);
74-
await makeLegalDelegate(polyToken, customers, accounts[1], accounts[2]);
77+
await makeKYCProvider(customers, accounts[1], expiryTime);
78+
await makeLegalDelegate(polyToken, customers, accounts[1], accounts[2], expiryTime);
7579
const templateAddress = await makeTemplate(
7680
compliance,
7781
accounts[1],
7882
accounts[2],
83+
expiryTime,
7984
);
8085

8186
assert.isAbove(templateAddress.length, 0);
8287
});
8388

8489
it('proposeTemplate, templateReputation, getTemplateAddressByProposal, cancelTemplateProposal', async () => {
85-
await makeKYCProvider(customers, accounts[1]);
86-
await makeLegalDelegate(polyToken, customers, accounts[1], accounts[2]);
90+
await makeKYCProvider(customers, accounts[1], expiryTime);
91+
await makeLegalDelegate(polyToken, customers, accounts[1], accounts[2], expiryTime);
8792
const templateAddress = await makeTemplateWithFinalized(
8893
compliance,
8994
accounts[1],
9095
accounts[2],
96+
expiryTime,
9197
);
9298

9399
// Propose Template
@@ -109,7 +115,7 @@ describe('Compliance wrapper', () => {
109115
});
110116

111117
it('setSTO', async () => {
112-
await makeKYCProvider(customers, accounts[1]);
118+
await makeKYCProvider(customers, accounts[1], expiryTime);
113119

114120
await compliance.setSTO(
115121
accounts[0],
@@ -135,7 +141,7 @@ describe('Compliance wrapper', () => {
135141
let subscriptionID1 = null;
136142
const eventName1 = 'LogTemplateCreated';
137143
const indexedFilterValues1 = ["_creator"];
138-
144+
const expiryTime = new BigNumber(web3.eth.getBlock('latest').timestamp).plus(10000);
139145
//the callback is passed into the filter.watch function, and is operated on when a new event comes in
140146
const logTemplateCreatedArgsPromise = new Promise((resolve, reject) => {
141147
subscriptionID1 = compliance.subscribe(eventName1, indexedFilterValues1, (err, log) => {
@@ -181,12 +187,13 @@ describe('Compliance wrapper', () => {
181187
});
182188
});
183189

184-
await makeKYCProvider(customers, accounts[1]);
185-
await makeLegalDelegate(polyToken, customers, accounts[1], accounts[2]);
190+
await makeKYCProvider(customers, accounts[1], expiryTime);
191+
await makeLegalDelegate(polyToken, customers, accounts[1], accounts[2], expiryTime);
186192
const templateAddress = await makeTemplate(
187193
compliance,
188194
accounts[1],
189195
accounts[2],
196+
expiryTime,
190197
);
191198

192199

test/Customers_test.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ import chai from 'chai';
33
import 'mocha';
44

55
import { makeCustomers, makePolyToken, makeKYCProvider } from './util/make_examples';
6-
import { makeWeb3Wrapper } from './util/web3';
6+
import { makeWeb3Wrapper, makeWeb3 } from './util/web3';
77
import { fakeAddress } from './util/fake';
88

99
const { assert } = chai;
1010

1111
describe('Customers wrapper', () => {
1212
const web3Wrapper = makeWeb3Wrapper();
13-
13+
const web3 = makeWeb3();
14+
const expiryTime = new BigNumber(web3.eth.getBlock('latest').timestamp).plus(10000);
1415
let accounts;
1516
let polyToken;
1617
let customers;
@@ -40,7 +41,7 @@ describe('Customers wrapper', () => {
4041

4142
describe('getKYCProviderByAddress', () => {
4243
it('should return created provider', async () => {
43-
await makeKYCProvider(customers, accounts[1]);
44+
await makeKYCProvider(customers, accounts[1], expiryTime);
4445

4546
const provider = await customers.getKYCProviderByAddress(accounts[1]);
4647
assert.equal(provider.name, 'Provider');
@@ -51,7 +52,7 @@ describe('Customers wrapper', () => {
5152
});
5253

5354
it('should emit LogNewProvider event', async () => {
54-
await makeKYCProvider(customers, accounts[1]);
55+
await makeKYCProvider(customers, accounts[1], expiryTime);
5556
const logs = await customers.getLogs(
5657
'LogNewProvider',
5758
{},
@@ -68,7 +69,7 @@ describe('Customers wrapper', () => {
6869
});
6970

7071
it('should change verification fee', async () => {
71-
await makeKYCProvider(customers, accounts[1]);
72+
await makeKYCProvider(customers, accounts[1], expiryTime);
7273
const provider = await customers.getKYCProviderByAddress(accounts[1]);
7374
assert.equal(provider.name, 'Provider');
7475

@@ -86,7 +87,7 @@ describe('Customers wrapper', () => {
8687
const kycProvider = accounts[1];
8788
const investor = accounts[2];
8889

89-
await makeKYCProvider(customers, accounts[1]);
90+
await makeKYCProvider(customers, accounts[1], expiryTime);
9091
await polyToken.approve(investor, customers.address, new BigNumber(100));
9192
await customers.verifyCustomer(
9293
kycProvider,
@@ -113,7 +114,7 @@ describe('Customers wrapper', () => {
113114
});
114115

115116
it('getCustomer should return null for nonexistent customer', async () => {
116-
await makeKYCProvider(customers, accounts[1]);
117+
await makeKYCProvider(customers, accounts[1], expiryTime);
117118

118119
assert.equal(
119120
await customers.getCustomer(accounts[0], fakeAddress),
@@ -163,7 +164,7 @@ describe('Customers wrapper', () => {
163164
const kycProvider = accounts[1];
164165
const investor = accounts[2];
165166

166-
await makeKYCProvider(customers, accounts[1]);
167+
await makeKYCProvider(customers, accounts[1], expiryTime);
167168

168169
const logNewProvider = await logNewProviderArgsPromise;
169170
assert.equal(logNewProvider.providerAddress, kycProvider, 'kycProvider address wasnt found in event subscription');

0 commit comments

Comments
 (0)