@@ -48,6 +48,11 @@ public class FreezeContractTest001 {
4848 ECKey ecKey2 = new ECKey (Utils .getRandom ());
4949 byte [] testAddress002 = ecKey2 .getAddress ();
5050 String testKey002 = ByteArray .toHexString (ecKey2 .getPrivKeyBytes ());
51+
52+ ECKey ecKey3 = new ECKey (Utils .getRandom ());
53+ byte [] testAddress003 = ecKey3 .getAddress ();
54+ String testKey003 = ByteArray .toHexString (ecKey3 .getPrivKeyBytes ());
55+
5156 private long freezeEnergyUseage ;
5257 private byte [] create2Address ;
5358 private final long freezeCount = 1000_123456L ;
@@ -59,6 +64,8 @@ public void beforeSuite() {
5964 Wallet .setAddressPreFixByte (Parameter .CommonConstant .ADD_PRE_FIX_BYTE_MAINNET );
6065 PublicMethed .printAddress (testKey001 );
6166 PublicMethed .printAddress (testKey002 );
67+
68+ PublicMethed .printAddress (testFoundationKey );
6269 }
6370
6471 /**
@@ -74,6 +81,8 @@ public void beforeClass() {
7481 testFoundationAddress ,testFoundationKey ,blockingStubFull ));
7582 Assert .assertTrue (PublicMethed .sendcoin (testAddress002 ,10_000000L ,
7683 testFoundationAddress ,testFoundationKey ,blockingStubFull ));
84+ Assert .assertTrue (PublicMethed .sendcoin (testAddress003 ,12000_000000L ,
85+ testFoundationAddress ,testFoundationKey ,blockingStubFull ));
7786
7887 String filePath = "src/test/resources/soliditycode/freezeContract001.sol" ;
7988 String contractName = "TestFreeze" ;
@@ -89,7 +98,7 @@ public void beforeClass() {
8998 }
9099
91100
92- @ Test (enabled = true , description = "contract freeze to account" )
101+ @ Test (description = "contract freeze to account" )
93102 void FreezeContractTest001 () {
94103
95104 AccountResourceMessage account002_before = PublicMethed
@@ -123,7 +132,7 @@ void FreezeContractTest001() {
123132
124133 }
125134
126- @ Test (enabled = true , description = "contract freeze to self" )
135+ @ Test (description = "contract freeze to self" )
127136 void FreezeContractTest002 () {
128137 AccountResourceMessage contractResource_before = PublicMethed
129138 .getAccountResource (contractAddress ,blockingStubFull );
@@ -151,7 +160,7 @@ void FreezeContractTest002() {
151160
152161 }
153162
154- @ Test (enabled = true , description = "contract freeze to other contract" )
163+ @ Test (description = "contract freeze to other contract" )
155164 void FreezeContractTest003 () {
156165 String filePath = "src/test/resources/soliditycode/freezeContract001.sol" ;
157166 String contractName = "TestFreeze" ;
@@ -192,7 +201,7 @@ void FreezeContractTest003() {
192201
193202 }
194203
195- @ Test (enabled = true , description = "contract freeze to unactive account" ,
204+ @ Test (description = "contract freeze to unactive account" ,
196205 dependsOnMethods = "FreezeContractTest001" )
197206 void FreezeContractTest004 () {
198207
@@ -237,7 +246,7 @@ void FreezeContractTest004() {
237246
238247 }
239248
240- @ Test (enabled = true , description = "contract freeze to pre create2 address, and UnFreeze" ,
249+ @ Test (description = "contract freeze to pre create2 address, and UnFreeze" ,
241250 dependsOnMethods = "FreezeContractTest001" )
242251 void FreezeContractTest005 () {
243252 String create2ArgsStr = "1" ;
@@ -313,7 +322,7 @@ void FreezeContractTest005() {
313322
314323 }
315324
316- @ Test (enabled = true , description = "Unfreeze when freeze to account" ,
325+ @ Test (description = "Unfreeze when freeze to account" ,
317326 dependsOnMethods = "FreezeContractTest001" )
318327 void UnFreezeContractTest001 () {
319328
@@ -352,7 +361,7 @@ void UnFreezeContractTest001() {
352361
353362 }
354363
355- @ Test (enabled = true , description = "Unfreeze when freeze to contract self" ,
364+ @ Test (description = "Unfreeze when freeze to contract self" ,
356365 dependsOnMethods = "FreezeContractTest002" )
357366 void UnFreezeContractTest002 () {
358367
@@ -387,7 +396,7 @@ void UnFreezeContractTest002() {
387396
388397 }
389398
390- @ Test (enabled = true , description = "energy caulate after transaction end" )
399+ @ Test (description = "energy caulate after transaction end" )
391400 public void freezeEnergyCaulate () {
392401
393402 String methedStr = "freeze(address,uint256,uint256)" ;
@@ -423,4 +432,75 @@ public void freezeEnergyCaulate() {
423432 Assert .assertTrue (testAccount001 .getEnergyUsed () > 0 );
424433 }
425434
435+ @ Test (description = "get Zero Address ExpirTime,used to be that freeze to contract self" ,
436+ dependsOnMethods = "FreezeContractTest002" )
437+ public void getZeroExpireTimeTest () {
438+ String ExpireTimeMethedStr = "getExpireTime(address,uint256)" ;
439+ String ExpireTimeArgsStr = "\" T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb\" " + ",0" ;
440+ TransactionExtention extention = PublicMethed
441+ .triggerConstantContractForExtention (contractAddress ,ExpireTimeMethedStr ,ExpireTimeArgsStr ,
442+ false ,0 ,maxFeeLimit ,"#" ,0 , testAddress001 ,testKey001 ,blockingStubFull );
443+ Long ExpireTime1 = ByteArray .toLong (extention .getConstantResult (0 ).toByteArray ());
444+ logger .info ("ExpireTime1: " + ExpireTime1 );
445+ Assert .assertEquals (0 ,ExpireTime1 .longValue ());
446+
447+ ExpireTimeArgsStr = "\" T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb\" " + ",1" ;
448+ extention = PublicMethed
449+ .triggerConstantContractForExtention (contractAddress ,ExpireTimeMethedStr ,ExpireTimeArgsStr ,
450+ false ,0 ,maxFeeLimit ,"#" ,0 , testAddress001 ,testKey001 ,blockingStubFull );
451+ Long ExpireTime2 = ByteArray .toLong (extention .getConstantResult (0 ).toByteArray ());
452+ logger .info ("ExpireTime2: " + ExpireTime2 );
453+ Assert .assertEquals (0 ,ExpireTime2 .longValue ());
454+
455+ // freeze(address payable receiver, uint amount, uint res)
456+ String methedStr = "freeze(address,uint256,uint256)" ;
457+ String argsStr = "\" " + "T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb" + "\" ," + freezeCount + "," + "1" ;
458+ String txid = PublicMethed .triggerContract (contractAddress ,methedStr ,argsStr ,
459+ false ,0 ,maxFeeLimit ,testAddress001 ,testKey001 ,blockingStubFull );
460+ PublicMethed .waitProduceNextBlock (blockingStubFull );
461+
462+ TransactionInfo info = PublicMethed .getTransactionInfoById (txid , blockingStubFull ).get ();
463+ Assert .assertEquals (code .SUCESS ,info .getResult ());
464+ Assert .assertEquals (contractResult .SUCCESS ,info .getReceipt ().getResult ());
465+
466+ extention = PublicMethed
467+ .triggerConstantContractForExtention (contractAddress ,ExpireTimeMethedStr ,ExpireTimeArgsStr ,
468+ false ,0 ,maxFeeLimit ,"#" ,0 , testAddress001 ,testKey001 ,blockingStubFull );
469+ Long ExpireTime = ByteArray .toLong (extention .getConstantResult (0 ).toByteArray ());
470+ logger .info ("ExpireTime: " + ExpireTime );
471+ Assert .assertEquals ((ExpireTime + 3 ) * 1000 , info .getBlockTimeStamp ());
472+
473+
474+ }
475+
476+ @ Test (description = "freeze in constructor" )
477+ public void FreezeContractTest006 () {
478+
479+ AccountResourceMessage account003_before = PublicMethed
480+ .getAccountResource (testAddress003 ,blockingStubFull );
481+
482+ String filePath = "src/test/resources/soliditycode/freezeContract001.sol" ;
483+ String contractName = "D" ;
484+ HashMap retMap = PublicMethed .getBycodeAbi (filePath , contractName );
485+ String code = retMap .get ("byteCode" ).toString ();
486+ String abi = retMap .get ("abI" ).toString ();
487+ long callValue = 10000_000000L ;
488+ byte [] contractAddress = PublicMethed
489+ .deployContract (contractName , abi , code , "" , maxFeeLimit , callValue ,
490+ 100 , null , testKey003 ,
491+ testAddress003 , blockingStubFull );
492+ PublicMethed .waitProduceNextBlock (blockingStubFull );
493+
494+ AccountResourceMessage account003_after = PublicMethed
495+ .getAccountResource (testAddress003 ,blockingStubFull );
496+ Account contractAccount_after = PublicMethed .queryAccount (contractAddress , blockingStubFull );
497+
498+ logger .info ("account002_before.getEnergyLimit : " + account003_before .getEnergyLimit ());
499+ logger .info ("account002_after.getEnergyLimit : " + account003_after .getEnergyLimit ());
500+ Assert .assertTrue (account003_before .getEnergyLimit () < account003_after .getEnergyLimit ());
501+ Assert .assertEquals (callValue ,
502+ contractAccount_after .getAccountResource ().getDelegatedFrozenBalanceForEnergy ());
503+ Assert .assertEquals (0 , contractAccount_after .getBalance ());
504+ }
505+
426506}
0 commit comments