Skip to content

Commit

Permalink
fix stored_ask
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Chernyshov <[email protected]>
  • Loading branch information
Alexey-N-Chernyshov committed Nov 29, 2021
1 parent 936285b commit 8f4c0a1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 20 deletions.
4 changes: 2 additions & 2 deletions core/markets/storage/ask_protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ namespace fc::markets::storage {
}

outcome::result<Bytes> getDigest() const override {
return codec::cbor::encode(*this);
return codec::cbor::encode(StorageAskV1_0_1{this->ask});
};

private:
Expand Down Expand Up @@ -151,7 +151,7 @@ namespace fc::markets::storage {
}

outcome::result<Bytes> getDigest() const override {
return codec::cbor::encode(*this);
return codec::cbor::encode(StorageAskV1_1_0{this->ask});
};

private:
Expand Down
4 changes: 2 additions & 2 deletions core/markets/storage/deal_protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ namespace fc::markets::storage {
}

outcome::result<Bytes> getDigest() const override {
return codec::cbor::encode(*this);
return codec::cbor::encode(ResponseV1_0_1{this->response});
};

private:
Expand Down Expand Up @@ -421,7 +421,7 @@ namespace fc::markets::storage {
}

outcome::result<Bytes> getDigest() const override {
return codec::cbor::encode(*this);
return codec::cbor::encode(ResponseV1_1_0{this->response});
};

private:
Expand Down
18 changes: 9 additions & 9 deletions core/markets/storage/provider/impl/stored_ask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ namespace fc::markets::storage::provider {
OUTCOME_TRY(chain_head, api_->ChainHead());
ChainEpoch timestamp = chain_head->height();
ChainEpoch expiry = chain_head->height() + kDefaultDuration;
StorageAsk default_ask{.price = kDefaultPrice,
.verified_price = kDefaultPrice,
.min_piece_size = kDefaultMinPieceSize,
.max_piece_size = kDefaultMaxPieceSize,
.miner = actor_,
.timestamp = timestamp,
.expiry = expiry,
.seq_no = 0};
StorageAskV1_1_0 default_ask{{.price = kDefaultPrice,
.verified_price = kDefaultPrice,
.min_piece_size = kDefaultMinPieceSize,
.max_piece_size = kDefaultMaxPieceSize,
.miner = actor_,
.timestamp = timestamp,
.expiry = expiry,
.seq_no = 0}};
OUTCOME_TRY(signed_ask, signAsk(default_ask, *chain_head));
return std::move(signed_ask);
}
Expand All @@ -93,7 +93,7 @@ namespace fc::markets::storage::provider {
SignedStorageAskV1_1_0 signed_ask(ask);
OUTCOME_TRY(digest, signed_ask.getDigest());
OUTCOME_TRYA(signed_ask.signature, api_->WalletSign(key_address, digest));
return signed_ask;
return std::move(signed_ask);
}

} // namespace fc::markets::storage::provider
Expand Down
4 changes: 2 additions & 2 deletions core/markets/storage/status_protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ namespace fc::markets::storage {
}

outcome::result<Bytes> getDigest() const override {
return codec::cbor::encode(*this);
return codec::cbor::encode(ProviderDealStateV1_1_0{this->state});
};

private:
Expand Down Expand Up @@ -187,7 +187,7 @@ namespace fc::markets::storage {
}

outcome::result<Bytes> getDigest() const override {
return codec::cbor::encode(*this);
return codec::cbor::encode(ProviderDealStateV1_1_0{this->state});
};

private:
Expand Down
6 changes: 1 addition & 5 deletions test/core/markets/storage/provider/stored_ask_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#include <gtest/gtest.h>
#include "crypto/bls/impl/bls_provider_impl.hpp"
#include "crypto/secp256k1/impl/secp256k1_sha256_provider_impl.hpp"
#include "storage/in_memory/in_memory_storage.hpp"
#include "testutil/literals.hpp"
#include "testutil/outcome.hpp"
Expand All @@ -20,17 +19,13 @@ namespace fc::markets::storage::provider {
using fc::crypto::bls::BlsProvider;
using fc::crypto::bls::BlsProviderImpl;
using fc::crypto::bls::KeyPair;
using fc::crypto::secp256k1::Secp256k1ProviderDefault;
using fc::crypto::secp256k1::Secp256k1Sha256ProviderImpl;
using fc::storage::InMemoryStorage;
using BlsSignature = fc::crypto::bls::Signature;

class StoredAskTest : public ::testing::Test {
public:
std::shared_ptr<BlsProvider> bls_provider_ =
std::make_shared<BlsProviderImpl>();
std::shared_ptr<Secp256k1ProviderDefault> secp256k1_provider_ =
std::make_shared<Secp256k1Sha256ProviderImpl>();

std::shared_ptr<Datastore> datastore = std::make_shared<InMemoryStorage>();

Expand Down Expand Up @@ -110,6 +105,7 @@ namespace fc::markets::storage::provider {
EXPECT_OUTCOME_TRUE(ask, stored_ask.getAsk(actor_address));

EXPECT_EQ(ask.ask.price, kDefaultPrice);
EXPECT_EQ(ask.ask.verified_price, kDefaultPrice);
EXPECT_EQ(ask.ask.min_piece_size, kDefaultMinPieceSize);
EXPECT_EQ(ask.ask.max_piece_size, kDefaultMaxPieceSize);
EXPECT_EQ(ask.ask.miner, actor_address);
Expand Down

0 comments on commit 8f4c0a1

Please sign in to comment.