|
1 | 1 | package org.tron.core.db; |
2 | 2 |
|
3 | 3 | import static org.junit.Assert.assertEquals; |
| 4 | +import static org.mockito.Mockito.mock; |
4 | 5 |
|
5 | 6 | import com.google.protobuf.ByteString; |
| 7 | +import com.typesafe.config.Config; |
| 8 | +import java.lang.reflect.Field; |
| 9 | +import java.util.ArrayList; |
| 10 | +import java.util.Collections; |
6 | 11 | import java.util.HashMap; |
| 12 | +import java.util.List; |
7 | 13 | import java.util.Map; |
8 | 14 | import javax.annotation.Resource; |
9 | 15 | import org.junit.Assert; |
10 | 16 | import org.junit.Before; |
11 | 17 | import org.junit.Test; |
| 18 | +import org.mockito.Mockito; |
12 | 19 | import org.tron.common.BaseTest; |
13 | 20 | import org.tron.common.utils.ByteArray; |
14 | 21 | import org.tron.core.Constant; |
15 | 22 | import org.tron.core.capsule.AccountCapsule; |
16 | 23 | import org.tron.core.config.args.Args; |
17 | 24 | import org.tron.core.db2.ISession; |
| 25 | +import org.tron.core.exception.TronError; |
| 26 | +import org.tron.core.net.peer.PeerManager; |
18 | 27 | import org.tron.core.store.AccountStore; |
19 | 28 | import org.tron.core.store.AssetIssueStore; |
20 | 29 | import org.tron.core.store.DynamicPropertiesStore; |
@@ -61,6 +70,21 @@ public void init() { |
61 | 70 | init = true; |
62 | 71 | } |
63 | 72 |
|
| 73 | + @Test |
| 74 | + public void setAccountTest() throws Exception { |
| 75 | + Field field = AccountStore.class.getDeclaredField("assertsAddress"); |
| 76 | + field.setAccessible(true); |
| 77 | + field.set(AccountStore.class, new HashMap<>()); |
| 78 | + Config config = mock(Config.class); |
| 79 | + Mockito.when(config.getObjectList("genesis.block.assets")).thenReturn(new ArrayList<>()); |
| 80 | + try { |
| 81 | + AccountStore.setAccount(config); |
| 82 | + Assert.fail(); |
| 83 | + } catch (Throwable e) { |
| 84 | + Assert.assertTrue(e instanceof TronError); |
| 85 | + } |
| 86 | + } |
| 87 | + |
64 | 88 | @Test |
65 | 89 | public void get() { |
66 | 90 | //test get and has Method |
|
0 commit comments