Skip to content

Commit

Permalink
add a test for the getTxsCount pending option
Browse files Browse the repository at this point in the history
  • Loading branch information
arajasek committed Nov 6, 2018
1 parent 6b5e04f commit 3b54f26
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions modApiServer/test/org/aion/api/server/ApiAionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

package org.aion.api.server;

import static org.aion.base.util.TypeConverter.StringHexToBigInteger;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
Expand All @@ -46,7 +47,6 @@
import org.aion.base.type.Address;
import org.aion.base.type.ITransaction;
import org.aion.base.type.ITxReceipt;
import org.aion.base.util.TypeConverter;
import org.aion.crypto.ed25519.ECKeyEd25519;
import org.aion.evtmgr.impl.evt.EventBlock;
import org.aion.evtmgr.impl.evt.EventDummy;
Expand Down Expand Up @@ -554,19 +554,19 @@ public void testEthSignTransaction() {
assertEquals(tx.get("to"), outTx.get("to"));
assertEquals(
tx.get("value").toString(),
TypeConverter.StringHexToBigInteger(outTx.get("value").toString()).toString());
StringHexToBigInteger(outTx.get("value").toString()).toString());
assertEquals(
tx.get("gasPrice").toString(),
TypeConverter.StringHexToBigInteger(outTx.get("gasPrice").toString()).toString());
StringHexToBigInteger(outTx.get("gasPrice").toString()).toString());
assertEquals(
tx.get("gasPrice").toString(),
TypeConverter.StringHexToBigInteger(outTx.get("nrgPrice").toString()).toString());
StringHexToBigInteger(outTx.get("nrgPrice").toString()).toString());
assertEquals(
tx.get("gas").toString(),
TypeConverter.StringHexToBigInteger(outTx.get("gas").toString()).toString());
StringHexToBigInteger(outTx.get("gas").toString()).toString());
assertEquals(
tx.get("gas").toString(),
TypeConverter.StringHexToBigInteger(outTx.get("nrg").toString()).toString());
StringHexToBigInteger(outTx.get("nrg").toString()).toString());
assertEquals("0x", outTx.get("input").toString());

JSONArray rawTxArray = new JSONArray();
Expand Down Expand Up @@ -653,4 +653,18 @@ public void testEthSendTransactionAccountNotUnlocked() {
assertNull(result);
assertEquals(RpcError.NOT_ALLOWED, rpcMsg.getError());
}

@Test
public void testEthGetTransactionCountPending() {
JSONObject req = new JSONObject();
req.put("address", Address.ZERO_ADDRESS().toString());
req.put("block", "pending");

RpcMsg rsp = web3Api.eth_getTransactionCount(req);
assertNull(rsp.getError());

assertEquals(
impl.getPendingState().getNonce(Address.ZERO_ADDRESS()),
StringHexToBigInteger(rsp.getResult().toString()));
}
}

0 comments on commit 3b54f26

Please sign in to comment.