diff --git a/eth/main.cpp b/eth/main.cpp index 971188ef2..d4ad08529 100644 --- a/eth/main.cpp +++ b/eth/main.cpp @@ -1124,13 +1124,33 @@ int main(int argc, char** argv) else if (c && cmd == "setblockfees") { iss >> blockFees; - gasPricer->setRefBlockFees(u256(blockFees * 1000)); + try + { + gasPricer->setRefBlockFees(u256(blockFees * 1000)); + } + catch (Overflow const& _e) + { + cout << boost::diagnostic_information(_e); + } + cout << "Block fees: " << blockFees << endl; } else if (c && cmd == "setetherprice") { iss >> etherPrice; - gasPricer->setRefPrice(u256(double(ether / 1000) / etherPrice)); + if (etherPrice == 0) + cout << "ether price cannot be set to zero" << endl; + else + { + try + { + gasPricer->setRefPrice(u256(double(ether / 1000) / etherPrice)); + } + catch (Overflow const& _e) + { + cout << boost::diagnostic_information(_e); + } + } cout << "ether Price: " << etherPrice << endl; } else if (c && cmd == "setpriority") diff --git a/libdevcore/Exceptions.h b/libdevcore/Exceptions.h index 377420003..219047827 100644 --- a/libdevcore/Exceptions.h +++ b/libdevcore/Exceptions.h @@ -51,6 +51,7 @@ struct NoUPnPDevice: virtual Exception {}; struct RootNotFound: virtual Exception {}; struct BadRoot: virtual Exception {}; struct FileError: virtual Exception {}; +struct Overflow: virtual Exception {}; struct InterfaceNotSupported: virtual Exception { public: InterfaceNotSupported(std::string _f): Exception("Interface " + _f + " not supported.") {} }; // error information to be added to exceptions diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 49679bc32..cb51bcb87 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -81,8 +82,10 @@ void BasicGasPricer::update(BlockChain const& _bc) h256 p = _bc.currentHash(); m_gasPerBlock = _bc.info(p).gasLimit; - map dist; - unsigned total = 0; + map dist; + u256 total = 0; + + // make gasPrice versus gasUsed distribution for the last 1000 blocks while (c < 1000 && p) { BlockInfo bi = _bc.info(p); @@ -91,29 +94,53 @@ void BasicGasPricer::update(BlockChain const& _bc) auto bb = _bc.block(p); RLP r(bb); BlockReceipts brs(_bc.receipts(bi.hash())); - for (unsigned i = 0; i < r[1].size(); ++i) + size_t i = 0; + for (auto const& tr: r[1]) { - auto gu = brs.receipts[i].gasUsed(); - dist[Transaction(r[1][i].data(), CheckTransaction::None).gasPrice()] += (unsigned)brs.receipts[i].gasUsed(); - total += (unsigned)gu; + Transaction tx(tr.data(), CheckTransaction::None); + u256 gu = brs.receipts[i].gasUsed(); + dist[tx.gasPrice()] += gu; + total += gu; + i++; } } p = bi.parentHash; ++c; } + + // fill m_octiles with weighted gasPrices if (total > 0) { - unsigned t = 0; - unsigned q = 1; m_octiles[0] = dist.begin()->first; + + // calc mean + u256 mean = 0; + for (auto const& i: dist) + mean += i.first * i.second; + mean /= total; + + // calc standard deviation + u256 sdSquared = 0; for (auto const& i: dist) + sdSquared += i.second * (i.first - mean) * (i.first - mean); + sdSquared /= total; + + if (sdSquared) + { + long double sd = sqrt(sdSquared.convert_to()); + long double normalizedSd = sd / mean.convert_to(); + + // calc octiles normalized to gaussian distribution + boost::math::normal gauss(1.0, (normalizedSd > 0.01) ? normalizedSd : 0.01); + for (size_t i = 1; i < 8; i++) + m_octiles[i] = u256(mean.convert_to() * boost::math::quantile(gauss, i / 8.0)); + m_octiles[8] = dist.rbegin()->first; + } + else { - for (; t <= total * q / 8 && t + i.second > total * q / 8; ++q) - m_octiles[q] = i.first; - if (q > 7) - break; + for (size_t i = 0; i < 9; i++) + m_octiles[i] = (i + 1) * mean / 5; } - m_octiles[8] = dist.rbegin()->first; } } diff --git a/libethereum/Client.h b/libethereum/Client.h index 8524525d8..662d05fd6 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -77,8 +77,8 @@ class BasicGasPricer: public GasPricer public: explicit BasicGasPricer(u256 _weiPerRef, u256 _refsPerBlock): m_weiPerRef(_weiPerRef), m_refsPerBlock(_refsPerBlock) {} - void setRefPrice(u256 _weiPerRef) { m_weiPerRef = _weiPerRef; } - void setRefBlockFees(u256 _refsPerBlock) { m_refsPerBlock = _refsPerBlock; } + void setRefPrice(u256 _weiPerRef) { if ((bigint)m_refsPerBlock * _weiPerRef > std::numeric_limits::max() ) BOOST_THROW_EXCEPTION(Overflow() << errinfo_comment("ether price * block fees is larger than 2**256-1, choose a smaller number.") ); else m_weiPerRef = _weiPerRef; } + void setRefBlockFees(u256 _refsPerBlock) { if ((bigint)m_weiPerRef * _refsPerBlock > std::numeric_limits::max() ) BOOST_THROW_EXCEPTION(Overflow() << errinfo_comment("ether price * block fees is larger than 2**256-1, choose a smaller number.") ); else m_refsPerBlock = _refsPerBlock; } u256 ask(State const&) const override { return m_weiPerRef * m_refsPerBlock / m_gasPerBlock; } u256 bid(TransactionPriority _p = TransactionPriority::Medium) const override { return m_octiles[(int)_p] > 0 ? m_octiles[(int)_p] : (m_weiPerRef * m_refsPerBlock / m_gasPerBlock); } diff --git a/libtestutils/StateLoader.cpp b/libtestutils/StateLoader.cpp index 07eb2cef5..9eff30b29 100644 --- a/libtestutils/StateLoader.cpp +++ b/libtestutils/StateLoader.cpp @@ -54,5 +54,4 @@ StateLoader::StateLoader(Json::Value const& _json, std::string const& _dbPath): } m_state.commit(); - m_state.db().commit(); } diff --git a/neth/main.cpp b/neth/main.cpp index 4e83f64bc..066177b2f 100644 --- a/neth/main.cpp +++ b/neth/main.cpp @@ -718,13 +718,33 @@ int main(int argc, char** argv) else if (c && cmd == "setblockfees") { iss >> blockFees; - gasPricer->setRefBlockFees(u256(blockFees * 1000)); + try + { + gasPricer->setRefBlockFees(u256(blockFees * 1000)); + } + catch (Overflow const& _e) + { + cout << boost::diagnostic_information(_e); + } + cout << "Block fees: " << blockFees << endl; } else if (c && cmd == "setetherprice") { iss >> etherPrice; - gasPricer->setRefPrice(u256(double(ether / 1000) / etherPrice)); + if (etherPrice == 0) + cout << "ether price cannot be set to zero" << endl; + else + { + try + { + gasPricer->setRefPrice(u256(double(ether / 1000) / etherPrice)); + } + catch (Overflow const& _e) + { + cout << boost::diagnostic_information(_e); + } + } cout << "ether Price: " << etherPrice << endl; } else if (c && cmd == "setpriority") diff --git a/test/libethereum/BlockTestsFiller/bcGasPricerTestFiller.json b/test/libethereum/BlockTestsFiller/bcGasPricerTestFiller.json new file mode 100644 index 000000000..0e7030107 --- /dev/null +++ b/test/libethereum/BlockTestsFiller/bcGasPricerTestFiller.json @@ -0,0 +1,386 @@ +{ + "highGasUsage" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "131072", + "extraData" : "0x42", + "gasLimit" : "31415920", + "gasUsed" : "0", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "expect" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000" + } + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "9000000000000000000000000000", + "nonce" : "0", + "code" : "", + "storage": {} + }, + "aaaf5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000", + "nonce" : "0", + "code" : "0x60003551", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + { + "data" : "0xffffffffffff", + "gasLimit" : "850000", + "gasPrice" : "10000000000000", + "nonce" : "0", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "0xffffffffffff", + "gasLimit" : "850000", + "gasPrice" : "12000000000000", + "nonce" : "1", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "0xffffffffffff", + "gasLimit" : "850000", + "gasPrice" : "14000000000000", + "nonce" : "2", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "0xffffffffffff", + "gasLimit" : "850000", + "gasPrice" : "16000000000000", + "nonce" : "3", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "0xffffffffffff", + "gasLimit" : "850000", + "gasPrice" : "18000000000000", + "nonce" : "4", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "0xffffffffffff", + "gasLimit" : "850000", + "gasPrice" : "20000000000000", + "nonce" : "5", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "0xffffffffffff", + "gasLimit" : "850000", + "gasPrice" : "22000000000000", + "nonce" : "6", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "0xffffffffffff", + "gasLimit" : "850000", + "gasPrice" : "24000000000000", + "nonce" : "7", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "0xffffffffffff", + "gasLimit" : "850000", + "gasPrice" : "26000000000000", + "nonce" : "8", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "0xffffffffffff", + "gasLimit" : "850000", + "gasPrice" : "28000000000000", + "nonce" : "9", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + { + "data" : "0xffffffffffff", + "gasLimit" : "850000", + "gasPrice" : "30000000000000", + "nonce" : "10", + "secretKey" : "45a915e4d060149eb4365960e6a7a45f334393093061116b197e3240065ff2d8", + "to" : "095e7baea6a6c7c4c2dfeb977efac326af552d87", + "value" : "10" + } + ], + "uncleHeaders" : [ + ] + } + ] + }, + + "notxs" : { + "genesisBlockHeader" : { + "bloom" : "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "coinbase" : "0x8888f1f195afa192cfee860698584c030f4c9db1", + "difficulty" : "131072", + "extraData" : "0x42", + "gasLimit" : "3141592", + "gasUsed" : "0", + "mixHash" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "nonce" : "0x0102030405060708", + "number" : "0", + "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000", + "receiptTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "stateRoot" : "0xf99eb1626cfa6db435c0836235942d7ccaa935f1ae247d3f1c21e495685f903a", + "timestamp" : "0x54c98c81", + "transactionsTrie" : "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", + "uncleHash" : "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347" + }, + "expect" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000" + } + }, + "pre" : { + "a94f5374fce5edbc8e2a8697c15331677e6ebf0b" : { + "balance" : "10000000000", + "nonce" : "0", + "code" : "", + "storage": {} + } + }, + "blocks" : [ + { + "transactions" : [ + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + ], + "uncleHeaders" : [ + ] + }, + { + "transactions" : [ + ], + "uncleHeaders" : [ + ] + } + ] + } +} diff --git a/test/bcRPC_API_TestFiller.json b/test/libethereum/BlockTestsFiller/bcRPC_API_TestFiller.json similarity index 100% rename from test/bcRPC_API_TestFiller.json rename to test/libethereum/BlockTestsFiller/bcRPC_API_TestFiller.json diff --git a/test/libethereum/blockchain.cpp b/test/libethereum/blockchain.cpp index 4c50c966d..45aa73d86 100644 --- a/test/libethereum/blockchain.cpp +++ b/test/libethereum/blockchain.cpp @@ -58,8 +58,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin) ImportTest importer(o["pre"].get_obj()); TransientDirectory td_stateDB; TransientDirectory td_stateDB_tmp; - State state(OverlayDB(State::openDB(td_stateDB.path())), BaseState::Empty, biGenesisBlock.coinbaseAddress); - State stateTemp(OverlayDB(State::openDB(td_stateDB_tmp.path())), BaseState::Empty, biGenesisBlock.coinbaseAddress); + State state(State::openDB(td_stateDB.path()), BaseState::Empty, biGenesisBlock.coinbaseAddress); + State stateTemp(State::openDB(td_stateDB_tmp.path()), BaseState::Empty, biGenesisBlock.coinbaseAddress); importer.importState(o["pre"].get_obj(), state); o["pre"] = fillJsonWithState(state); state.commit(); @@ -699,6 +699,11 @@ BOOST_AUTO_TEST_CASE(bcUncleHeaderValiditiy) dev::test::executeTests("bcUncleHeaderValiditiy", "/BlockTests",dev::test::getFolder(__FILE__) + "/BlockTestsFiller", dev::test::doBlockchainTests); } +BOOST_AUTO_TEST_CASE(bcGasPricerTest) +{ + dev::test::executeTests("bcGasPricerTest", "/BlockTests",dev::test::getFolder(__FILE__) + "/BlockTestsFiller", dev::test::doBlockchainTests); +} + BOOST_AUTO_TEST_CASE(userDefinedFile) { dev::test::userDefinedTest("--singletest", dev::test::doBlockchainTests); diff --git a/test/libethereum/gaspricer.cpp b/test/libethereum/gaspricer.cpp new file mode 100644 index 000000000..577d217e8 --- /dev/null +++ b/test/libethereum/gaspricer.cpp @@ -0,0 +1,140 @@ +/* + This file is part of cpp-ethereum. + + cpp-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + cpp-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with cpp-ethereum. If not, see . +*/ +/** @file gasPricer.cpp + * @author Christoph Jentzsch + * @date 2015 + */ + +#include +#include +#include +#include +#include +#include "../TestHelper.h" + +using namespace std; +using namespace dev; +using namespace dev::eth; + +namespace dev { namespace test { + +void executeGasPricerTest(const string name, double _etherPrice, double _blockFee, const string bcTestPath, TransactionPriority _txPrio, u256 _expectedAsk, u256 _expectedBid) +{ + cnote << name; + BasicGasPricer gp(u256(double(ether / 1000) / _etherPrice), u256(_blockFee * 1000)); + + Json::Value vJson = test::loadJsonFromFile(test::getTestPath() + bcTestPath); + test::BlockChainLoader bcLoader(vJson[name]); + BlockChain const& bc = bcLoader.bc(); + + gp.update(bc); + BOOST_CHECK_EQUAL(gp.ask(State()), _expectedAsk); + BOOST_CHECK_EQUAL(gp.bid(_txPrio), _expectedBid); +} +} } + +BOOST_AUTO_TEST_SUITE(GasPricer) + +BOOST_AUTO_TEST_CASE(trivialGasPricer) +{ + cnote << "trivialGasPricer"; + std::shared_ptr gp(new TrivialGasPricer); + BOOST_CHECK_EQUAL(gp->ask(State()), 10 * szabo); + BOOST_CHECK_EQUAL(gp->bid(), 10 * szabo); + gp->update(BlockChain(bytes(), TransientDirectory().path(), WithExisting::Kill)); + BOOST_CHECK_EQUAL(gp->ask(State()), 10 * szabo); + BOOST_CHECK_EQUAL(gp->bid(), 10 * szabo); +} + +BOOST_AUTO_TEST_CASE(basicGasPricerNoUpdate) +{ + cnote << "basicGasPricer"; + BasicGasPricer gp(u256(double(ether / 1000) / 30.679), u256(15.0 * 1000)); + BOOST_CHECK_EQUAL(gp.ask(State()), 155632494086); + BOOST_CHECK_EQUAL(gp.bid(), 155632494086); + + gp.setRefPrice(u256(0)); + BOOST_CHECK_EQUAL(gp.ask(State()), 0); + BOOST_CHECK_EQUAL(gp.bid(), 0); + + gp.setRefPrice(u256(1)); + gp.setRefBlockFees(u256(0)); + BOOST_CHECK_EQUAL(gp.ask(State()), 0); + BOOST_CHECK_EQUAL(gp.bid(), 0); + + gp.setRefPrice(u256("0x100000000000000000000000000000000")); + BOOST_CHECK_THROW(gp.setRefBlockFees(u256("0x100000000000000000000000000000000")), Overflow); + BOOST_CHECK_EQUAL(gp.ask(State()), 0); + BOOST_CHECK_EQUAL(gp.bid(), 0); + + gp.setRefPrice(1); + gp.setRefBlockFees(u256("0x100000000000000000000000000000000")); + BOOST_CHECK_THROW(gp.setRefPrice(u256("0x100000000000000000000000000000000")), Overflow); + BOOST_CHECK_EQUAL(gp.ask(State()), u256("108315264019305646138446560671076")); + BOOST_CHECK_EQUAL(gp.bid(), u256("108315264019305646138446560671076")); +} + +BOOST_AUTO_TEST_CASE(basicGasPricer_RPC_API_Test) +{ + dev::test::executeGasPricerTest("RPC_API_Test", 30.679, 15.0, "/BlockTests/bcRPC_API_Test.json", TransactionPriority::Medium, 155632494086, 1); +} + +BOOST_AUTO_TEST_CASE(basicGasPricer_bcValidBlockTest) +{ + dev::test::executeGasPricerTest("SimpleTx", 30.679, 15.0, "/BlockTests/bcValidBlockTest.json", TransactionPriority::Medium, 155632494086, 10); +} + +BOOST_AUTO_TEST_CASE(basicGasPricer_bcUncleTest) +{ + dev::test::executeGasPricerTest("twoUncle", 30.679, 15.0, "/BlockTests/bcUncleTest.json", TransactionPriority::Medium, 155632494086, 1); +} + +BOOST_AUTO_TEST_CASE(basicGasPricer_bcUncleHeaderValiditiy) +{ + dev::test::executeGasPricerTest("correct", 30.679, 15.0, "/BlockTests/bcUncleHeaderValiditiy.json", TransactionPriority::Medium, 155632494086, 1); +} + +BOOST_AUTO_TEST_CASE(basicGasPricer_notxs) +{ + dev::test::executeGasPricerTest("notxs", 30.679, 15.0, "/BlockTests/bcGasPricerTest.json", TransactionPriority::Medium, 155632494086, 155632494086); +} + +BOOST_AUTO_TEST_CASE(basicGasPricer_highGasUsage_LowestPrio) +{ + dev::test::executeGasPricerTest("highGasUsage", 30.679, 15.0, "/BlockTests/bcGasPricerTest.json", TransactionPriority::Lowest, 15731292650, 10000000000000); +} + +BOOST_AUTO_TEST_CASE(basicGasPricer_highGasUsage_LowPrio) +{ + dev::test::executeGasPricerTest("highGasUsage", 30.679, 15.0, "/BlockTests/bcGasPricerTest.json", TransactionPriority::Low, 15731292650, 15734152261884); +} + +BOOST_AUTO_TEST_CASE(basicGasPricer_highGasUsage_MediumPrio) +{ + dev::test::executeGasPricerTest("highGasUsage", 30.679, 15.0, "/BlockTests/bcGasPricerTest.json", TransactionPriority::Medium, 15731292650, 20000000000000); +} + +BOOST_AUTO_TEST_CASE(basicGasPricer_highGasUsage_HighPrio) +{ + dev::test::executeGasPricerTest("highGasUsage", 30.679, 15.0, "/BlockTests/bcGasPricerTest.json", TransactionPriority::High, 15731292650, 24265847738115); +} + +BOOST_AUTO_TEST_CASE(basicGasPricer_highGasUsage_HighestPrio) +{ + dev::test::executeGasPricerTest("highGasUsage", 30.679, 15.0, "/BlockTests/bcGasPricerTest.json", TransactionPriority::Highest, 15731292650, 30000000000000); +} +BOOST_AUTO_TEST_SUITE_END()