mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-20 03:35:55 +00:00
@@ -17,9 +17,8 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include "feed/FeedBaseTest.h"
|
||||
#include "feed/FeedTestUtil.h"
|
||||
#include "feed/impl/LedgerFeed.h"
|
||||
#include "util/Fixtures.h"
|
||||
#include "util/TestObject.h"
|
||||
|
||||
#include <boost/asio/io_context.hpp>
|
||||
@@ -29,12 +28,11 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <ripple/protocol/Fees.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
constexpr static auto LEDGERHASH = "4BC50C9B0D8515D3EAAE1E74B29A95804346C491EE1A95BF25E4AAB854A6A652";
|
||||
|
||||
using namespace feed::impl;
|
||||
namespace json = boost::json;
|
||||
using namespace testing;
|
||||
|
||||
using FeedLedgerTest = FeedBaseTest<LedgerFeed>;
|
||||
|
||||
@@ -68,11 +66,6 @@ TEST_F(FeedLedgerTest, SubPub)
|
||||
ctx.run();
|
||||
EXPECT_EQ(testFeedPtr->count(), 1);
|
||||
|
||||
// test publish
|
||||
auto const ledgerinfo2 = CreateLedgerInfo(LEDGERHASH, 31);
|
||||
auto fee2 = ripple::Fees();
|
||||
fee2.reserve = 10;
|
||||
testFeedPtr->pub(ledgerinfo2, fee2, "10-31", 8);
|
||||
constexpr static auto ledgerPub =
|
||||
R"({
|
||||
"type":"ledgerClosed",
|
||||
@@ -85,20 +78,23 @@ TEST_F(FeedLedgerTest, SubPub)
|
||||
"validated_ledgers":"10-31",
|
||||
"txn_count":8
|
||||
})";
|
||||
ctx.restart();
|
||||
ctx.run();
|
||||
|
||||
EXPECT_EQ(json::parse(receivedFeedMessage()), json::parse(ledgerPub));
|
||||
|
||||
// test unsub
|
||||
cleanReceivedFeed();
|
||||
testFeedPtr->unsub(sessionPtr);
|
||||
EXPECT_EQ(testFeedPtr->count(), 0);
|
||||
|
||||
// test publish
|
||||
EXPECT_CALL(*mockSessionPtr, send(SharedStringJsonEq(ledgerPub))).Times(1);
|
||||
auto const ledgerinfo2 = CreateLedgerInfo(LEDGERHASH, 31);
|
||||
auto fee2 = ripple::Fees();
|
||||
fee2.reserve = 10;
|
||||
testFeedPtr->pub(ledgerinfo2, fee2, "10-31", 8);
|
||||
ctx.restart();
|
||||
ctx.run();
|
||||
|
||||
// test unsub, after unsub the send should not be called
|
||||
testFeedPtr->unsub(sessionPtr);
|
||||
EXPECT_EQ(testFeedPtr->count(), 0);
|
||||
EXPECT_CALL(*mockSessionPtr, send(_)).Times(0);
|
||||
testFeedPtr->pub(ledgerinfo2, fee2, "10-31", 8);
|
||||
ctx.restart();
|
||||
ctx.run();
|
||||
EXPECT_TRUE(receivedFeedMessage().empty());
|
||||
}
|
||||
|
||||
TEST_F(FeedLedgerTest, AutoDisconnect)
|
||||
@@ -126,8 +122,8 @@ TEST_F(FeedLedgerTest, AutoDisconnect)
|
||||
});
|
||||
ctx.run();
|
||||
EXPECT_EQ(testFeedPtr->count(), 1);
|
||||
EXPECT_CALL(*mockSessionPtr, send(_)).Times(0);
|
||||
|
||||
// destroy the session
|
||||
sessionPtr.reset();
|
||||
EXPECT_EQ(testFeedPtr->count(), 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user