Herder::TransactionSubmitStatus
LoadGenerator::TxInfo::execute(Application& app, bool isCreate,
                               TransactionResultCode& code, int32_t batchSize)
{
    auto seqNum = mFrom->getLastSequenceNumber();
    mFrom->setSequenceNumber(seqNum + 1);

    TransactionFramePtr txf =
        transactionFromOperations(app, mFrom->getSecretKey(), seqNum + 1, mOps);
    TxMetrics txm(app.getMetrics());

    // Record tx metrics.
    if (isCreate)
    {
        while (batchSize--)
        {
            txm.mAccountCreated.Mark();
        }
    }
    else
    {
        txm.mPayment.Mark();
        txm.mNativePayment.Mark();
    }
    txm.mTxnAttempted.Mark();

    StellarMessage msg;
    msg.type(TRANSACTION);
    msg.transaction() = txf->getEnvelope();
    txm.mTxnBytes.Mark(xdr::xdr_argpack_size(msg));

    auto status = app.getHerder().recvTransaction(txf);
    if (status != Herder::TX_STATUS_PENDING)
    {
        CLOG(INFO, "LoadGen")
            << "tx rejected '" << Herder::TX_STATUS_STRING[status]
            << "': " << xdr::xdr_to_string(txf->getEnvelope()) << " ===> "
            << xdr::xdr_to_string(txf->getResult());
        if (status == Herder::TX_STATUS_ERROR)
        {
            code = txf->getResultCode();
        }
        txm.mTxnRejected.Mark();
    }
    else
    {
        app.getOverlayManager().broadcastMessage(msg);
    }

    return status;
}
Beispiel #2
0
    const uint64_t paymentAmount =
        app.getLedgerManager().getCurrentLedgerHeader().baseReserve * 10;

    SECTION("outer envelope")
    {
        TransactionFramePtr txFrame;
        LedgerDelta delta(app.getLedgerManager().getCurrentLedgerHeader());

        SECTION("no signature")
        {
            txFrame = createPaymentTx(root, a1, rootSeq++, paymentAmount);
            txFrame->getEnvelope().signatures.clear();

            txFrame->apply(delta, app);

            REQUIRE(txFrame->getResultCode() == txBAD_AUTH);
        }
        SECTION("bad signature")
        {
            txFrame = createPaymentTx(root, a1, rootSeq++, paymentAmount);
            txFrame->getEnvelope().signatures[0].signature.fill(123);

            txFrame->apply(delta, app);

            REQUIRE(txFrame->getResultCode() == txBAD_AUTH);
        }
        SECTION("bad signature (wrong hint)")
        {
            txFrame = createPaymentTx(root, a1, rootSeq++, paymentAmount);
            txFrame->getEnvelope().signatures[0].hint.fill(1);