本文整理汇总了C++中CallbackStatus::setStatus方法的典型用法代码示例。如果您正苦于以下问题:C++ CallbackStatus::setStatus方法的具体用法?C++ CallbackStatus::setStatus怎么用?C++ CallbackStatus::setStatus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CallbackStatus
的用法示例。
在下文中一共展示了CallbackStatus::setStatus方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_blockchain_top
TEST_F(InProcessNode, getLastLocalBlockTimestamp) {
class GetBlockTimestampCore : public ICoreStub {
public:
GetBlockTimestampCore(uint64_t timestamp) : timestamp(timestamp) {}
virtual bool get_blockchain_top(uint64_t& height, crypto::hash& top_id) override {
return true;
}
virtual bool getBlockByHash(const crypto::hash &h, cryptonote::Block &blk) override {
blk.timestamp = timestamp;
return true;
}
uint64_t timestamp;
};
uint64_t expectedTimestamp = 1234567890;
GetBlockTimestampCore core(expectedTimestamp);
CryptoNote::InProcessNode newNode(core, protocolQueryStub);
CallbackStatus initStatus;
newNode.init([&initStatus] (std::error_code ec) { initStatus.setStatus(ec); });
ASSERT_TRUE(initStatus.wait());
uint64_t timestamp = newNode.getLastLocalBlockTimestamp();
ASSERT_EQ(expectedTimestamp, timestamp);
}
示例2:
TEST_F(InProcessNodeTests, getBlocksByHashFail) {
const size_t NUMBER_OF_BLOCKS = 10;
std::vector<Crypto::Hash> blockHashes;
std::vector<CryptoNote::BlockDetails> actualBlocks;
coreStub.set_blockchain_top(0, boost::value_initialized<Crypto::Hash>());
generator.generateEmptyBlocks(NUMBER_OF_BLOCKS);
ASSERT_LT(generator.getBlockchain().size(), NUMBER_OF_BLOCKS * 2);
for (const CryptoNote::Block& block : generator.getBlockchain()) {
coreStub.addBlock(block);
}
for (uint32_t i = 0; i < NUMBER_OF_BLOCKS * 2; ++i) {
blockHashes.push_back(boost::value_initialized<Crypto::Hash>());
}
ASSERT_EQ(actualBlocks.size(), 0);
CallbackStatus status;
node.getBlocks(blockHashes, actualBlocks, [&status] (std::error_code ec) { status.setStatus(ec); });
ASSERT_TRUE(status.wait());
ASSERT_NE(std::error_code(), status.getStatus());
}
示例3: newNode
TEST_F(InProcessNode, initOk) {
CryptoNote::InProcessNode newNode(coreStub, protocolQueryStub);
CallbackStatus status;
newNode.init([&status] (std::error_code ec) { status.setStatus(ec); });
ASSERT_TRUE(status.ok());
}
示例4:
TEST_F(InProcessNode, doubleInit) {
CallbackStatus status;
node.init([&status] (std::error_code ec) { status.setStatus(ec); });
ASSERT_TRUE(status.wait());
std::error_code ec = status.getStatus();
ASSERT_NE(ec, std::error_code());
}
示例5: newNode
TEST_F(InProcessNodeTests, isSynchronizedNotInited) {
CryptoNote::InProcessNode newNode(coreStub, protocolQueryStub);
bool syncStatus;
CallbackStatus status;
newNode.isSynchronized(syncStatus, [&status] (std::error_code ec) { status.setStatus(ec); });
ASSERT_TRUE(status.wait());
ASSERT_NE(std::error_code(), status.getStatus());
}
示例6: get_blockchain_top
TEST_F(InProcessNodeTests, getLastLocalBlockTimestampError) {
class GetBlockTimestampErrorCore : public ICoreStub {
public:
virtual void get_blockchain_top(uint32_t& height, Crypto::Hash& top_id) override {
}
virtual bool getBlockByHash(const Crypto::Hash &h, CryptoNote::Block &blk) override {
return false;
}
};
GetBlockTimestampErrorCore core;
CryptoNote::InProcessNode newNode(core, protocolQueryStub);
CallbackStatus initStatus;
newNode.init([&initStatus] (std::error_code ec) { initStatus.setStatus(ec); });
ASSERT_TRUE(initStatus.wait());
ASSERT_THROW(newNode.getLastLocalBlockTimestamp(), std::exception);
}
示例7: initNode
void InProcessNode::initNode() {
CallbackStatus status;
node.init([&status] (std::error_code ec) { status.setStatus(ec); });
ASSERT_TRUE(status.ok());
}