@@ -570,4 +570,39 @@ public void secondTokenBalanceNotEnough() {
570570 Assert .assertFalse (e instanceof ContractExeException );
571571 }
572572 }
573+
574+ /*
575+ * not trx,ont token is ok, but the second one is not exist.
576+ */
577+ @ Test
578+ public void secondTokenNotExist () {
579+ String firstTokenId = "abc" ;
580+ long firstTokenBalance = 100_000_000_000000L ;
581+ String secondTokenId = "def" ;
582+ long secondTokenBalance = 100_000_000L ;
583+
584+ byte [] ownerAddress = ByteArray .fromHexString (OWNER_ADDRESS_FIRST );
585+ AccountCapsule accountCapsule = dbManager .getAccountStore ().get (ownerAddress );
586+ accountCapsule .addAssetAmount (firstTokenId .getBytes (), firstTokenBalance );
587+ accountCapsule .setBalance (10000_000000L );
588+ dbManager .getAccountStore ().put (ownerAddress , accountCapsule );
589+
590+ ExchangeCreateActuator actuator = new ExchangeCreateActuator (getContract (
591+ OWNER_ADDRESS_FIRST , firstTokenId , firstTokenBalance , secondTokenId , secondTokenBalance ),
592+ dbManager );
593+ TransactionResultCapsule ret = new TransactionResultCapsule ();
594+ Assert .assertEquals (dbManager .getDynamicPropertiesStore ().getLatestExchangeNum (), 0 );
595+ try {
596+ actuator .validate ();
597+ actuator .execute (ret );
598+ fail ();
599+ } catch (ContractValidateException e ) {
600+ Assert .assertTrue (e instanceof ContractValidateException );
601+ Assert .assertEquals ("second token balance is not enough" ,
602+ e .getMessage ());
603+ } catch (ContractExeException e ) {
604+ Assert .assertFalse (e instanceof ContractExeException );
605+ }
606+ }
607+
573608}
0 commit comments