Skip to content

Commit

Permalink
Merge pull request #1739 from skalenetwork/3.17.2-merge
Browse files Browse the repository at this point in the history
3.17.2 merge
  • Loading branch information
DmytroNazarenko authored Dec 1, 2023
2 parents 1de9f45 + 661bb2d commit 8569d6f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libweb3jsonrpc/Net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Net::Net( const dev::eth::ChainParams& _chainParams ) : m_chainParams( _chainPar
// TODO Ask here real values from consensus/broadcast

std::string Net::net_version() {
return toJS( m_chainParams.chainID );
return toString( m_chainParams.chainID );
}

std::string Net::net_peerCount() {
Expand Down
23 changes: 20 additions & 3 deletions test/unittests/libweb3jsonrpc/jsonrpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include <libweb3jsonrpc/Debug.h>
#include <libweb3jsonrpc/Eth.h>
#include <libweb3jsonrpc/ModularServer.h>
// SKALE #include <libweb3jsonrpc/Net.h>
#include <libweb3jsonrpc/Net.h>
#include <libweb3jsonrpc/Test.h>
#include <libweb3jsonrpc/Web3.h>
#include <test/tools/libtesteth/TestHelper.h>
Expand Down Expand Up @@ -329,7 +329,7 @@ struct JsonRpcFixture : public TestOutputHelperFixture {
else
client->setAuthor( chainParams.sChain.blockAuthor );

using FullServer = ModularServer< rpc::EthFace, /* rpc::NetFace,*/ rpc::Web3Face,
using FullServer = ModularServer< rpc::EthFace, rpc::NetFace, rpc::Web3Face,
rpc::AdminEthFace /*, rpc::AdminNetFace*/, rpc::DebugFace, rpc::TestFace >;

accountHolder.reset( new FixedAccountHolder( [&]() { return client.get(); }, {} ) );
Expand All @@ -343,7 +343,7 @@ struct JsonRpcFixture : public TestOutputHelperFixture {

gasPricer = make_shared< eth::TrivialGasPricer >( 0, DefaultGasPrice );

rpcServer.reset( new FullServer( ethFace /*, new rpc::Net(*web3)*/,
rpcServer.reset( new FullServer( ethFace , new rpc::Net( chainParams ),
new rpc::Web3( /*web3->clientVersion()*/ ), // TODO Add real version?
new rpc::AdminEth( *client, *gasPricer, keyManager, *sessionManager.get() ),
/*new rpc::AdminNet(*web3, *sessionManager), */ new rpc::Debug( *client ),
Expand Down Expand Up @@ -502,6 +502,23 @@ BOOST_AUTO_TEST_CASE( jsonrpc_number ) {
// BOOST_CHECK_EQUAL(web3->isNetworkStarted(), false);
//}

BOOST_AUTO_TEST_CASE( jsonrpc_netVersion )
{
std::string _config = c_genesisConfigString;
Json::Value ret;
Json::Reader().parse( _config, ret );

// Set chainID = 65535
ret["params"]["chainID"] = "0xffff";

Json::FastWriter fastWriter;
std::string config = fastWriter.write( ret );
JsonRpcFixture fixture( config );

auto version = fixture.rpcClient->net_version();
BOOST_CHECK_EQUAL( version, "65535" );
}

BOOST_AUTO_TEST_CASE( jsonrpc_setMining ) {
JsonRpcFixture fixture;
fixture.rpcClient->admin_eth_setMining( true, fixture.adminSession );
Expand Down

0 comments on commit 8569d6f

Please sign in to comment.