Skip to content

Commit

Permalink
#2031 fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
olehnikolaiev committed Feb 7, 2025
1 parent e402572 commit bd06b85
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
2 changes: 0 additions & 2 deletions libethereum/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,6 @@ size_t Client::syncTransactions(
assert( !m_working.isSealed() );
tie( newPendingReceipts, goodReceipts ) =
m_working.syncEveryone( bc(), _transactions, _timestamp, _gasPrice );
// m_state.clearAllCaches();
m_state = m_state.createStateCopyAndClearCaches();
#ifdef HISTORIC_STATE
// make sure the trie in new state object points to the new state root
Expand Down Expand Up @@ -642,7 +641,6 @@ void Client::restartMining() {
DEV_READ_GUARDED( x_preSeal )
newPreMine = m_preSeal;

// m_state.clearAllCaches();
m_state = m_state.createStateCopyAndClearCaches();
preChanged = newPreMine.sync( bc(), m_state );

Expand Down
6 changes: 3 additions & 3 deletions test/unittests/libskutils/test_skutils_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1380,9 +1380,9 @@ void test_print_header_name( const char* s ) {
cc::_on_ = bPrev;
}


int g_nDefaultPort = 9696;
int g_nDefaultPortProxygen = 8686;
int randomOffset = std::rand() % 50000;
int g_nDefaultPort = 9696 + randomOffset;
int g_nDefaultPortProxygen = 8686 + randomOffset;

std::vector< std::string > g_vecTestClientNamesA = {"Frodo", "Bilbo", "Sam", "Elrond", "Galadriel",
"Celeborn", "Balrog", "Anduin", "Samwise", "Gandalf", "Legolas", "Aragorn", "Gimli", "Faramir",
Expand Down
22 changes: 11 additions & 11 deletions test/unittests/libweb3jsonrpc/jsonrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2512,7 +2512,7 @@ BOOST_AUTO_TEST_CASE( storage_limit_contract ) {
txCall["from"] = toJS( senderAddress );
txCall["gasPrice"] = fixture.rpcClient->eth_gasPrice();
txHash = fixture.rpcClient->eth_call( txCall, "latest" );
BOOST_REQUIRE( fixture.client->state().storageUsed( contract ) == 0 );
BOOST_REQUIRE( fixture.client->state().createReadOnlySnapBasedCopy().storageUsed( contract ) == 0 );

Json::Value txPushValueAndCall; // call storeAndCall(1)
txPushValueAndCall["to"] = contractAddress;
Expand All @@ -2522,7 +2522,7 @@ BOOST_AUTO_TEST_CASE( storage_limit_contract ) {
txPushValueAndCall["gasPrice"] = fixture.rpcClient->eth_gasPrice();
txHash = fixture.rpcClient->eth_sendTransaction( txPushValueAndCall );
dev::eth::mineTransaction( *( fixture.client ), 1 );
BOOST_REQUIRE( fixture.client->state().storageUsed( contract ) == 96 );
BOOST_REQUIRE( fixture.client->state().createReadOnlySnapBasedCopy().storageUsed( contract ) == 96 );

Json::Value txPushValue; // call store(2)
txPushValue["to"] = contractAddress;
Expand All @@ -2532,7 +2532,7 @@ BOOST_AUTO_TEST_CASE( storage_limit_contract ) {
txPushValue["gasPrice"] = fixture.rpcClient->eth_gasPrice();
txHash = fixture.rpcClient->eth_sendTransaction( txPushValue );
dev::eth::mineTransaction( *( fixture.client ), 1 );
BOOST_REQUIRE( fixture.client->state().storageUsed( contract ) == 128 );
BOOST_REQUIRE( fixture.client->state().createReadOnlySnapBasedCopy().storageUsed( contract ) == 128 );

Json::Value txThrow; // trying to call store(3)
txThrow["to"] = contractAddress;
Expand All @@ -2541,7 +2541,7 @@ BOOST_AUTO_TEST_CASE( storage_limit_contract ) {
txThrow["gasPrice"] = fixture.rpcClient->eth_gasPrice();
txHash = fixture.rpcClient->eth_sendTransaction( txThrow );
dev::eth::mineTransaction( *( fixture.client ), 1 );
BOOST_REQUIRE( fixture.client->state().storageUsed( contract ) == 128 );
BOOST_REQUIRE( fixture.client->state().createReadOnlySnapBasedCopy().storageUsed( contract ) == 128 );

Json::Value txEraseValue; // call erase(2)
txEraseValue["to"] = contractAddress;
Expand All @@ -2551,7 +2551,7 @@ BOOST_AUTO_TEST_CASE( storage_limit_contract ) {
txEraseValue["gasPrice"] = fixture.rpcClient->eth_gasPrice();
txHash = fixture.rpcClient->eth_sendTransaction( txEraseValue );
dev::eth::mineTransaction( *( fixture.client ), 1 );
BOOST_REQUIRE( fixture.client->state().storageUsed( contract ) == 96 );
BOOST_REQUIRE( fixture.client->state().createReadOnlySnapBasedCopy().storageUsed( contract ) == 96 );

Json::Value txZeroValue; // call zero(1)
txZeroValue["to"] = contractAddress;
Expand All @@ -2561,7 +2561,7 @@ BOOST_AUTO_TEST_CASE( storage_limit_contract ) {
txZeroValue["gasPrice"] = fixture.rpcClient->eth_gasPrice();
txHash = fixture.rpcClient->eth_sendTransaction( txZeroValue );
dev::eth::mineTransaction( *( fixture.client ), 1 );
BOOST_REQUIRE( fixture.client->state().storageUsed( contract ) == 64 );
BOOST_REQUIRE( fixture.client->state().createReadOnlySnapBasedCopy().storageUsed( contract ) == 64 );

Json::Value txZeroValue1; // call zero(1)
txZeroValue1["to"] = contractAddress;
Expand All @@ -2571,7 +2571,7 @@ BOOST_AUTO_TEST_CASE( storage_limit_contract ) {
txZeroValue1["gasPrice"] = fixture.rpcClient->eth_gasPrice();
txHash = fixture.rpcClient->eth_sendTransaction( txZeroValue1 );
dev::eth::mineTransaction( *( fixture.client ), 1 );
BOOST_REQUIRE( fixture.client->state().storageUsed( contract ) == 64 );
BOOST_REQUIRE( fixture.client->state().createReadOnlySnapBasedCopy().storageUsed( contract ) == 64 );

Json::Value txValueChanged; // call strangeFunction(1)
txValueChanged["to"] = contractAddress;
Expand All @@ -2581,7 +2581,7 @@ BOOST_AUTO_TEST_CASE( storage_limit_contract ) {
txValueChanged["gasPrice"] = fixture.rpcClient->eth_gasPrice();
txHash = fixture.rpcClient->eth_sendTransaction( txValueChanged );
dev::eth::mineTransaction( *( fixture.client ), 1 );
BOOST_REQUIRE( fixture.client->state().storageUsed( contract ) == 96 );
BOOST_REQUIRE( fixture.client->state().createReadOnlySnapBasedCopy().storageUsed( contract ) == 96 );

Json::Value txValueChanged1; // call strangeFunction(0)
txValueChanged1["to"] = contractAddress;
Expand All @@ -2591,7 +2591,7 @@ BOOST_AUTO_TEST_CASE( storage_limit_contract ) {
txValueChanged1["gasPrice"] = fixture.rpcClient->eth_gasPrice();
txHash = fixture.rpcClient->eth_sendTransaction( txValueChanged1 );
dev::eth::mineTransaction( *( fixture.client ), 1 );
BOOST_REQUIRE( fixture.client->state().storageUsed( contract ) == 96 );
BOOST_REQUIRE( fixture.client->state().createReadOnlySnapBasedCopy().storageUsed( contract ) == 96 );

Json::Value txValueChanged2; // call strangeFunction(2)
txValueChanged2["to"] = contractAddress;
Expand All @@ -2601,7 +2601,7 @@ BOOST_AUTO_TEST_CASE( storage_limit_contract ) {
txValueChanged2["gasPrice"] = fixture.rpcClient->eth_gasPrice();
txHash = fixture.rpcClient->eth_sendTransaction( txValueChanged2 );
dev::eth::mineTransaction( *( fixture.client ), 1 );
BOOST_REQUIRE( fixture.client->state().storageUsed( contract ) == 128 );
BOOST_REQUIRE( fixture.client->state().createReadOnlySnapBasedCopy().storageUsed( contract ) == 128 );

Json::Value txValueChanged3; // try call strangeFunction(3)
txValueChanged3["to"] = contractAddress;
Expand All @@ -2611,7 +2611,7 @@ BOOST_AUTO_TEST_CASE( storage_limit_contract ) {
txValueChanged3["gasPrice"] = fixture.rpcClient->eth_gasPrice();
txHash = fixture.rpcClient->eth_sendTransaction( txValueChanged3 );
dev::eth::mineTransaction( *( fixture.client ), 1 );
BOOST_REQUIRE( fixture.client->state().storageUsed( contract ) == 128 );
BOOST_REQUIRE( fixture.client->state().createReadOnlySnapBasedCopy().storageUsed( contract ) == 128 );
}

BOOST_AUTO_TEST_CASE( storage_limit_chain ) {
Expand Down

0 comments on commit bd06b85

Please sign in to comment.