예제 #1
0
  @Test
  public void testDb() {
    Tx tx = new Tx();
    byte[] txHash =
        Utils.reverseBytes(
            Utils.hexStringToByteArray(
                "f8a8335594d4c883f367e003cb3832015640f24714b48bd21cf6fbe84a617dfe"));
    tx.setTxHash(
        Utils.reverseBytes(
            Utils.hexStringToByteArray(
                "f8a8335594d4c883f367e003cb3832015640f24714b48bd21cf6fbe84a617dfe")));
    tx.setBlockNo(304942);
    tx.setTxTime((int) new Date().getTime() / 1000);
    tx.setTxVer(1);
    In inPut = new In();
    inPut.setPrevTxHash(
        Utils.reverseBytes(
            Utils.hexStringToByteArray(
                "d7f4efff7aeaffc1630dd3653e923a233fd463f9dc7dd4f97bb5cbf0cf99e56a")));
    inPut.setInSn(0);
    inPut.setTxHash(txHash);
    inPut.setInSequence(1);
    inPut.setInSignature(txHash);

    tx.addInput(inPut);
    Out out = new Out();
    out.setTxHash(txHash);
    out.setOutSn(0);
    out.setOutValue(3400);
    out.setOutScript(
        Utils.hexStringToByteArray("76a914abceaddc7d791f749671c17dfa36e9b17a4b055588ac"));
    out.setOutStatus(Out.OutStatus.spent);
    out.setOutAddress("test");
    tx.addOutput(out);
    AbstractDb.txProvider.add(tx);
    Tx testTx = AbstractDb.txProvider.getTxDetailByTxHash(txHash);
    assertEquals(
        Utils.bytesToHexString(tx.getTxHash()), Utils.bytesToHexString(testTx.getTxHash()));
  }