Skip to content

Commit

Permalink
fix: apiWeb3AionTests failing on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
beidouz committed Nov 6, 2018
1 parent ddab265 commit 77d05b9
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 6 deletions.
14 changes: 8 additions & 6 deletions modApiServer/test/org/aion/api/server/rpc/ApiWeb3AionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
import org.junit.Test;

public class ApiWeb3AionTest {

private static final String BASE_PATH = System.getProperty("user.dir");
private static final File GENESIS_PATH = new File(BASE_PATH + "/test_resources/genesis.json");
private static final File CONFIG_PATH = new File(BASE_PATH + "/test_resources/config.xml");
private static final String KEYSTORE_PATH;
private static final String DATABASE_PATH = "ApiServerTestPath";
private long testStartTime;
Expand All @@ -72,6 +74,7 @@ public class ApiWeb3AionTest {

@Before
public void setUp() {
CfgAion.inst().setReadConfigFiles(CONFIG_PATH, GENESIS_PATH);
CfgAion.inst().getDb().setPath(DATABASE_PATH);
impl = AionImpl.inst();
web3Api = new ApiWeb3Aion(impl);
Expand Down Expand Up @@ -132,7 +135,6 @@ public void testEthProtocalVersion() {
public void testEthSyncing() {
RpcMsg rpcMsg = web3Api.eth_syncing();
JSONObject result = (JSONObject) rpcMsg.getResult();
System.out.println();
if (!impl.isSyncComplete()) {
assertEquals(
(long) impl.getInitialStartingBlockNumber().orElse(0L),
Expand Down Expand Up @@ -636,7 +638,7 @@ public void testEthSendRawTransactionNullRawTx() {
}

@Test
public void testGetBlockByHash() {
public void testEthGetBlockByHash() {
AionBlock blk = impl.getBlockchain().getBestBlock();
assertEquals(blk, web3Api.getBestBlock());
JSONObject param = new JSONObject();
Expand All @@ -648,7 +650,7 @@ public void testGetBlockByHash() {
}

@Test
public void testGetBlockByNumber() {
public void testEthGetBlockByNumber() {
AionBlock blk = impl.getBlockchain().getBestBlock();
assertEquals(blk, web3Api.getBestBlock());

Expand All @@ -661,7 +663,7 @@ public void testGetBlockByNumber() {
}

@Test
public void testGetTransactionByHashInvalidParams() {
public void testEthGetTransactionByHashInvalidParams() {
JSONObject params = new JSONObject();
RpcMsg rpcMsg = web3Api.eth_getTransactionByHash(params);

Expand All @@ -671,7 +673,7 @@ public void testGetTransactionByHashInvalidParams() {
}

@Test
public void testGetTransactionByHash() {
public void testEthGetTransactionByHash() {
AionTransaction tx =
new AionTransaction(
AionRepositoryImpl.inst().getNonce(Address.ZERO_ADDRESS()).toByteArray(),
Expand Down
103 changes: 103 additions & 0 deletions modApiServer/test_resources/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="utf-8"?>
<aion>
<mode>aion</mode>
<id>[NODE-ID-PLACEHOLDER]</id>
<api>
<!-- rpc config docs: https://github.com/aionnetwork/aion/wiki/JSON-RPC-API-Docs -->
<rpc active="false" ip="127.0.0.1" port="8545">
<cors-enabled>false</cors-enabled>
<!--comma-separated list, APIs available: web3,net,debug,personal,eth,stratum-->
<apis-enabled>web3,eth,personal,stratum,ops</apis-enabled>
</rpc>
<java active="false" ip="127.0.0.1" port="8547">
<secure-connect>true</secure-connect>
</java>

<nrg-recommendation>
<!--default NRG price used by api if oracle disabled, minimum price recommended by oracle-->
<default>10E9</default>
<!--max NRG price recommended by oracle-->
<max>100E9</max>
<!--enable/diable nrg-oracle service. if disabled, api returns default NRG price if asked for nrgPrice-->
<oracle-enabled>false</oracle-enabled>
</nrg-recommendation>
</api>
<net>
<id>256</id>
<nodes>
<node>p2p://[email protected]:30303</node>
<node>p2p://[email protected]:30303</node>
<node>p2p://[email protected]:30303</node>
<node>p2p://[email protected]:30303</node>
<node>p2p://[email protected]:30303</node>
<node>p2p://[email protected]:30303</node>
</nodes>
<p2p>
<ip>0.0.0.0</ip>
<port>30303</port>
<discover>false</discover>
<max-active-nodes>128</max-active-nodes>
</p2p>
</net>
<sync>
<!-- Downloaded blocks queue limit. This affects memory footprint -->
<blocks-queue-max>32</blocks-queue-max>
<!-- Display syncing status -->
<show-status>false</show-status>
</sync>
<consensus>
<mining>false</mining>
<miner-address>0000000000000000000000000000000000000000000000000000000000000000</miner-address>
<cpu-mine-threads>2</cpu-mine-threads>
<extra-data>AION</extra-data>
<nrg-strategy>
<!-- <monotonic-increase></monotonic-increase> -->
<!-- <decaying></decaying> -->
<!-- <targetted target="10000000"></targetted> -->
<clamped-decay upper-bound="20000000" lower-bound="15000000"></clamped-decay>
</nrg-strategy>
</consensus>
<db>
<!--Sets the physical location on disk where data will be stored.-->
<path>database</path>
<!--Boolean value. Enable/disable database integrity check run at startup.-->
<check_integrity>true</check_integrity>
<!--Data pruning behavior for the state database. Options: FULL, TOP, SPREAD.-->
<!--FULL: the state is not pruned-->
<!--TOP: the state is kept only for the top K blocks; limits sync to branching only within the stored blocks-->
<!--SPREAD: the state is kept for the top K blocks and at regular block intervals-->
<state-storage>FULL</state-storage>
<!--Database implementation used to store data; supported options: leveldb, h2, rocksdb.-->
<!--Caution: changing implementation requires re-syncing from genesis!-->
<vendor>leveldb</vendor>
<!--Boolean value. Enable/disable database compression to trade storage space for execution time.-->
<enable_db_compression>false</enable_db_compression>
</db>
<log>
<!--Enable/Disable logback service; if disabled, output will not be logged -->
<log-file>true</log-file>
<!--Sets the physical location on disk where log files will be stored.-->
<log-path>log</log-path>
<ROOT>WARN</ROOT>
<GEN>INFO</GEN>
<VM>ERROR</VM>
<SYNC>INFO</SYNC>
<CONS>INFO</CONS>
<DB>WARN</DB>
<API>INFO</API>
<P2P>INFO</P2P>
<GUI>INFO</GUI>
</log>
<gui>
<launcher>
<!--Whether JVM settings for launching kernel should be autodetected; 'true' or 'false'-->
<autodetect>true</autodetect>
<!--Path to JAVA_HOME. This field has no effect if autodetect is true.-->
<java-home>aion.sh</java-home>
<!--Working directory of kernel process. This field has no effect if autodetect is true.-->
<working-dir>/placeholder/for/aion_root_dir</working-dir>
<!--Filename of aion launcher script, relative to working-dir. This field has no effect if autodetect is true.-->
<aion-sh></aion-sh>
</launcher>
</gui>
</aion>
19 changes: 19 additions & 0 deletions modApiServer/test_resources/genesis.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"alloc": {
"0x0000000000000000000000000000000000000000000000000000000000000000": {
"balance": "465934586660000000000000000"
}
},
"networkBalanceAllocs": {
"0": {
"balance": "465934586660000000000000000"
}
},
"energyLimit": "15000000",
"nonce": "0x00",
"difficulty": "0x0010",
"coinbase": "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp": "1525924800",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"chainId": "0"
}

0 comments on commit 77d05b9

Please sign in to comment.