Update sample test code
This commit is contained in:
parent
94f0da99f9
commit
bdcc333b7d
37
src/test/java/bdchain/api/Test.java
Normal file
37
src/test/java/bdchain/api/Test.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package bdchain.api;
|
||||||
|
|
||||||
|
import bdchain.api.grpc.GetLedgersResponse;
|
||||||
|
import bdchain.api.grpc.TransactionType;
|
||||||
|
|
||||||
|
public class Test {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
final String ledger = "test";
|
||||||
|
final int block_number = 1;
|
||||||
|
final String block_hash = "0x0";
|
||||||
|
final int index = 0;
|
||||||
|
|
||||||
|
TransactionLedgerClient tlClient = new TransactionLedgerClient("localhost", 8004);
|
||||||
|
System.out.println(tlClient.createLedger(ledger).getOk());
|
||||||
|
GetLedgersResponse r = tlClient.getLedgers();
|
||||||
|
for (int i = 0; i < r.getLedgersCount(); i++) {
|
||||||
|
System.out.println(r.getLedgers(i));
|
||||||
|
}
|
||||||
|
System.out.println(
|
||||||
|
tlClient
|
||||||
|
.sendTransaction(ledger, TransactionType.RECORD, "0x0", "0x1", "data".getBytes())
|
||||||
|
.getHash());
|
||||||
|
|
||||||
|
AccountingChainClient acClient = new AccountingChainClient("localhost", 8013);
|
||||||
|
System.out.println(acClient.blockNumber(ledger).getBlockNumber());
|
||||||
|
System.out.println(acClient.getBlockByNumber(ledger, block_number, false).toString());
|
||||||
|
System.out.println(acClient.getBlockByNumber(ledger, block_number, true).toString());
|
||||||
|
System.out.println(acClient.getBlockByHash(ledger, block_hash, false).toString());
|
||||||
|
System.out.println(acClient.getBlockByHash(ledger, block_hash, true).toString());
|
||||||
|
System.out.println(acClient.getTransactionByHash(ledger, "0x0").toString());
|
||||||
|
System.out.println(
|
||||||
|
acClient.getTransactionByBlockNumberAndIndex(ledger, block_number, index).toString());
|
||||||
|
System.out.println(
|
||||||
|
acClient.getTransactionByBlockHashAndIndex(ledger, block_hash, index).toString());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user