11package org .tron .common .runtime ;
22
3- import java .io .File ;
43import lombok .extern .slf4j .Slf4j ;
54import org .bouncycastle .util .encoders .Hex ;
6- import org .junit .AfterClass ;
7- import org .junit .BeforeClass ;
5+ import org .junit .Before ;
86import org .junit .Test ;
97import org .testng .Assert ;
10- import org .tron .common .application .Application ;
11- import org .tron .common .application .ApplicationFactory ;
12- import org .tron .common .application .TronApplicationContext ;
8+ import org .tron .common .BaseTest ;
139import org .tron .common .runtime .vm .DataWord ;
14- import org .tron .common .utils .FileUtil ;
1510import org .tron .core .Constant ;
1611import org .tron .core .Wallet ;
17- import org .tron .core .config .DefaultConfig ;
1812import org .tron .core .config .args .Args ;
19- import org .tron .core .db .Manager ;
2013import org .tron .core .exception .ContractExeException ;
2114import org .tron .core .exception .ContractValidateException ;
2215import org .tron .core .exception .ReceiptCheckErrException ;
2619import org .tron .protos .Protocol .AccountType ;
2720
2821@ Slf4j
29- public class InternalTransactionComplexTest {
22+ public class InternalTransactionComplexTest extends BaseTest {
3023
31- private static final String dbPath = "output_InternalTransactionComplexTest" ;
3224 private static final String OWNER_ADDRESS ;
3325 private static Runtime runtime ;
34- private static Manager dbManager ;
35- private static TronApplicationContext context ;
36- private static Application appT ;
3726 private static RepositoryImpl repository ;
3827
3928 static {
29+ dbPath = "output_InternalTransactionComplexTest" ;
4030 Args .setParam (new String []{"--output-directory" , dbPath , "--debug" , "--support-constant" },
4131 Constant .TEST_CONF );
42- context = new TronApplicationContext (DefaultConfig .class );
43- appT = ApplicationFactory .create (context );
4432 OWNER_ADDRESS = Wallet .getAddressPreFixString () + "abd4b9367799eaa3197fecb144eb71de1e049abc" ;
4533 }
4634
4735 /**
4836 * Init data.
4937 */
50- @ BeforeClass
51- public static void init () {
52- dbManager = context .getBean (Manager .class );
38+ @ Before
39+ public void init () {
5340 repository = RepositoryImpl .createRoot (StoreFactory .getInstance ());
5441 repository .createAccount (Hex .decode (OWNER_ADDRESS ), AccountType .Normal );
5542 repository .addBalance (Hex .decode (OWNER_ADDRESS ), 100000000 );
5643 }
5744
58- /**
59- * Release resources.
60- */
61- @ AfterClass
62- public static void destroy () {
63- Args .clearParam ();
64- context .destroy ();
65- if (FileUtil .deleteDir (new File (dbPath ))) {
66- logger .info ("Release resources successful." );
67- } else {
68- logger .info ("Release resources failure." );
69- }
70- }
71-
7245 /**
7346 * pragma solidity 0.4.24;
74- *
7547 * // this is to test wither the TVM is returning vars from one contract calling another //
7648 * contract's functions.
77- *
7849 * contract callerContract { // lets set up our instance of the new contract calledContract
7950 * CALLED_INSTANCE; // lets set the contract instance address in the constructor
8051 * constructor(address _addr) public { CALLED_INSTANCE = calledContract(_addr); } // lets create a
@@ -85,7 +56,6 @@ public static void destroy() {
8556 * in to temp vars (bool _bool, uint256 _uint, bytes32 _bytes32) = CALLED_INSTANCE.testReturns();
8657 * // lets write those temp vars to state testCallbackReturns_.someBool = _bool;
8758 * testCallbackReturns_.someUint = _uint; testCallbackReturns_.someBytes32 = _bytes32; } }
88- *
8959 * contract calledContract { function testReturns() external pure returns(bool, uint256, bytes32)
9060 * { return(true, 314159, 0x123456); } }
9161 */
0 commit comments