Skip to content

Commit

Permalink
1702 fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
olehnikolaiev committed Nov 7, 2023
1 parent 399e9b1 commit cfbd435
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 20 deletions.
2 changes: 1 addition & 1 deletion libethereum/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ void Client::init( WithExisting _forceAction, u256 _networkId ) {
if ( m_dbPath.size() )
Defaults::setDBPath( m_dbPath );

if ( ChainParams().sChain.nodeGroups.size() > 0 ) {
if ( chainParams().sChain.nodeGroups.size() > 0 ) {
initHistoricGroupIndex();
} else {
LOG( m_logger ) << "Empty node groups in config. "
Expand Down
2 changes: 2 additions & 0 deletions libethereum/ValidationSchemes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ void validateConfigJson( js::mObject const& _obj ) {
{ "nodeGroups", { { js::obj_type }, JsonFieldPresence::Optional } },
{ "nodeGroups", { { js::obj_type }, JsonFieldPresence::Optional } },
{ "skipInvalidTransactionsPatchTimestamp",
{ { js::int_type }, JsonFieldPresence::Optional } },
{ "precompiledConfigPatchTimestamp",
{ { js::int_type }, JsonFieldPresence::Optional } } } );

js::mArray const& nodes = sChain.at( "nodes" ).get_array();
Expand Down
3 changes: 2 additions & 1 deletion test/unittests/libethereum/ClientTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,7 @@ static std::string const c_genesisInfoSkaleIMABLSPublicKeyTest = std::string() +
"schainName": "TestChain",
"schainID": 1,
"emptyBlockIntervalMs": -1,
"precompiledConfigPatchTimestamp": 1,
"nodeGroups": {
"1": {
"nodes": {
Expand Down Expand Up @@ -919,7 +920,7 @@ static std::string const c_genesisInfoSkaleIMABLSPublicKeyTest = std::string() +
}
)E";

BOOST_AUTO_TEST_CASE( initAndUpdateIMABLSPUblicKey ) {
BOOST_AUTO_TEST_CASE( initAndUpdateHistoricConfigFields ) {
TestClientFixture fixture( c_genesisInfoSkaleIMABLSPublicKeyTest );
ClientTest* testClient = asClientTest( fixture.ethereum() );

Expand Down
1 change: 1 addition & 0 deletions test/unittests/libethereum/PrecompiledConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"schainName": "TestChain",
"schainID": 1,
"contractStorageLimit": 32000,
"precompiledConfigPatchTimestamp": 1,
"emptyBlockIntervalMs": -1,
"nodeGroups": {
"1": {
Expand Down
55 changes: 37 additions & 18 deletions test/unittests/libethereum/PrecompiledTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
#include <libethereum/Precompiled.h>
#include <libethereum/ChainParams.h>
#include <libethereum/Client.h>
#include <libethereum/ClientTest.h>
#include <libethereum/SkaleHost.h>
#include <libethereum/TransactionQueue.h>
#include <test/tools/libtesteth/TestHelper.h>
#include <boost/test/unit_test.hpp>
#include <libskale/OverlayFS.h>
#include <libskale/RevertableFSPatch.h>
#include <libskale/PrecompiledConfigPatch.h>

#include <secp256k1_sha256.h>

Expand Down Expand Up @@ -1624,12 +1626,13 @@ static std::string const genesisInfoSkaleConfigTest = std::string() +
"schainName": "TestChain",
"schainID": 1,
"contractStorageLimit": 32000,
"precompiledConfigPatchTimestamp": 1,
"emptyBlockIntervalMs": -1,
"nodeGroups": {
"1": {
"nodes": {
"30": [
0,
13,
30,
"0x6180cde2cbbcc6b6a17efec4503a7d4316f8612f411ee171587089f770335f484003ad236c534b9afa82befc1f69533723abdb6ec2601e582b72dcfd7919338b",
"0x23bbe8db4e347b4e8c937c1c8350e4b5ed33adb3db69cbdb7a38e1f40a1b82fe"
Expand Down Expand Up @@ -1688,34 +1691,42 @@ static std::string const genesisInfoSkaleConfigTest = std::string() +
BOOST_AUTO_TEST_CASE( getConfigVariableUint256 ) {
ChainParams chainParams;
chainParams = chainParams.loadConfig( genesisInfoSkaleConfigTest );
chainParams.sealEngineName = NoProof::name();
chainParams.allowFutureBlocks = true;

Check warning on line 1695 in test/unittests/libethereum/PrecompiledTest.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/libethereum/PrecompiledTest.cpp#L1691-L1695

Added lines #L1691 - L1695 were not covered by tests

dev::eth::g_configAccesssor.reset( new skutils::json_config_file_accessor( "../../test/unittests/libethereum/PrecompiledConfig.json" ) );

Check warning on line 1697 in test/unittests/libethereum/PrecompiledTest.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/libethereum/PrecompiledTest.cpp#L1697

Added line #L1697 was not covered by tests

std::unique_ptr<dev::eth::Client> client;
dev::WithExisting withExisting = dev::WithExisting::Trust;
dev::TransientDirectory m_tmpDir;
auto monitor = make_shared< InstanceMonitor >("test");
setenv("DATA_DIR", m_tmpDir.path().c_str(), 1);
client.reset( new eth::Client( chainParams, ( int ) chainParams.networkID,
shared_ptr< GasPricer >(), nullptr, nullptr, m_tmpDir.path(),
withExisting, dev::eth::TransactionQueue::Limits{ 1, 1, 1, 1 } ) );
client.reset( new eth::ClientTest( chainParams, ( int ) chainParams.networkID,
shared_ptr< GasPricer >(), nullptr, monitor, m_tmpDir.path(), dev::WithExisting::Kill ) );

Check warning on line 1704 in test/unittests/libethereum/PrecompiledTest.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/libethereum/PrecompiledTest.cpp#L1699-L1704

Added lines #L1699 - L1704 were not covered by tests

std::shared_ptr< SkaleHost > skaleHost = std::make_shared< SkaleHost >( *client, nullptr, nullptr, "", false );
dev::eth::g_skaleHost = skaleHost;
client->injectSkaleHost( skaleHost );
client->injectSkaleHost();
client->startWorking();

Check warning on line 1707 in test/unittests/libethereum/PrecompiledTest.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/libethereum/PrecompiledTest.cpp#L1706-L1707

Added lines #L1706 - L1707 were not covered by tests

client->setAuthor( Address("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF") );

Check warning on line 1709 in test/unittests/libethereum/PrecompiledTest.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/libethereum/PrecompiledTest.cpp#L1709

Added line #L1709 was not covered by tests

ClientTest* testClient = asClientTest( client.get() );

Check warning on line 1711 in test/unittests/libethereum/PrecompiledTest.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/libethereum/PrecompiledTest.cpp#L1711

Added line #L1711 was not covered by tests

testClient->mineBlocks( 1 );
testClient->importTransactionsAsBlock( dev::eth::Transactions(), 1000, 4294967294 );
dev::eth::g_skaleHost = testClient->skaleHost();

Check warning on line 1715 in test/unittests/libethereum/PrecompiledTest.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/libethereum/PrecompiledTest.cpp#L1713-L1715

Added lines #L1713 - L1715 were not covered by tests

PrecompiledExecutor exec = PrecompiledRegistrar::executor( "getConfigVariableUint256" );

Check warning on line 1717 in test/unittests/libethereum/PrecompiledTest.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/libethereum/PrecompiledTest.cpp#L1717

Added line #L1717 was not covered by tests

bytes in = fromHex( numberToHex( 32 ) + stringToHex( "skaleConfig.sChain.nodes.[0].id" ) );
auto res = exec( bytesConstRef( in.data(), in.size() ) );

Check warning on line 1720 in test/unittests/libethereum/PrecompiledTest.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/libethereum/PrecompiledTest.cpp#L1719-L1720

Added lines #L1719 - L1720 were not covered by tests

BOOST_REQUIRE( res.first );
BOOST_REQUIRE( dev::fromBigEndian<dev::u256>( res.second ) == 26 );
BOOST_REQUIRE( dev::fromBigEndian<dev::u256>( res.second ) == 30 );

Check warning on line 1723 in test/unittests/libethereum/PrecompiledTest.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/libethereum/PrecompiledTest.cpp#L1722-L1723

Added lines #L1722 - L1723 were not covered by tests

in = fromHex( numberToHex( 64 ) + stringToHex( "skaleConfig.sChain.nodes.[0].schainIndex" ) );
res = exec( bytesConstRef( in.data(), in.size() ) );

Check warning on line 1726 in test/unittests/libethereum/PrecompiledTest.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/libethereum/PrecompiledTest.cpp#L1725-L1726

Added lines #L1725 - L1726 were not covered by tests

BOOST_REQUIRE( res.first );
BOOST_REQUIRE( dev::fromBigEndian<dev::u256>( res.second ) == 3 );
BOOST_REQUIRE( dev::fromBigEndian<dev::u256>( res.second ) == 13 );

Check warning on line 1729 in test/unittests/libethereum/PrecompiledTest.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/libethereum/PrecompiledTest.cpp#L1728-L1729

Added lines #L1728 - L1729 were not covered by tests

in = fromHex( numberToHex( 64 ) + stringToHex( "skaleConfig.sChain.nodes.[0].owner" ) );
res = exec( bytesConstRef( in.data(), in.size() ) );

Check warning on line 1732 in test/unittests/libethereum/PrecompiledTest.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/libethereum/PrecompiledTest.cpp#L1731-L1732

Added lines #L1731 - L1732 were not covered by tests
Expand All @@ -1731,28 +1742,36 @@ BOOST_AUTO_TEST_CASE( getConfigVariableUint256 ) {
BOOST_AUTO_TEST_CASE( getConfigVariableAddress ) {
ChainParams chainParams;
chainParams = chainParams.loadConfig( genesisInfoSkaleConfigTest );
chainParams.sealEngineName = NoProof::name();
chainParams.allowFutureBlocks = true;

Check warning on line 1746 in test/unittests/libethereum/PrecompiledTest.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/libethereum/PrecompiledTest.cpp#L1742-L1746

Added lines #L1742 - L1746 were not covered by tests

dev::eth::g_configAccesssor.reset( new skutils::json_config_file_accessor( "../../test/unittests/libethereum/PrecompiledConfig.json" ) );

Check warning on line 1748 in test/unittests/libethereum/PrecompiledTest.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/libethereum/PrecompiledTest.cpp#L1748

Added line #L1748 was not covered by tests

std::unique_ptr<dev::eth::Client> client;
dev::WithExisting withExisting = dev::WithExisting::Trust;
dev::TransientDirectory m_tmpDir;
auto monitor = make_shared< InstanceMonitor >("test");
setenv("DATA_DIR", m_tmpDir.path().c_str(), 1);
client.reset( new eth::Client( chainParams, ( int ) chainParams.networkID,
shared_ptr< GasPricer >(), nullptr, nullptr, m_tmpDir.path(),
withExisting, dev::eth::TransactionQueue::Limits{ 1, 1, 1, 1 } ) );
client.reset( new eth::ClientTest( chainParams, ( int ) chainParams.networkID,
shared_ptr< GasPricer >(), nullptr, monitor, m_tmpDir.path(), dev::WithExisting::Kill ) );

Check warning on line 1755 in test/unittests/libethereum/PrecompiledTest.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/libethereum/PrecompiledTest.cpp#L1750-L1755

Added lines #L1750 - L1755 were not covered by tests

client->injectSkaleHost();
client->startWorking();

Check warning on line 1758 in test/unittests/libethereum/PrecompiledTest.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/libethereum/PrecompiledTest.cpp#L1757-L1758

Added lines #L1757 - L1758 were not covered by tests

client->setAuthor( Address("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF") );

Check warning on line 1760 in test/unittests/libethereum/PrecompiledTest.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/libethereum/PrecompiledTest.cpp#L1760

Added line #L1760 was not covered by tests

ClientTest* testClient = asClientTest( client.get() );

Check warning on line 1762 in test/unittests/libethereum/PrecompiledTest.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/libethereum/PrecompiledTest.cpp#L1762

Added line #L1762 was not covered by tests

std::shared_ptr< SkaleHost > skaleHost = std::make_shared< SkaleHost >( *client, nullptr, nullptr, "", false );
dev::eth::g_skaleHost = skaleHost;
client->injectSkaleHost( skaleHost );
testClient->mineBlocks( 1 );
testClient->importTransactionsAsBlock( dev::eth::Transactions(), 1000, 4294967294 );
dev::eth::g_skaleHost = testClient->skaleHost();

Check warning on line 1766 in test/unittests/libethereum/PrecompiledTest.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/libethereum/PrecompiledTest.cpp#L1764-L1766

Added lines #L1764 - L1766 were not covered by tests

PrecompiledExecutor exec = PrecompiledRegistrar::executor( "getConfigVariableAddress" );

Check warning on line 1768 in test/unittests/libethereum/PrecompiledTest.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/libethereum/PrecompiledTest.cpp#L1768

Added line #L1768 was not covered by tests

bytes in = fromHex( numberToHex( 64 ) + stringToHex( "skaleConfig.sChain.nodes.[0].owner" ) );
auto res = exec( bytesConstRef( in.data(), in.size() ) );

Check warning on line 1771 in test/unittests/libethereum/PrecompiledTest.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/libethereum/PrecompiledTest.cpp#L1770-L1771

Added lines #L1770 - L1771 were not covered by tests

BOOST_REQUIRE( res.first );
BOOST_REQUIRE( res.second == fromHex("0x47bbe8db4e347b4e8c937c1c8350e4b7ed30adb3db69bbdb7a38c1f40a1b82fd") );
BOOST_REQUIRE( res.second == fromHex("0x23bbe8db4e347b4e8c937c1c8350e4b5ed33adb3db69cbdb7a38e1f40a1b82fe") );

Check warning on line 1774 in test/unittests/libethereum/PrecompiledTest.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/libethereum/PrecompiledTest.cpp#L1773-L1774

Added lines #L1773 - L1774 were not covered by tests

in = fromHex( numberToHex( 32 ) + stringToHex( "skaleConfig.sChain.nodes.[0].id" ) );
res = exec( bytesConstRef( in.data(), in.size() ) );

Check warning on line 1777 in test/unittests/libethereum/PrecompiledTest.cpp

View check run for this annotation

Codecov / codecov/patch

test/unittests/libethereum/PrecompiledTest.cpp#L1776-L1777

Added lines #L1776 - L1777 were not covered by tests
Expand Down

0 comments on commit cfbd435

Please sign in to comment.