Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/dot-transfer-broadcast #1328

Merged
merged 5 commits into from
Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion core/api/service/author/impl/author_api_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,18 @@ namespace kagome::api {
outcome::result<AuthorApi::SubscriptionId>
AuthorApiImpl::submitAndWatchExtrinsic(Extrinsic extrinsic) {
if (auto service = api_service_.lock()) {
OUTCOME_TRY(
tx,
pool_->constructTransaction(TransactionSource::External, extrinsic));
OUTCOME_TRY(sub_id, service->subscribeForExtrinsicLifecycle(tx.hash));
OUTCOME_TRY(tx_hash,
submitExtrinsic(
// submit and watch could be executed only
// from RPC call, so External source is chosen
TransactionSource::External,
extrinsic));
BOOST_ASSERT(tx_hash == tx.hash);

OUTCOME_TRY(sub_id, service->subscribeForExtrinsicLifecycle(tx_hash));
SL_DEBUG(logger_, "Subscribe for ex hash={}", tx_hash);

return sub_id;
Expand Down
4 changes: 2 additions & 2 deletions core/transaction_pool/impl/transaction_pool_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ namespace kagome::transaction_pool {

Status getStatus() const override;

private:
outcome::result<primitives::Transaction> constructTransaction(
primitives::TransactionSource source,
primitives::Extrinsic extrinsic) const;
primitives::Extrinsic extrinsic) const override;

private:
outcome::result<void> submitOne(const std::shared_ptr<Transaction> &tx);

outcome::result<void> processTransaction(
Expand Down
4 changes: 4 additions & 0 deletions core/transaction_pool/transaction_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ namespace kagome::transaction_pool {
const primitives::BlockId &at) = 0;

virtual Status getStatus() const = 0;

virtual outcome::result<primitives::Transaction> constructTransaction(
primitives::TransactionSource source,
primitives::Extrinsic extrinsic) const = 0;
};

struct TransactionPool::Status {
Expand Down
3 changes: 3 additions & 0 deletions test/core/api/service/author/author_api_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,9 @@ TEST_F(AuthorApiTest, HasKeyFail) {
TEST_F(AuthorApiTest, SubmitAndWatchExtrinsicSubmitsAndWatches) {
Transaction::Hash tx_hash{};

EXPECT_CALL(*transaction_pool,
constructTransaction(TransactionSource::External, *extrinsic))
.WillOnce(Return(outcome::success()));
EXPECT_CALL(*transaction_pool,
submitExtrinsic(TransactionSource::External, *extrinsic))
.WillOnce(testing::DoAll(
Expand Down
5 changes: 5 additions & 0 deletions test/mock/core/transaction_pool/transaction_pool_mock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ namespace kagome::transaction_pool {
(override));

MOCK_METHOD(Status, getStatus, (), (const, override));

MOCK_METHOD(outcome::result<primitives::Transaction>,
constructTransaction,
(primitives::TransactionSource, primitives::Extrinsic),
(const, override));
};

} // namespace kagome::transaction_pool
Expand Down