@@ -8,27 +8,19 @@ const TokenRulesSetup = Package.Setup.TokenRules,
88 RulesSetup = Package . Setup . Rules ,
99 MockContractsDeployer = require ( './../utils/MockContractsDeployer' ) ,
1010 config = require ( '../utils/configReader' ) ,
11- Web3WalletHelper = require ( '../utils/Web3WalletHelper' ) ,
1211 Contracts = Package . Contracts ,
1312 User = Package . Helpers . User ,
1413 TokenRules = Package . Helpers . TokenRules ,
1514 AbiBinProvider = Package . AbiBinProvider ,
16- TokenHolder = Package . Helpers . TokenHolder ;
15+ TokenHolder = Package . Helpers . TokenHolder ,
16+ { dockerSetup, dockerTeardown } = require ( './../../utils/docker' ) ;
1717
18- const auxiliaryWeb3 = new Web3 ( config . gethRpcEndPoint ) ,
19- ContractsInstance = new Contracts ( auxiliaryWeb3 ) ,
20- web3WalletHelper = new Web3WalletHelper ( auxiliaryWeb3 ) ,
21- assert = chai . assert ,
18+ const assert = chai . assert ,
2219 OrganizationHelper = Mosaic . ChainSetup . OrganizationHelper ,
2320 abiBinProvider = new AbiBinProvider ( ) ;
2421
25- let txOptions = {
26- from : config . deployerAddress ,
27- gasPrice : config . gasPrice ,
28- gas : config . gas
29- } ;
30-
31- let wallets ,
22+ let txOptions ,
23+ ContractsInstance ,
3224 userWalletFactoryAddress ,
3325 thMasterCopyAddress ,
3426 gnosisSafeMasterCopyAddress ,
@@ -37,8 +29,6 @@ let wallets,
3729 pricerRuleAddress ,
3830 worker ,
3931 organization ,
40- beneficiary ,
41- facilitator ,
4232 mockToken ,
4333 owner = config . deployerAddress ,
4434 tokenHolderSender ,
@@ -47,21 +37,29 @@ let wallets,
4737 gnosisSafeProxy ,
4838 ephemeralKey ,
4939 mockTokenDeployerInstance ,
50- tokenRulesObject ;
40+ tokenRulesObject ,
41+ deployerAddress ,
42+ auxiliaryWeb3 ;
5143
5244describe ( 'Direct transfers between TH contracts' , async function ( ) {
5345 before ( async function ( ) {
54- await web3WalletHelper . init ( auxiliaryWeb3 ) ;
55- wallets = web3WalletHelper . web3Object . eth . accounts . wallet ;
56- worker = wallets [ 1 ] . address ;
57- beneficiary = wallets [ 2 ] . address ;
58- facilitator = wallets [ 3 ] . address ;
46+ const { rpcEndpointOrigin } = await dockerSetup ( ) ;
47+ auxiliaryWeb3 = new Web3 ( rpcEndpointOrigin ) ;
48+ ContractsInstance = new Contracts ( auxiliaryWeb3 ) ;
49+ const accountsOrigin = await auxiliaryWeb3 . eth . getAccounts ( ) ;
50+ deployerAddress = accountsOrigin [ 0 ] ;
51+ worker = accountsOrigin [ 1 ] ;
52+ owner = accountsOrigin [ 2 ] ;
53+ } ) ;
54+
55+ after ( ( ) => {
56+ dockerTeardown ( ) ;
5957 } ) ;
6058
6159 it ( 'Deploys Organization contract' , async function ( ) {
6260 let orgHelper = new OrganizationHelper ( auxiliaryWeb3 , null ) ;
6361 const orgConfig = {
64- deployer : config . deployerAddress ,
62+ deployer : deployerAddress ,
6563 owner : owner ,
6664 workers : worker ,
6765 workerExpirationHeight : '20000000'
@@ -74,7 +72,7 @@ describe('Direct transfers between TH contracts', async function() {
7472 } ) ;
7573
7674 it ( 'Deploys EIP20Token contract' , async function ( ) {
77- mockTokenDeployerInstance = new MockContractsDeployer ( config . deployerAddress , auxiliaryWeb3 ) ;
75+ mockTokenDeployerInstance = new MockContractsDeployer ( deployerAddress , auxiliaryWeb3 ) ;
7876
7977 await mockTokenDeployerInstance . deployMockToken ( ) ;
8078
@@ -83,6 +81,12 @@ describe('Direct transfers between TH contracts', async function() {
8381 } ) ;
8482
8583 it ( 'Deploys TokenRules contract' , async function ( ) {
84+ txOptions = {
85+ from : deployerAddress ,
86+ gasPrice : config . gasPrice ,
87+ gas : config . gas
88+ } ;
89+
8690 const tokenRulesSetupInstance = new TokenRulesSetup ( auxiliaryWeb3 ) ;
8791
8892 const response = await tokenRulesSetupInstance . deploy ( organization , mockToken , txOptions ) ;
@@ -158,11 +162,7 @@ describe('Direct transfers between TH contracts', async function() {
158162
159163 it ( 'Registers PricerRule rule' , async function ( ) {
160164 // Only worker can registerRule.
161- const txOptions = {
162- from : worker ,
163- gasPrice : config . gasPrice ,
164- gas : config . gas
165- } ;
165+ txOptions . from = worker ;
166166
167167 tokenRulesObject = new TokenRules ( tokenRulesAddress , auxiliaryWeb3 ) ;
168168 const pricerRuleName = 'PricerRule' ,
@@ -189,6 +189,7 @@ describe('Direct transfers between TH contracts', async function() {
189189 } ) ;
190190
191191 it ( 'Creates first user wallet' , async function ( ) {
192+ txOptions . from = deployerAddress ;
192193 const userInstance = new User (
193194 gnosisSafeMasterCopyAddress ,
194195 thMasterCopyAddress ,
@@ -198,8 +199,10 @@ describe('Direct transfers between TH contracts', async function() {
198199 auxiliaryWeb3
199200 ) ;
200201
201- ephemeralKey = wallets [ 5 ] ;
202- const owners = [ wallets [ 3 ] . address ] ,
202+ await auxiliaryWeb3 . eth . accounts . wallet . create ( 1 ) ;
203+ ephemeralKey = auxiliaryWeb3 . eth . accounts . wallet [ 0 ] ;
204+
205+ const owners = [ owner ] ,
203206 threshold = 1 ,
204207 sessionKeys = [ ephemeralKey . address ] ;
205208
@@ -234,8 +237,10 @@ describe('Direct transfers between TH contracts', async function() {
234237 auxiliaryWeb3
235238 ) ;
236239
237- ephemeralKey = wallets [ 5 ] ;
238- const owners = [ wallets [ 3 ] . address ] ,
240+ await auxiliaryWeb3 . eth . accounts . wallet . create ( 1 ) ;
241+ ephemeralKey = auxiliaryWeb3 . eth . accounts . wallet [ 0 ] ;
242+
243+ const owners = [ owner ] ,
239244 threshold = 1 ,
240245 sessionKeys = [ ephemeralKey . address ] ;
241246
@@ -270,7 +275,10 @@ describe('Direct transfers between TH contracts', async function() {
270275 auxiliaryWeb3
271276 ) ;
272277
273- const sessionKeys = [ wallets [ 5 ] . address ] ;
278+ await auxiliaryWeb3 . eth . accounts . wallet . create ( 1 ) ;
279+ const sessionKey = auxiliaryWeb3 . eth . accounts . wallet [ 0 ] . address ;
280+
281+ const sessionKeys = [ sessionKey ] ;
274282
275283 const response = await userInstance . createCompanyWallet (
276284 proxyFactoryAddress ,
0 commit comments