1616import org .testng .annotations .BeforeSuite ;
1717import org .testng .annotations .Test ;
1818import org .tron .api .GrpcAPI ;
19+ import org .tron .api .GrpcAPI .EmptyMessage ;
1920import org .tron .api .WalletGrpc ;
21+ import org .tron .api .WalletSolidityGrpc ;
2022import org .tron .common .crypto .ECKey ;
2123import org .tron .common .parameter .CommonParameter ;
2224import org .tron .common .utils .ByteArray ;
@@ -58,13 +60,22 @@ public class TransactionFee001 {
5860
5961 private ManagedChannel channelFull = null ;
6062 private WalletGrpc .WalletBlockingStub blockingStubFull = null ;
63+ private WalletSolidityGrpc .WalletSolidityBlockingStub blockingStubSolidity = null ;
64+ private ManagedChannel channelSolidity = null ;
65+ private WalletSolidityGrpc .WalletSolidityBlockingStub blockingStubPbft = null ;
66+ private ManagedChannel channelPbft = null ;
67+
6168
6269 ECKey ecKey1 = new ECKey (Utils .getRandom ());
6370 byte [] deployAddress = ecKey1 .getAddress ();
6471 final String deployKey = ByteArray .toHexString (ecKey1 .getPrivKeyBytes ());
6572
6673 private String fullnode = Configuration .getByPath ("testng.conf" )
6774 .getStringList ("fullnode.ip.list" ).get (0 );
75+ private String soliditynode = Configuration .getByPath ("testng.conf" )
76+ .getStringList ("solidityNode.ip.list" ).get (0 );
77+ private String soliInPbft = Configuration .getByPath ("testng.conf" )
78+ .getStringList ("solidityNode.ip.list" ).get (2 );
6879
6980 Long startNum = 0L ;
7081 Long endNum = 0L ;
@@ -76,7 +87,8 @@ public class TransactionFee001 {
7687 Long blackHoleBalance2 = 0L ;
7788 Long witness01Increase = 0L ;
7889 Long witness02Increase = 0L ;
79- //Long blackHoleIncrease = 0L;
90+ Long beforeBurnTrxAmount = 0L ;
91+ Long afterBurnTrxAmount = 0L ;
8092 String txid = null ;
8193
8294
@@ -96,15 +108,22 @@ public void beforeClass() {
96108 .usePlaintext (true )
97109 .build ();
98110 blockingStubFull = WalletGrpc .newBlockingStub (channelFull );
111+
112+ channelSolidity = ManagedChannelBuilder .forTarget (soliditynode )
113+ .usePlaintext (true )
114+ .build ();
115+ blockingStubSolidity = WalletSolidityGrpc .newBlockingStub (channelSolidity );
116+ channelPbft = ManagedChannelBuilder .forTarget (soliInPbft )
117+ .usePlaintext (true )
118+ .build ();
119+ blockingStubPbft = WalletSolidityGrpc .newBlockingStub (channelPbft );
99120 }
100121
101122 @ Test (enabled = true , description = "Test deploy contract with energy fee to sr" )
102123 public void test01DeployContractEnergyFeeToSr () {
103-
104124 Assert .assertTrue (PublicMethed .sendcoin (deployAddress , 20000000000L , fromAddress ,
105125 testKey002 , blockingStubFull ));
106- PublicMethed .waitProduceNextBlock (blockingStubFull );
107- PublicMethed .waitProduceNextBlock (blockingStubFull );
126+ PublicMethed .waitSolidityNodeSynFullNodeData (blockingStubFull ,blockingStubSolidity );
108127 String filePath = "src/test/resources/soliditycode//contractLinkage003.sol" ;
109128 String contractName = "divideIHaveArgsReturnStorage" ;
110129 HashMap retMap = null ;
@@ -122,12 +141,13 @@ public void test01DeployContractEnergyFeeToSr() {
122141 .getAllowance ();
123142 blackHoleBalance1 = PublicMethed .queryAccount (Commons .decode58Check (blackHoleAdd ),
124143 blockingStubFull ).getBalance ();
144+ beforeBurnTrxAmount = blockingStubSolidity
145+ .getBurnTrx (EmptyMessage .newBuilder ().build ()).getNum ();
125146
126- txid = PublicMethed
127- .deployContractAndGetTransactionInfoById (contractName , abi , code , "" , maxFeeLimit ,
128- 0L , 0 , null ,
147+ txid = PublicMethed .deployContractAndGetTransactionInfoById (contractName , abi , code ,
148+ "" , maxFeeLimit , 0L , 0 , null ,
129149 deployKey , deployAddress , blockingStubFull );
130- PublicMethed .waitProduceNextBlock (blockingStubFull );
150+ PublicMethed .waitSolidityNodeSynFullNodeData (blockingStubFull , blockingStubSolidity );
131151
132152 endNum = blockingStubFull .getNowBlock (GrpcAPI .EmptyMessage .newBuilder ().build ())
133153 .getBlockHeader ().getRawData ().getNumber ();
@@ -157,12 +177,14 @@ public void test01DeployContractEnergyFeeToSr() {
157177 Optional <Protocol .TransactionInfo > infoById =
158178 PublicMethed .getTransactionInfoById (txid , blockingStubFull );
159179 Assert .assertEquals (infoById .get ().getFee (),infoById .get ().getPackingFee ());
180+ afterBurnTrxAmount = blockingStubSolidity
181+ .getBurnTrx (EmptyMessage .newBuilder ().build ()).getNum ();
182+ Assert .assertEquals (beforeBurnTrxAmount ,afterBurnTrxAmount );
160183 }
161184
162185 @ Test (enabled = true , description = "Test update account permission fee to black hole,"
163186 + "trans with multi sign and fee to sr" )
164187 public void test02UpdateAccountPermissionAndMultiSiginTrans () {
165-
166188 ECKey ecKey1 = new ECKey (Utils .getRandom ());
167189 byte [] ownerAddress = ecKey1 .getAddress ();
168190 final String ownerKey = ByteArray .toHexString (ecKey1 .getPrivKeyBytes ());
@@ -174,8 +196,7 @@ public void test02UpdateAccountPermissionAndMultiSiginTrans() {
174196
175197 Assert .assertTrue (PublicMethed .sendcoin (ownerAddress , needCoin + 1_000_000 , fromAddress ,
176198 testKey002 , blockingStubFull ));
177- PublicMethed .waitProduceNextBlock (blockingStubFull );
178- PublicMethed .waitProduceNextBlock (blockingStubFull );
199+ PublicMethed .waitSolidityNodeSynFullNodeData (blockingStubFull ,blockingStubSolidity );
179200 Long balanceBefore = PublicMethed .queryAccount (ownerAddress , blockingStubFull )
180201 .getBalance ();
181202 logger .info ("balanceBefore: " + balanceBefore );
@@ -197,6 +218,8 @@ public void test02UpdateAccountPermissionAndMultiSiginTrans() {
197218 PublicMethed .queryAccount (witnessAddress02 , blockingStubFull ).getAllowance ();
198219 blackHoleBalance1 = PublicMethed .queryAccount (Commons .decode58Check (blackHoleAdd ),
199220 blockingStubFull ).getBalance ();
221+ beforeBurnTrxAmount = blockingStubFull
222+ .getBurnTrx (EmptyMessage .newBuilder ().build ()).getNum ();
200223 String accountPermissionJson =
201224 "{\" owner_permission\" :{\" type\" :0,\" permission_name\" :\" owner1\" ,"
202225 + "\" threshold\" :1,\" keys\" :["
@@ -217,7 +240,7 @@ public void test02UpdateAccountPermissionAndMultiSiginTrans() {
217240 ownerAddress , ownerKey , blockingStubFull ,
218241 ownerPermissionKeys .toArray (new String [ownerPermissionKeys .size ()]));
219242
220- PublicMethed .waitProduceNextBlock (blockingStubFull );
243+ // PublicMethed.waitSolidityNodeSynFullNodeData (blockingStubFull,blockingStubSolidity );
221244 PublicMethed .waitProduceNextBlock (blockingStubFull );
222245 Optional <Protocol .TransactionInfo > infoById =
223246 PublicMethed .getTransactionInfoById (txid , blockingStubFull );
@@ -265,7 +288,7 @@ public void test02UpdateAccountPermissionAndMultiSiginTrans() {
265288 logger .info (PublicMethedForMutiSign .printPermission (PublicMethed .queryAccount (ownerAddress ,
266289 blockingStubFull ).getOwnerPermission ()));
267290
268- PublicMethed .waitProduceNextBlock (blockingStubFull );
291+ // PublicMethed.waitSolidityNodeSynFullNodeData (blockingStubFull,blockingStubSolidity );
269292
270293 startNum = blockingStubFull .getNowBlock (GrpcAPI .EmptyMessage .newBuilder ().build ())
271294 .getBlockHeader ().getRawData ().getNumber ();
@@ -276,6 +299,14 @@ public void test02UpdateAccountPermissionAndMultiSiginTrans() {
276299 blackHoleBalance1 = PublicMethed .queryAccount (Commons .decode58Check (blackHoleAdd ),
277300 blockingStubFull ).getBalance ();
278301
302+ afterBurnTrxAmount = blockingStubFull
303+ .getBurnTrx (EmptyMessage .newBuilder ().build ()).getNum ();
304+ Assert .assertTrue (afterBurnTrxAmount - beforeBurnTrxAmount == 100000000L );
305+
306+
307+ beforeBurnTrxAmount = blockingStubFull
308+ .getBurnTrx (EmptyMessage .newBuilder ().build ()).getNum ();
309+
279310 Protocol .Transaction transaction = PublicMethedForMutiSign
280311 .sendcoin2 (fromAddress , 1000_000 , ownerAddress , ownerKey , blockingStubFull );
281312 txid = ByteArray .toHexString (Sha256Hash
@@ -328,6 +359,9 @@ public void test02UpdateAccountPermissionAndMultiSiginTrans() {
328359 infoById = PublicMethed .getTransactionInfoById (txid , blockingStubFull );
329360 Assert .assertEquals (infoById .get ().getPackingFee (),0 );
330361 Assert .assertEquals (infoById .get ().getFee (),1000000L );
362+ afterBurnTrxAmount = blockingStubFull
363+ .getBurnTrx (EmptyMessage .newBuilder ().build ()).getNum ();
364+ Assert .assertTrue (afterBurnTrxAmount - beforeBurnTrxAmount == 1000000L );
331365 }
332366
333367 @ Test (enabled = true , description = "Test trigger result is \" OUT_OF_TIME\" "
@@ -348,8 +382,7 @@ public void test03OutOfTimeEnergyFeeToBlackHole() {
348382 contractAddress = PublicMethed .deployContract (contractName , abi , code ,
349383 "" , maxFeeLimit ,
350384 0L , 100 , null , deployKey , deployAddress , blockingStubFull );
351- PublicMethed .waitProduceNextBlock (blockingStubFull );
352- PublicMethed .waitProduceNextBlock (blockingStubFull );
385+ PublicMethed .waitSolidityNodeSynFullNodeData (blockingStubFull ,blockingStubSolidity );
353386
354387 startNum = blockingStubFull .getNowBlock (GrpcAPI .EmptyMessage .newBuilder ().build ())
355388 .getBlockHeader ().getRawData ().getNumber ();
@@ -359,11 +392,12 @@ public void test03OutOfTimeEnergyFeeToBlackHole() {
359392 PublicMethed .queryAccount (witnessAddress02 , blockingStubFull ).getAllowance ();
360393 blackHoleBalance1 = PublicMethed .queryAccount (Commons .decode58Check (blackHoleAdd ),
361394 blockingStubFull ).getBalance ();
395+ beforeBurnTrxAmount = blockingStubSolidity
396+ .getBurnTrx (EmptyMessage .newBuilder ().build ()).getNum ();
362397 txid = PublicMethed .triggerContract (contractAddress ,
363398 "testUseCpu(uint256)" , "90100" , false ,
364399 0 , maxFeeLimit , deployAddress , deployKey , blockingStubFull );
365- // PublicMethed.waitProduceNextBlock(blockingStubFull);
366- PublicMethed .waitProduceNextBlock (blockingStubFull );
400+ PublicMethed .waitSolidityNodeSynFullNodeData (blockingStubFull ,blockingStubSolidity );
367401 endNum = blockingStubFull .getNowBlock (GrpcAPI .EmptyMessage .newBuilder ().build ())
368402 .getBlockHeader ().getRawData ().getNumber ();
369403 witness01Allowance2 =
@@ -396,11 +430,13 @@ public void test03OutOfTimeEnergyFeeToBlackHole() {
396430 logger .info ("receipt:" + infoById .get ().getReceipt ());
397431 Assert .assertTrue (packingFee == 0L );
398432 Assert .assertTrue (infoById .get ().getFee () >= maxFeeLimit );
433+ afterBurnTrxAmount = blockingStubSolidity
434+ .getBurnTrx (EmptyMessage .newBuilder ().build ()).getNum ();
435+ Assert .assertTrue (afterBurnTrxAmount - beforeBurnTrxAmount == maxFeeLimit );
399436 }
400437
401438 @ Test (enabled = true , description = "Test create account with netFee to sr" )
402439 public void test04AccountCreate () {
403- PublicMethed .waitProduceNextBlock (blockingStubFull );
404440 startNum = blockingStubFull .getNowBlock (GrpcAPI .EmptyMessage .newBuilder ().build ())
405441 .getBlockHeader ().getRawData ().getNumber ();
406442 witness01Allowance1 =
@@ -409,14 +445,15 @@ public void test04AccountCreate() {
409445 PublicMethed .queryAccount (witnessAddress02 , blockingStubFull ).getAllowance ();
410446 blackHoleBalance1 = PublicMethed .queryAccount (Commons .decode58Check (blackHoleAdd ),
411447 blockingStubFull ).getBalance ();
412-
448+ beforeBurnTrxAmount = blockingStubSolidity
449+ .getBurnTrx (EmptyMessage .newBuilder ().build ()).getNum ();
413450 ECKey ecKey = new ECKey (Utils .getRandom ());
414451 byte [] lowBalAddress = ecKey .getAddress ();
415452 txid = PublicMethed .createAccountGetTxid (fromAddress , lowBalAddress ,
416453 testKey002 , blockingStubFull );
417454
418- PublicMethed . waitProduceNextBlock ( blockingStubFull );
419- PublicMethed .waitProduceNextBlock (blockingStubFull );
455+
456+ PublicMethed .waitSolidityNodeSynFullNodeData (blockingStubFull , blockingStubSolidity );
420457 endNum = blockingStubFull .getNowBlock (GrpcAPI .EmptyMessage .newBuilder ().build ())
421458 .getBlockHeader ().getRawData ().getNumber ();
422459 witness01Allowance2 =
@@ -445,6 +482,9 @@ public void test04AccountCreate() {
445482 PublicMethed .getTransactionInfoById (txid , blockingStubFull );
446483 Assert .assertTrue (infoById .get ().getPackingFee () == 0L );
447484 Assert .assertTrue (infoById .get ().getFee () == 100000L );
485+ afterBurnTrxAmount = blockingStubSolidity
486+ .getBurnTrx (EmptyMessage .newBuilder ().build ()).getNum ();
487+ Assert .assertTrue (afterBurnTrxAmount - beforeBurnTrxAmount == 100000L );
448488 }
449489
450490 @ Test (enabled = true , description = "Test trigger contract with netFee and energyFee to sr" )
@@ -470,8 +510,8 @@ public void test05NetFeeAndEnergyFee2Sr() {
470510 "testUseCpu(uint256)" , "700" , false ,
471511 0 , maxFeeLimit , deployAddress , deployKey , blockingStubFull );
472512 }
473- PublicMethed . waitProduceNextBlock ( blockingStubFull );
474- PublicMethed .waitProduceNextBlock (blockingStubFull );
513+
514+ PublicMethed .waitSolidityNodeSynFullNodeData (blockingStubFull , blockingStubSolidity );
475515
476516 startNum = blockingStubFull .getNowBlock (GrpcAPI .EmptyMessage .newBuilder ().build ())
477517 .getBlockHeader ().getRawData ().getNumber ();
@@ -481,11 +521,13 @@ public void test05NetFeeAndEnergyFee2Sr() {
481521 PublicMethed .queryAccount (witnessAddress02 , blockingStubFull ).getAllowance ();
482522 blackHoleBalance1 = PublicMethed .queryAccount (Commons .decode58Check (blackHoleAdd ),
483523 blockingStubFull ).getBalance ();
524+ beforeBurnTrxAmount = blockingStubSolidity
525+ .getBurnTrx (EmptyMessage .newBuilder ().build ()).getNum ();
484526 txid = PublicMethed .triggerContract (contractAddress ,
485527 "testUseCpu(uint256)" , "700" , false ,
486528 0 , maxFeeLimit , deployAddress , deployKey , blockingStubFull );
487529 // PublicMethed.waitProduceNextBlock(blockingStubFull);
488- PublicMethed .waitProduceNextBlock (blockingStubFull );
530+ PublicMethed .waitSolidityNodeSynFullNodeData (blockingStubFull , blockingStubSolidity );
489531 endNum = blockingStubFull .getNowBlock (GrpcAPI .EmptyMessage .newBuilder ().build ())
490532 .getBlockHeader ().getRawData ().getNumber ();
491533 witness01Allowance2 =
@@ -512,6 +554,9 @@ public void test05NetFeeAndEnergyFee2Sr() {
512554 Assert .assertTrue ((Math .abs (witnessAllowance .get (ByteArray .toHexString (witnessAddress02 ))
513555 - witness02Increase )) <= 2 );
514556 Assert .assertEquals (blackHoleBalance1 ,blackHoleBalance2 );
557+ afterBurnTrxAmount = blockingStubSolidity
558+ .getBurnTrx (EmptyMessage .newBuilder ().build ()).getNum ();
559+ Assert .assertEquals (beforeBurnTrxAmount ,afterBurnTrxAmount );
515560 }
516561
517562 /**
@@ -530,7 +575,7 @@ public void test06CreateAssetIssue() {
530575 Assert .assertTrue (PublicMethed
531576 .sendcoin (tokenAccountAddress , 1028000000L , fromAddress , testKey002 , blockingStubFull ));
532577
533- PublicMethed .waitProduceNextBlock (blockingStubFull );
578+ PublicMethed .waitSolidityNodeSynFullNodeData (blockingStubFull , blockingStubSolidity );
534579 startNum = blockingStubFull .getNowBlock (GrpcAPI .EmptyMessage .newBuilder ().build ())
535580 .getBlockHeader ().getRawData ().getNumber ();
536581 witness01Allowance1 =
@@ -539,7 +584,8 @@ public void test06CreateAssetIssue() {
539584 PublicMethed .queryAccount (witnessAddress02 , blockingStubFull ).getAllowance ();
540585 blackHoleBalance1 = PublicMethed .queryAccount (Commons .decode58Check (blackHoleAdd ),
541586 blockingStubFull ).getBalance ();
542-
587+ beforeBurnTrxAmount = blockingStubSolidity
588+ .getBurnTrx (EmptyMessage .newBuilder ().build ()).getNum ();
543589 Long start = System .currentTimeMillis () + 2000 ;
544590 Long end = System .currentTimeMillis () + 1000000000 ;
545591 long now = System .currentTimeMillis ();
@@ -551,7 +597,7 @@ public void test06CreateAssetIssue() {
551597 1 , 1 , start , end , 1 , description , url , 0L ,
552598 0L , 1L , 1L , tokenAccountKey ,
553599 blockingStubFull );
554- PublicMethed .waitProduceNextBlock (blockingStubFull );
600+ PublicMethed .waitSolidityNodeSynFullNodeData (blockingStubFull , blockingStubSolidity );
555601
556602 endNum = blockingStubFull .getNowBlock (GrpcAPI .EmptyMessage .newBuilder ().build ())
557603 .getBlockHeader ().getRawData ().getNumber ();
@@ -581,6 +627,16 @@ public void test06CreateAssetIssue() {
581627 PublicMethed .getTransactionInfoById (txid , blockingStubFull );
582628 Assert .assertTrue (infoById .get ().getPackingFee () == 0L );
583629 Assert .assertTrue (infoById .get ().getFee () == 1024000000L );
630+ afterBurnTrxAmount = blockingStubSolidity
631+ .getBurnTrx (EmptyMessage .newBuilder ().build ()).getNum ();
632+ Assert .assertTrue (afterBurnTrxAmount - beforeBurnTrxAmount == 1024000000L );
633+
634+ Assert .assertEquals (blockingStubFull
635+ .getBurnTrx (EmptyMessage .newBuilder ().build ()),blockingStubSolidity .getBurnTrx (
636+ EmptyMessage .newBuilder ().build ()));
637+ Assert .assertEquals (blockingStubFull .getBurnTrx (EmptyMessage .newBuilder ().build ()),
638+ blockingStubPbft .getBurnTrx (
639+ EmptyMessage .newBuilder ().build ()));
584640 }
585641 /**
586642 * constructor.
0 commit comments