33import com .google .protobuf .ByteString ;
44import io .grpc .ManagedChannel ;
55import io .grpc .ManagedChannelBuilder ;
6- import java .util .Map ;
76import java .util .Optional ;
87import java .util .concurrent .TimeUnit ;
98import lombok .extern .slf4j .Slf4j ;
@@ -30,7 +29,7 @@ public class ContractTrcToken023 {
3029
3130
3231 private final String testKey002 = Configuration .getByPath ("testng.conf" )
33- .getString ("foundationAccount.key2 " );
32+ .getString ("foundationAccount.key1 " );
3433 private final byte [] fromAddress = PublicMethed .getFinalAddress (testKey002 );
3534 private static final long now = System .currentTimeMillis ();
3635
@@ -47,7 +46,7 @@ public class ContractTrcToken023 {
4746 private Long maxFeeLimit = Configuration .getByPath ("testng.conf" )
4847 .getLong ("defaultParameter.maxFeeLimit" );
4948 byte [] transferTokenContractAddress ;
50- byte [] BTestAddress ;
49+ byte [] btestAddress ;
5150 private static final long TotalSupply = 10000000L ;
5251
5352 String description = Configuration .getByPath ("testng.conf" )
@@ -104,6 +103,7 @@ public void deploy01TransferTokenContract() {
104103 Assert .assertTrue (PublicMethed .freezeBalanceGetEnergy (user001Address , 2048000000 ,
105104 0 , 1 , user001Key , blockingStubFull ));
106105 PublicMethed .waitProduceNextBlock (blockingStubFull );
106+ PublicMethed .waitProduceNextBlock (blockingStubFull );
107107
108108 long start = System .currentTimeMillis () + 2000 ;
109109 long end = System .currentTimeMillis () + 1000000000 ;
@@ -136,7 +136,7 @@ public void deploy01TransferTokenContract() {
136136 .getString ("code.code_ContractTrcToken023_tokenTest" );
137137 String abi = Configuration .getByPath ("testng.conf" )
138138 .getString ("abi.abi_ContractTrcToken023_tokenTest" );
139- byte [] BTestAddress = PublicMethed
139+ btestAddress = PublicMethed
140140 .deployContract (contractName , abi , code , "" , maxFeeLimit ,
141141 0L , 0 , originEnergyLimit , "0" ,
142142 0 , null , dev001Key , dev001Address ,
@@ -147,7 +147,7 @@ public void deploy01TransferTokenContract() {
147147 .assertTrue (PublicMethed .sendcoin (transferTokenContractAddress , 1000000000L , fromAddress ,
148148 testKey002 , blockingStubFull ));
149149 Assert
150- .assertTrue (PublicMethed .sendcoin (BTestAddress , 1000000000L , fromAddress ,
150+ .assertTrue (PublicMethed .sendcoin (btestAddress , 1000000000L , fromAddress ,
151151 testKey002 , blockingStubFull ));
152152 PublicMethed .waitProduceNextBlock (blockingStubFull );
153153
@@ -171,16 +171,20 @@ public void deploy02TransferTokenContract() {
171171 Long beforeEnergyUsed = resourceInfo .getEnergyUsed ();
172172 Long beforeNetUsed = resourceInfo .getNetUsed ();
173173 Long beforeFreeNetUsed = resourceInfo .getFreeNetUsed ();
174- Long beforeAssetIssueDevAddress = getAssetIssueValue (dev001Address , assetAccountId ,
175- blockingStubFull );
176- Long beforeAssetIssueUserAddress = getAssetIssueValue (user001Address , assetAccountId ,
177- blockingStubFull );
174+ Long beforeAssetIssueDevAddress = PublicMethed
175+ .getAssetIssueValue (dev001Address , assetAccountId ,
176+ blockingStubFull );
177+ Long beforeAssetIssueUserAddress = PublicMethed
178+ .getAssetIssueValue (user001Address , assetAccountId ,
179+ blockingStubFull );
178180
179- Long beforeAssetIssueContractAddress = getAssetIssueValue (transferTokenContractAddress ,
180- assetAccountId ,
181- blockingStubFull );
182- Long beforeAssetIssueBAddress = getAssetIssueValue (BTestAddress , assetAccountId ,
183- blockingStubFull );
181+ Long beforeAssetIssueContractAddress = PublicMethed
182+ .getAssetIssueValue (transferTokenContractAddress ,
183+ assetAccountId ,
184+ blockingStubFull );
185+ Long beforeAssetIssueBAddress = PublicMethed
186+ .getAssetIssueValue (btestAddress , assetAccountId ,
187+ blockingStubFull );
184188
185189 Long beforeBalanceContractAddress = PublicMethed .queryAccount (transferTokenContractAddress ,
186190 blockingStubFull ).getBalance ();
@@ -199,11 +203,11 @@ public void deploy02TransferTokenContract() {
199203 logger .info ("beforeUserBalance:" + beforeUserBalance );
200204
201205 String param =
202- "\" " + Base58 .encode58Check (BTestAddress ) + "\" ,\" " + assetAccountId
206+ "\" " + Base58 .encode58Check (btestAddress ) + "\" ,\" " + assetAccountId
203207 .toStringUtf8 ()
204208 + "\" ,\" 1\" " ;
205209
206- String triggerTxid = PublicMethed .triggerContract (transferTokenContractAddress ,
210+ final String triggerTxid = PublicMethed .triggerContract (transferTokenContractAddress ,
207211 "TransferTokenTo(address,trcToken,uint256)" ,
208212 param , false , 0 , 1000000000L , "0" ,
209213 0 , dev001Address , dev001Key ,
@@ -215,18 +219,22 @@ public void deploy02TransferTokenContract() {
215219 blockingStubFull );
216220 Long afterBalance = infoafter .getBalance ();
217221 Long afterEnergyUsed = resourceInfoafter .getEnergyUsed ();
218- Long afterAssetIssueDevAddress = getAssetIssueValue (dev001Address , assetAccountId ,
219- blockingStubFull );
222+ Long afterAssetIssueDevAddress = PublicMethed
223+ .getAssetIssueValue (dev001Address , assetAccountId ,
224+ blockingStubFull );
220225 Long afterNetUsed = resourceInfoafter .getNetUsed ();
221226 Long afterFreeNetUsed = resourceInfoafter .getFreeNetUsed ();
222- Long afterAssetIssueContractAddress = getAssetIssueValue (transferTokenContractAddress ,
223- assetAccountId ,
224- blockingStubFull );
225- Long afterAssetIssueBAddress = getAssetIssueValue (BTestAddress , assetAccountId ,
226- blockingStubFull );
227+ Long afterAssetIssueContractAddress = PublicMethed
228+ .getAssetIssueValue (transferTokenContractAddress ,
229+ assetAccountId ,
230+ blockingStubFull );
231+ Long afterAssetIssueBAddress = PublicMethed
232+ .getAssetIssueValue (btestAddress , assetAccountId ,
233+ blockingStubFull );
227234
228- Long afterAssetIssueUserAddress = getAssetIssueValue (user001Address , assetAccountId ,
229- blockingStubFull );
235+ Long afterAssetIssueUserAddress = PublicMethed
236+ .getAssetIssueValue (user001Address , assetAccountId ,
237+ blockingStubFull );
230238 Long afterBalanceContractAddress = PublicMethed .queryAccount (transferTokenContractAddress ,
231239 blockingStubFull ).getBalance ();
232240 Long afterUserBalance = PublicMethed .queryAccount (user001Address , blockingStubFull )
@@ -263,18 +271,7 @@ public void shutdown() throws InterruptedException {
263271 }
264272 }
265273
266- public static Long getAssetIssueValue (byte [] dev001Address , ByteString assetIssueId ,
267- WalletGrpc .WalletBlockingStub blockingStubFull ) {
268- Long assetIssueCount = 0L ;
269- Account contractAccount = PublicMethed .queryAccount (dev001Address , blockingStubFull );
270- Map <String , Long > createAssetIssueMap = contractAccount .getAssetV2Map ();
271- for (Map .Entry <String , Long > entry : createAssetIssueMap .entrySet ()) {
272- if (assetIssueId .toStringUtf8 ().equals (entry .getKey ())) {
273- assetIssueCount = entry .getValue ();
274- }
275- }
276- return assetIssueCount ;
277- }
274+
278275}
279276
280277
0 commit comments