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 22, 2023
1 parent e411718 commit a504090
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions libethereum/Precompiled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,8 @@ ETH_REGISTER_PRECOMPILED( logTextMessage )( bytesConstRef _in ) {
return { false, response }; // 1st false - means bad error occur
}

static const std::list< std::string > g_listReadableConfigParts{ "skaleConfig.sChain.nodes." };
static const std::list< std::string > g_listReadableConfigParts{ "skaleConfig.sChain.nodes.",
"skaleConfig.nodeInfo.wallets.ima.n" };

static bool stat_is_accessible_json_path( const std::string& strPath ) {
if ( strPath.empty() )
Expand Down Expand Up @@ -935,7 +936,7 @@ ETH_REGISTER_PRECOMPILED( getConfigVariableString )( bytesConstRef _in ) {
strValue = skutils::tools::trim_copy(
joValue.is_string() ? joValue.get< std::string >() : joValue.dump() );

Check warning on line 937 in libethereum/Precompiled.cpp

View check run for this annotation

Codecov / codecov/patch

libethereum/Precompiled.cpp#L935-L937

Added lines #L935 - L937 were not covered by tests
}
bytes response = dev::asBytes( strValue );
bytes response = dev::fromHex( strValue );
return { true, response };
} catch ( std::exception& ex ) {
std::string strError = ex.what();
Expand Down
10 changes: 6 additions & 4 deletions test/unittests/libethereum/PrecompiledTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,7 @@ static std::string const genesisInfoSkaleConfigTest = std::string() +
"30": [
13,
30,
"0x6180cde2cbbcc6b6a17efec4503a7d4316f8612f411ee171587089f770335f484003ad236c534b9afa82befc1f69533723abdb6ec2601e582b72dcfd7919338b",
"0x6180cde2cbbcc6b6a17efec4503a7d4316f8612f411ee171587089f770335f484003ad236c534b9afa82befc1f69533723abdb6ec2601e582b72dcfd7919338b"
]
},
"finish_ts": null,
Expand All @@ -1650,7 +1650,7 @@ static std::string const genesisInfoSkaleConfigTest = std::string() +
"26": [
3,
26,
"0x3a581d62b12232dade30c3710215a271984841657449d1f474295a13737b778266f57e298f123ae80cbab7cc35ead1b62a387556f94b326d5c65d4a7aa2abcba",
"0x3a581d62b12232dade30c3710215a271984841657449d1f474295a13737b778266f57e298f123ae80cbab7cc35ead1b62a387556f94b326d5c65d4a7aa2abcba"
]
},
"finish_ts": 4294967290,
Expand Down Expand Up @@ -1731,7 +1731,8 @@ BOOST_AUTO_TEST_CASE( getConfigVariable ) {
BOOST_REQUIRE( dev::fromBigEndian<dev::u256>( res.second ) == 13 );

input = stringToHex( "skaleConfig.sChain.nodes.0.publicKey" );
in = fromHex( numberToHex( 32 ) + input );
input = input.substr(0, 72); // remove 0s in the end
in = fromHex( numberToHex( 36 ) + input );
res = exec( bytesConstRef( in.data(), in.size() ) );

BOOST_REQUIRE( !res.first );
Expand All @@ -1746,7 +1747,8 @@ BOOST_AUTO_TEST_CASE( getConfigVariable ) {
exec = PrecompiledRegistrar::executor( "getConfigVariableString" );

input = stringToHex( "skaleConfig.sChain.nodes.0.publicKey" );
in = fromHex( numberToHex( 32 ) + input );
input = input.substr(0, 72); // remove 0s in the end
in = fromHex( numberToHex( 36 ) + input );
res = exec( bytesConstRef( in.data(), in.size() ) );

BOOST_REQUIRE( res.first );
Expand Down

0 comments on commit a504090

Please sign in to comment.