@@ -9,6 +9,9 @@ import { loopring_exported_account as acc, web3 } from './utils'
99
1010import { ExchangeAPI } from '../api/exchange_api'
1111import { sleep } from '../utils' ;
12+ import { deposit } from '../api/contract_api' ;
13+ import { JSONOutput } from 'typedoc' ;
14+ import { TokenInfo } from '../defs' ;
1215
1316// start ganache-cli before
1417// ganache-cli --debug --chainId=5 --account="0xadc22517f2de0093429e5365b042da0ec9299353943db0f0cc104743c69104cf,1000e+18" --secure --unlock "0xfF7d59D9316EBA168837E3eF924BCDFd64b237D8"
@@ -82,83 +85,77 @@ const gasLimit = 200000
8285
8386describe ( 'contract test' , function ( ) {
8487
85- beforeEach ( async ( ) => {
88+ beforeEach ( ( ) => {
8689 api = new ExchangeAPI ( { chainId : ChainId . GOERLI } )
87-
88- } )
89- afterEach ( async ( ) => {
90- await sleep ( 500 )
91-
9290 } )
9391
94- it ( 'approveZero_LRC' , async ( ) => {
95-
92+ it ( 'approveMax_LRC' , async ( ) => {
9693 const nonce = await contract . getNonce ( web3 , acc . address )
97-
98- const response = await contract . approveZero ( web3 , acc . address , lrc . address ,
94+ await sleep ( 200 )
95+ const response = await contract . approveMax ( web3 , acc . address , lrc . address ,
9996 acc . depositAddr , gasPrice , gasLimit , ChainId . GOERLI , nonce , true )
10097
101- console . log ( `nonce: ${ nonce } approveZero : ${ response } ` )
98+ console . log ( `nonce: ${ nonce } approveMax : ${ JSON . stringify ( response ) } ` )
10299 } , DEFAULT_TIMEOUT )
103100
104- it ( 'approveMax_LRC' , async ( ) => {
105-
101+ it ( 'deposit_LRC2' , async ( ) => {
106102 const nonce = await contract . getNonce ( web3 , acc . address )
103+ await sleep ( 200 )
104+ const response = await contract . deposit ( web3 , acc . address , acc . exchangeAddr ,
105+ lrc , 11 , 0 , gasPrice , gasLimit , ChainId . GOERLI , nonce , true )
107106
108- const response = await contract . approveMax ( web3 , acc . address , lrc . address ,
109- acc . depositAddr , gasPrice , gasLimit , ChainId . GOERLI , nonce , true )
110-
111- console . log ( `nonce: ${ nonce } approveMax: ${ response } ` )
107+ console . log ( `nonce: ${ nonce } deposit_LRC: ` , response )
112108 } , DEFAULT_TIMEOUT )
113109
114110 it ( 'approveMax_ETH test' , async ( ) => {
115-
116111 const nonce = await contract . getNonce ( web3 , acc . address )
117-
112+ await sleep ( 200 )
118113 const response = await contract . approveMax ( web3 , acc . address , eth . address ,
119114 acc . depositAddr , gasPrice , gasLimit , ChainId . GOERLI , nonce , true )
120115
121116 console . log ( `nonce: ${ nonce } approveMax: ${ response } ` )
122117 } , DEFAULT_TIMEOUT )
123118
124- it ( 'deposit_LRC2' , async ( ) => {
125-
126- const nonce = await contract . getNonce ( web3 , acc . address )
127-
128- const response = await contract . deposit ( web3 , acc . address , acc . exchangeAddr ,
129- lrc , 11 , 0 , gasPrice , gasLimit , ChainId . GOERLI , nonce , false )
119+
130120
131- console . log ( `nonce: ${ nonce } deposit_LRC: ` , response )
132- } , DEFAULT_TIMEOUT )
133121
134122 it ( 'deposit_LRC1' , async ( ) => {
135-
136123 const nonce = await contract . getNonce ( web3 , acc . address )
137-
124+ await sleep ( 200 )
138125 const response = await contract . deposit ( web3 , acc . address , acc . exchangeAddr ,
139126 lrc , 1 , 0 , gasPrice , gasLimit , ChainId . GOERLI , nonce , true )
140127
141128 console . log ( `nonce: ${ nonce } deposit_LRC: ` , response )
142129 } , DEFAULT_TIMEOUT )
130+
131+ //TODO: test for hardware wallet
132+ // it('deposit_ETH test', async () => {
133+ // const nonce = await contract.getNonce(web3, acc.address)
134+ // await sleep(200)
135+ // const response = await contract.deposit(web3, acc.address, acc.exchangeAddr,
136+ // eth, 0.1, 0, gasPrice, parseInt(eth.gasAmounts.deposit), ChainId.GOERLI, nonce, false)
137+ //
138+ // console.log(`nonce: ${nonce} deposit_ETH: ${response}`)
139+ // }, DEFAULT_TIMEOUT)
143140
144- it ( 'deposit_ETH test' , async ( ) => {
145-
141+ it ( 'forceWithdrawal test' , async ( ) => {
146142 const nonce = await contract . getNonce ( web3 , acc . address )
147-
148- const response = await contract . deposit ( web3 , acc . address , acc . exchangeAddr ,
149- eth , 0.1 , 0 , gasPrice , parseInt ( eth . gasAmounts . deposit ) , ChainId . GOERLI , nonce , true )
143+ await sleep ( 200 )
144+ const response = await contract . forceWithdrawal ( web3 , acc . address , acc . accountId , acc . exchangeAddr ,
145+ eth , 0 , gasPrice , gasLimit , ChainId . GOERLI , nonce , true )
150146
151147 console . log ( `nonce: ${ nonce } deposit_ETH: ${ response } ` )
152148 } , DEFAULT_TIMEOUT )
153-
154- it ( 'forceWithdrawal test ' , async ( ) => {
149+
150+ it ( 'approveZero_LRC ' , async ( ) => {
155151
156152 const nonce = await contract . getNonce ( web3 , acc . address )
153+ await sleep ( 200 )
154+ const response = await contract . approveZero ( web3 , acc . address , lrc . address ,
155+ acc . depositAddr , gasPrice , gasLimit , ChainId . GOERLI , nonce , true )
157156
158- const response = await contract . forceWithdrawal ( web3 , acc . address , acc . accountId , acc . exchangeAddr ,
159- eth , 0 , gasPrice , gasLimit , ChainId . GOERLI , nonce , true )
160-
161- console . log ( `nonce: ${ nonce } deposit_ETH: ${ response } ` )
157+ console . log ( `nonce: ${ nonce } approveZero: ${ response } ` )
162158 } , DEFAULT_TIMEOUT )
163159
160+
164161} )
0 commit comments