本文整理汇总了C++中CallbackStatus类的典型用法代码示例。如果您正苦于以下问题:C++ CallbackStatus类的具体用法?C++ CallbackStatus怎么用?C++ CallbackStatus使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CallbackStatus类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST_F
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
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: initNode
void InProcessNode::initNode() {
CallbackStatus status;
node.init([&status] (std::error_code ec) { status.setStatus(ec); });
ASSERT_TRUE(status.ok());
}