1
1
import latestTime from "./helpers/latestTime" ;
2
2
import { duration , promisifyLogWatch , latestBlock } from "./helpers/utils" ;
3
3
import takeSnapshot , { increaseTime , revertToSnapshot } from "./helpers/time" ;
4
- import { getSignTMSig } from "./helpers/signData" ;
4
+ import { getSignTMData } from "./helpers/signData" ;
5
5
import { pk } from "./helpers/testprivateKey" ;
6
6
import { encodeProxyCall , encodeModuleCall } from "./helpers/encodeCall" ;
7
7
import { catchRevert } from "./helpers/exceptions" ;
@@ -224,26 +224,33 @@ contract("SignedTransferManager", accounts => {
224
224
225
225
await I_SignedTransferManager . updateSigners ( [ signer . address ] , [ true ] , { from : token_owner } ) ;
226
226
227
- const sig = await getSignTMSig (
227
+ let nonce = new BN ( 10 ) ;
228
+ let expiry = new BN ( currentTime . add ( new BN ( duration . days ( 100 ) ) ) ) ;
229
+ let data = await getSignTMData (
228
230
I_SignedTransferManager . address ,
231
+ nonce ,
232
+ expiry ,
229
233
account_investor1 ,
230
234
account_investor2 ,
231
235
oneeth ,
232
236
signer . privateKey
233
237
) ;
234
238
235
- assert . equal ( await I_SignedTransferManager . checkSignatureIsInvalid ( sig ) , false ) ;
236
- await I_SignedTransferManager . invalidateSignature ( account_investor1 , account_investor2 , oneeth , sig , { from : signer . address } ) ;
237
- assert . equal ( await I_SignedTransferManager . checkSignatureIsInvalid ( sig ) , true ) ;
239
+ assert . equal ( await I_SignedTransferManager . checkSignatureValidity ( data ) , true ) ;
240
+ await I_SignedTransferManager . invalidateSignature ( account_investor1 , account_investor2 , oneeth , data , { from : signer . address } ) ;
241
+ assert . equal ( await I_SignedTransferManager . checkSignatureValidity ( data ) , false ) ;
238
242
} ) ;
239
243
240
244
it ( "should allow transfer with valid sig" , async ( ) => {
241
245
let signer = web3 . eth . accounts . create ( ) ;
242
246
await I_SignedTransferManager . updateSigners ( [ signer . address ] , [ true ] , { from : token_owner } ) ;
243
247
let oneeth = new BN ( web3 . utils . toWei ( "1" , "ether" ) ) ;
244
-
245
- const sig = await getSignTMSig (
248
+ let nonce = new BN ( 10 ) ;
249
+ let expiry = new BN ( currentTime . add ( new BN ( duration . days ( 100 ) ) ) ) ;
250
+ let data = await getSignTMData (
246
251
I_SignedTransferManager . address ,
252
+ nonce ,
253
+ expiry ,
247
254
account_investor1 ,
248
255
account_investor2 ,
249
256
oneeth ,
@@ -253,28 +260,35 @@ contract("SignedTransferManager", accounts => {
253
260
let balance11 = await I_SecurityToken . balanceOf ( account_investor1 ) ;
254
261
let balance21 = await I_SecurityToken . balanceOf ( account_investor2 ) ;
255
262
256
- await I_SecurityToken . transferWithData ( account_investor2 , oneeth , sig , { from : account_investor1 } ) ;
263
+ assert . equal ( await I_SignedTransferManager . checkSignatureValidity ( data ) , true ) ;
264
+
265
+ await I_SecurityToken . transferWithData ( account_investor2 , oneeth , data , { from : account_investor1 } ) ;
266
+
267
+ assert . equal ( await I_SignedTransferManager . checkSignatureValidity ( data ) , false ) ;
268
+ await catchRevert ( I_SecurityToken . transferWithData ( account_investor2 , oneeth , data , { from : account_investor1 } ) ) ;
257
269
258
- assert . equal ( await I_SignedTransferManager . checkSignatureIsInvalid ( sig ) , true ) ;
259
270
assert . equal ( balance11 . sub ( oneeth ) . toString ( ) , ( await I_SecurityToken . balanceOf ( account_investor1 ) ) . toString ( ) ) ;
260
271
assert . equal ( balance21 . add ( oneeth ) . toString ( ) , ( await I_SecurityToken . balanceOf ( account_investor2 ) ) . toString ( ) ) ;
261
272
262
- await catchRevert ( I_SecurityToken . transferWithData ( account_investor2 , oneeth , sig , { from : account_investor1 } ) ) ;
273
+
263
274
} ) ;
264
275
265
276
it ( "should not allow transfer if the signer is not on the signer list" , async ( ) => {
266
277
let signer = web3 . eth . accounts . create ( ) ;
267
278
let oneeth = new BN ( web3 . utils . toWei ( "1" , "ether" ) ) ;
268
-
269
- const sig = await getSignTMSig (
279
+ let nonce = new BN ( 10 ) ;
280
+ let expiry = new BN ( currentTime . add ( new BN ( duration . days ( 100 ) ) ) ) ;
281
+ let data = await getSignTMData (
270
282
I_SignedTransferManager . address ,
283
+ nonce ,
284
+ expiry ,
271
285
account_investor1 ,
272
286
account_investor2 ,
273
287
oneeth ,
274
288
signer . privateKey
275
289
) ;
276
290
277
- await catchRevert ( I_SecurityToken . transferWithData ( account_investor2 , oneeth , sig , { from : account_investor1 } ) ) ;
291
+ await catchRevert ( I_SecurityToken . transferWithData ( account_investor2 , oneeth , data , { from : account_investor1 } ) ) ;
278
292
} ) ;
279
293
} ) ;
280
294
} ) ;
0 commit comments