11import latestTime from "./helpers/latestTime" ;
22import { duration , promisifyLogWatch , latestBlock } from "./helpers/utils" ;
33import takeSnapshot , { increaseTime , revertToSnapshot } from "./helpers/time" ;
4- import { getSignTMSig } from "./helpers/signData" ;
4+ import { getSignTMData } from "./helpers/signData" ;
55import { pk } from "./helpers/testprivateKey" ;
66import { encodeProxyCall , encodeModuleCall } from "./helpers/encodeCall" ;
77import { catchRevert } from "./helpers/exceptions" ;
@@ -224,26 +224,33 @@ contract("SignedTransferManager", accounts => {
224224
225225 await I_SignedTransferManager . updateSigners ( [ signer . address ] , [ true ] , { from : token_owner } ) ;
226226
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 (
228230 I_SignedTransferManager . address ,
231+ nonce ,
232+ expiry ,
229233 account_investor1 ,
230234 account_investor2 ,
231235 oneeth ,
232236 signer . privateKey
233237 ) ;
234238
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 ) ;
238242 } ) ;
239243
240244 it ( "should allow transfer with valid sig" , async ( ) => {
241245 let signer = web3 . eth . accounts . create ( ) ;
242246 await I_SignedTransferManager . updateSigners ( [ signer . address ] , [ true ] , { from : token_owner } ) ;
243247 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 (
246251 I_SignedTransferManager . address ,
252+ nonce ,
253+ expiry ,
247254 account_investor1 ,
248255 account_investor2 ,
249256 oneeth ,
@@ -253,28 +260,35 @@ contract("SignedTransferManager", accounts => {
253260 let balance11 = await I_SecurityToken . balanceOf ( account_investor1 ) ;
254261 let balance21 = await I_SecurityToken . balanceOf ( account_investor2 ) ;
255262
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 } ) ) ;
257269
258- assert . equal ( await I_SignedTransferManager . checkSignatureIsInvalid ( sig ) , true ) ;
259270 assert . equal ( balance11 . sub ( oneeth ) . toString ( ) , ( await I_SecurityToken . balanceOf ( account_investor1 ) ) . toString ( ) ) ;
260271 assert . equal ( balance21 . add ( oneeth ) . toString ( ) , ( await I_SecurityToken . balanceOf ( account_investor2 ) ) . toString ( ) ) ;
261272
262- await catchRevert ( I_SecurityToken . transferWithData ( account_investor2 , oneeth , sig , { from : account_investor1 } ) ) ;
273+
263274 } ) ;
264275
265276 it ( "should not allow transfer if the signer is not on the signer list" , async ( ) => {
266277 let signer = web3 . eth . accounts . create ( ) ;
267278 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 (
270282 I_SignedTransferManager . address ,
283+ nonce ,
284+ expiry ,
271285 account_investor1 ,
272286 account_investor2 ,
273287 oneeth ,
274288 signer . privateKey
275289 ) ;
276290
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 } ) ) ;
278292 } ) ;
279293 } ) ;
280294} ) ;
0 commit comments