Skip to content

Commit

Permalink
fix unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyShi22 committed Nov 6, 2023
1 parent 67fefb0 commit 5a83f73
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
3 changes: 2 additions & 1 deletion bcos-crypto/bcos-crypto/ChecksumAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ inline std::string newEVMAddress(bcos::crypto::Hash::Ptr _hashImpl, const std::s
bytesConstRef _init, u256 const& _salt)
{
auto hash = _hashImpl->hash(
bytes{0xff} + fromHex(_sender) + toBigEndian(_salt) + _hashImpl->hash(_init));
bytes{0xff} + (_sender.starts_with("0x") ? fromHexWithPrefix(_sender) : fromHex(_sender)) +
toBigEndian(_salt) + _hashImpl->hash(_init));

std::string hexAddress;
hexAddress.reserve(40);
Expand Down
11 changes: 4 additions & 7 deletions bcos-framework/test/unittests/interfaces/FeaturesTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,9 @@ BOOST_AUTO_TEST_CASE(feature)
features3.setToDefault(bcos::protocol::BlockVersion::V3_2_3_VERSION);
flags = features3.flags();
// std::tie(flag, name, value) = flags[0];
flag = std::get<0>(flags[0]);
name = std::get<1>(flags[0]);
value = std::get<2>(flags[0]);
BOOST_CHECK_EQUAL(flag, Features::Flag::bugfix_revert);
BOOST_CHECK_EQUAL(name, "bugfix_revert");
BOOST_CHECK_EQUAL(value, true);
BOOST_CHECK_EQUAL(std::get<0>(flags[0]), Features::Flag::bugfix_revert);
BOOST_CHECK_EQUAL(std::get<1>(flags[0]), "bugfix_revert");
BOOST_CHECK_EQUAL(std::get<2>(flags[0]), true);

BOOST_CHECK_EQUAL(features3.get(Features::Flag::feature_dmc2serial), false);
BOOST_CHECK_EQUAL(features3.get("feature_dmc2serial"), false);
Expand All @@ -68,7 +65,7 @@ BOOST_AUTO_TEST_CASE(feature)
BOOST_CHECK_EQUAL(features5.get("feature_dmc2serial"), true);

auto keys = Features::featureKeys();
BOOST_CHECK_EQUAL(keys.size(), 3);
BOOST_CHECK_EQUAL(keys.size(), 4);
BOOST_CHECK_EQUAL(keys[0], "bugfix_revert");
BOOST_CHECK_EQUAL(keys[1], "bugfix_statestorage_hash");
BOOST_CHECK_EQUAL(keys[2], "bugfix_evm_create2_delegatecall_staticcall_codecopy");
Expand Down
2 changes: 2 additions & 0 deletions bcos-scheduler/src/DmcExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ class DmcExecutor
});
}

void setIsCall(bool isCall) { m_isCall = isCall; }

private:
MessageHint handleExecutiveMessage(ExecutiveState::Ptr executive);
void handleExecutiveOutputs(std::vector<bcos::protocol::ExecutionMessage::UniquePtr> outputs);
Expand Down
9 changes: 5 additions & 4 deletions bcos-scheduler/test/testDmcExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ BOOST_AUTO_TEST_CASE(stateSwitchTest)
block->setBlockHeader(blockHeader);
// block = fakeBlock(cryptoSuite, blockFactory, 1, 1, 1);
auto dmcExecutor = std::make_shared<DmcExecutor>(
"DmcExecutor1", "0xaabbccdd", block, executor1, keyLocks, hashImpl, dmcRecorder);
"DmcExecutor1", "0xaabbccdd", block, executor1, keyLocks, hashImpl, dmcRecorder, false);

dmcExecutor->setSchedulerOutHandler(
[this, &dmcFlagStruct](bcos::scheduler::ExecutiveState::Ptr executiveState) {
Expand All @@ -103,7 +103,7 @@ BOOST_AUTO_TEST_CASE(stateSwitchTest)
blockHeader->calculateHash(*hashImpl);
block->setBlockHeader(blockHeader);
auto dmcExecutor2 = std::make_shared<DmcExecutor>(
"DmcExecutor2", to, block, executor1, keyLocks, hashImpl, dmcRecorder);
"DmcExecutor2", to, block, executor1, keyLocks, hashImpl, dmcRecorder, false);
dmcExecutor2->scheduleIn(executiveState);
});

Expand Down Expand Up @@ -226,6 +226,7 @@ BOOST_AUTO_TEST_CASE(stateSwitchTest)


// call
dmcExecutor->setIsCall(true);
auto callMessage = createMessage(4, 0, 1, "0xaabbccdd", true);
dmcExecutor->submit(std::move(callMessage), false);
dmcExecutor->prepare();
Expand Down Expand Up @@ -253,7 +254,7 @@ BOOST_AUTO_TEST_CASE(keyLocksTest)
block->setBlockHeader(blockHeader);
// block = fakeBlock(cryptoSuite, blockFactory, 1, 1, 1);
auto dmcExecutor = std::make_shared<DmcExecutor>(
"DmcExecutor1", "0xaabbccdd", block, executor1, keyLocks, hashImpl, dmcRecorder);
"DmcExecutor1", "0xaabbccdd", block, executor1, keyLocks, hashImpl, dmcRecorder, false);

dmcExecutor->setSchedulerOutHandler(
[this, &dmcFlagStruct](bcos::scheduler::ExecutiveState::Ptr executiveState) {
Expand All @@ -266,7 +267,7 @@ BOOST_AUTO_TEST_CASE(keyLocksTest)
blockHeader->calculateHash(*blockFactory->cryptoSuite()->hashImpl());
block->setBlockHeader(blockHeader);
auto dmcExecutor2 = std::make_shared<DmcExecutor>(
"DmcExecutor2", to, block, executor1, keyLocks, hashImpl, dmcRecorder);
"DmcExecutor2", to, block, executor1, keyLocks, hashImpl, dmcRecorder, false);
dmcExecutor2->scheduleIn(executiveState);
});

Expand Down

0 comments on commit 5a83f73

Please sign in to comment.