|
1 | 1 | package org.tron.common.runtime; |
2 | 2 |
|
3 | | -import java.io.File; |
4 | 3 | import lombok.extern.slf4j.Slf4j; |
5 | 4 | import org.bouncycastle.util.encoders.Hex; |
6 | | -import org.junit.AfterClass; |
7 | | -import org.junit.BeforeClass; |
| 5 | +import org.junit.Before; |
8 | 6 | import org.junit.Test; |
9 | 7 | import org.testng.Assert; |
10 | | -import org.tron.common.application.Application; |
11 | | -import org.tron.common.application.ApplicationFactory; |
12 | | -import org.tron.common.application.TronApplicationContext; |
13 | | -import org.tron.common.utils.FileUtil; |
| 8 | +import org.tron.common.BaseTest; |
14 | 9 | import org.tron.core.Constant; |
15 | 10 | import org.tron.core.Wallet; |
16 | | -import org.tron.core.config.DefaultConfig; |
17 | 11 | import org.tron.core.config.args.Args; |
18 | | -import org.tron.core.db.Manager; |
19 | 12 | import org.tron.core.exception.ContractExeException; |
20 | 13 | import org.tron.core.exception.ContractValidateException; |
21 | 14 | import org.tron.core.exception.ReceiptCheckErrException; |
|
25 | 18 | import org.tron.protos.Protocol.AccountType; |
26 | 19 |
|
27 | 20 | @Slf4j |
28 | | -public class InheritanceTest { |
| 21 | +public class InheritanceTest extends BaseTest { |
29 | 22 |
|
30 | | - private static final String dbPath = "output_InheritanceTest"; |
31 | 23 | private static final String OWNER_ADDRESS; |
32 | | - private static Runtime runtime; |
33 | | - private static Manager dbManager; |
34 | | - private static TronApplicationContext context; |
35 | | - private static Application appT; |
36 | | - private static RepositoryImpl repository; |
| 24 | + private RepositoryImpl repository; |
| 25 | + private static boolean init; |
37 | 26 |
|
38 | 27 | static { |
| 28 | + dbPath = "output_InheritanceTest"; |
39 | 29 | Args.setParam(new String[]{"--output-directory", dbPath, "--debug"}, Constant.TEST_CONF); |
40 | | - context = new TronApplicationContext(DefaultConfig.class); |
41 | | - appT = ApplicationFactory.create(context); |
42 | 30 | OWNER_ADDRESS = Wallet.getAddressPreFixString() + "abd4b9367799eaa3197fecb144eb71de1e049abc"; |
43 | 31 | } |
44 | 32 |
|
45 | 33 | /** |
46 | 34 | * Init data. |
47 | 35 | */ |
48 | | - @BeforeClass |
49 | | - public static void init() { |
50 | | - dbManager = context.getBean(Manager.class); |
| 36 | + @Before |
| 37 | + public void init() { |
| 38 | + if (init) { |
| 39 | + return; |
| 40 | + } |
51 | 41 | repository = RepositoryImpl.createRoot(StoreFactory.getInstance()); |
52 | 42 | repository.createAccount(Hex.decode(OWNER_ADDRESS), AccountType.Normal); |
53 | 43 | repository.addBalance(Hex.decode(OWNER_ADDRESS), 100000000); |
54 | | - } |
55 | | - |
56 | | - /** |
57 | | - * Release resources. |
58 | | - */ |
59 | | - @AfterClass |
60 | | - public static void destroy() { |
61 | | - Args.clearParam(); |
62 | | - context.destroy(); |
63 | | - if (FileUtil.deleteDir(new File(dbPath))) { |
64 | | - logger.info("Release resources successful."); |
65 | | - } else { |
66 | | - logger.info("Release resources failure."); |
67 | | - } |
| 44 | + init = true; |
68 | 45 | } |
69 | 46 |
|
70 | 47 | /** |
71 | 48 | * pragma solidity ^0.4.19; |
72 | | - * |
73 | 49 | * contract foo { uint256 public id=10; function getNumber() returns (uint256){return 100;} |
74 | 50 | * function getName() returns (string){ return "foo"; } } |
75 | | - * |
76 | 51 | * contract bar is foo { function getName() returns (string) { return "bar"; } function getId() |
77 | 52 | * returns(uint256){return id;} } |
78 | 53 | */ |
@@ -119,7 +94,7 @@ public void inheritanceTest() |
119 | 94 |
|
120 | 95 | /* ========================== CALL getName() return child value ============================= */ |
121 | 96 | byte[] triggerData1 = TvmTestUtils.parseAbi("getName()", ""); |
122 | | - runtime = TvmTestUtils |
| 97 | + Runtime runtime = TvmTestUtils |
123 | 98 | .triggerContractWholeProcessReturnContractAddress(callerAddress, contractAddress, |
124 | 99 | triggerData1, 0, 1000000, repository, null); |
125 | 100 |
|
|
0 commit comments