Skip to content

Commit

Permalink
addressing review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
vlntb committed Jan 22, 2025
1 parent 423a7f3 commit 873e855
Showing 1 changed file with 15 additions and 31 deletions.
46 changes: 15 additions & 31 deletions src/test/overlay/tx_reduce_relay_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#include <test/jtx.h>
#include <test/jtx/Env.h>
#include <xrpld/overlay/detail/OverlayImpl.h>
#include <xrpld/overlay/detail/PeerImp.h>
Expand Down Expand Up @@ -223,37 +224,20 @@ class tx_reduce_relay_test : public beast::unit_test::suite
for (int i = 0; i < nPeers; i++)
addPeer(env, peers, nDisabled);

auto const kp1 = randomKeyPair(KeyType::secp256k1);
auto const id1 = calcAccountID(kp1.first);

auto const kp2 = randomKeyPair(KeyType::secp256k1);
auto const id2 = calcAccountID(kp2.first);

auto getPayment = [kp1, id1, id2]() {
// Account id1 pays account id2 10,000 XRP.
STObject payment(sfGeneric);
payment.setFieldU16(sfTransactionType, ttPAYMENT);
payment.setAccountID(sfAccount, id1);
payment.setAccountID(sfDestination, id2);
payment.setFieldAmount(sfAmount, STAmount(10000000000ull));
payment.setFieldAmount(sfFee, STAmount(10ull));
payment.setFieldU32(sfSequence, 1);
payment.setFieldVL(
sfSigningPubKey, Slice(kp1.first.data(), kp1.first.size()));
return payment;
};
auto stx = STTx{getPayment()};

protocol::TMTransaction m;
Serializer s;
stx.add(s);
m.set_rawtransaction(s.data(), s.size());
m.set_deferred(false);
m.set_status(protocol::TransactionStatus::tsNEW);
env.app().overlay().relay(uint256{0}, m, toSkip);
BEAST_EXPECT(
PeerTest::sendTx_ == expectRelay &&
PeerTest::queueTx_ == expectQueue);
auto const jtx = env.jt(noop(env.master));
if (BEAST_EXPECT(jtx.stx))
{
protocol::TMTransaction m;
Serializer s;
jtx.stx->add(s);
m.set_rawtransaction(s.data(), s.size());
m.set_deferred(false);
m.set_status(protocol::TransactionStatus::tsNEW);
env.app().overlay().relay(uint256{0}, m, toSkip);
BEAST_EXPECT(
PeerTest::sendTx_ == expectRelay &&
PeerTest::queueTx_ == expectQueue);
}
}

void
Expand Down

0 comments on commit 873e855

Please sign in to comment.