mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #4951 from ethereum/alethUpdates
Use current aleth release for testing.
This commit is contained in:
commit
17bf164afe
@ -90,7 +90,7 @@ The option ``--no-smt`` disables the tests that require ``libz3`` and
|
|||||||
``--no-ipc`` disables those that require ``aleth``.
|
``--no-ipc`` disables those that require ``aleth``.
|
||||||
|
|
||||||
If you want to run the ipc tests (that test the semantics of the generated code),
|
If you want to run the ipc tests (that test the semantics of the generated code),
|
||||||
you need to install `aleth <https://github.com/ethereum/cpp-ethereum/releases/download/solidityTester/aleth_2018-06-20_artful>`_ and run it in testing mode: ``aleth --test -d /tmp/testeth`` (make sure to rename it).
|
you need to install `aleth <https://github.com/ethereum/aleth/releases/download/v1.5.0-alpha.7/aleth-1.5.0-alpha.7-linux-x86_64.tar.gz>`_ and run it in testing mode: ``aleth --test -d /tmp/testeth`` (make sure to rename it).
|
||||||
|
|
||||||
To run the actual tests, use: ``./scripts/soltest.sh --ipcpath /tmp/testeth/geth.ipc``.
|
To run the actual tests, use: ``./scripts/soltest.sh --ipcpath /tmp/testeth/geth.ipc``.
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ The CI runs additional tests (including ``solc-js`` and testing third party Soli
|
|||||||
|
|
||||||
You can not use some versions of ``aleth`` for testing. We suggest using
|
You can not use some versions of ``aleth`` for testing. We suggest using
|
||||||
the same version that the Solidity continuous integration tests use.
|
the same version that the Solidity continuous integration tests use.
|
||||||
Currently the CI uses ``d661ac4fec0aeffbedcdc195f67f5ded0c798278`` of ``aleth``.
|
Currently the CI uses version ``1.5.0-alpha.7`` of ``aleth``.
|
||||||
|
|
||||||
Writing and running syntax tests
|
Writing and running syntax tests
|
||||||
--------------------------------
|
--------------------------------
|
||||||
|
@ -130,21 +130,14 @@ function download_aleth()
|
|||||||
elif [ -z $CI ]; then
|
elif [ -z $CI ]; then
|
||||||
ALETH_PATH="aleth"
|
ALETH_PATH="aleth"
|
||||||
else
|
else
|
||||||
# Any time the hash is updated here, the "Running compiler tests" section should also be updated.
|
|
||||||
mkdir -p /tmp/test
|
mkdir -p /tmp/test
|
||||||
if grep -i trusty /etc/lsb-release >/dev/null 2>&1
|
# Any time the hash is updated here, the "Running compiler tests" section should also be updated.
|
||||||
then
|
ALETH_HASH="8ce2f00539d2fd8b5f093d854c6999424f7494ff"
|
||||||
# built from d661ac4fec0aeffbedcdc195f67f5ded0c798278 at 2018-06-20
|
ALETH_VERSION=1.5.0-alpha.7
|
||||||
ALETH_BINARY=aleth_2018-06-20_trusty
|
wget -q -O /tmp/test/aleth.tar.gz https://github.com/ethereum/aleth/releases/download/v${ALETH_VERSION}/aleth-${ALETH_VERSION}-linux-x86_64.tar.gz
|
||||||
ALETH_HASH="54b8a5455e45b295e3a962f353ff8f1580ed106c"
|
test "$(shasum /tmp/test/aleth.tar.gz)" = "$ALETH_HASH /tmp/test/aleth.tar.gz"
|
||||||
else
|
tar -xf /tmp/test/aleth.tar.gz -C /tmp/test
|
||||||
# built from d661ac4fec0aeffbedcdc195f67f5ded0c798278 at 2018-06-20
|
ALETH_PATH="/tmp/test/bin/aleth"
|
||||||
ALETH_BINARY=aleth_2018-06-20_artful
|
|
||||||
ALETH_HASH="02e6c4b3d98299885e73f7db6c9e3fbe3d66d444"
|
|
||||||
fi
|
|
||||||
ALETH_PATH="/tmp/test/aleth"
|
|
||||||
wget -q -O $ALETH_PATH https://github.com/ethereum/cpp-ethereum/releases/download/solidityTester/$ALETH_BINARY
|
|
||||||
test "$(shasum $ALETH_PATH)" = "$ALETH_HASH $ALETH_PATH"
|
|
||||||
sync
|
sync
|
||||||
chmod +x $ALETH_PATH
|
chmod +x $ALETH_PATH
|
||||||
sync # Otherwise we might get a "text file busy" error
|
sync # Otherwise we might get a "text file busy" error
|
||||||
|
@ -296,40 +296,7 @@ void RPCSession::test_mineBlocks(int _number)
|
|||||||
{
|
{
|
||||||
u256 startBlock = fromBigEndian<u256>(fromHex(rpcCall("eth_blockNumber").asString()));
|
u256 startBlock = fromBigEndian<u256>(fromHex(rpcCall("eth_blockNumber").asString()));
|
||||||
BOOST_REQUIRE(rpcCall("test_mineBlocks", { to_string(_number) }, true) == true);
|
BOOST_REQUIRE(rpcCall("test_mineBlocks", { to_string(_number) }, true) == true);
|
||||||
|
BOOST_REQUIRE(fromBigEndian<u256>(fromHex(rpcCall("eth_blockNumber").asString())) == startBlock + _number);
|
||||||
// We auto-calibrate the time it takes to mine the transaction.
|
|
||||||
// It would be better to go without polling, but that would probably need a change to the test client
|
|
||||||
|
|
||||||
auto startTime = std::chrono::steady_clock::now();
|
|
||||||
unsigned sleepTime = m_sleepTime;
|
|
||||||
size_t tries = 0;
|
|
||||||
for (; ; ++tries)
|
|
||||||
{
|
|
||||||
std::this_thread::sleep_for(chrono::milliseconds(sleepTime));
|
|
||||||
auto endTime = std::chrono::steady_clock::now();
|
|
||||||
unsigned timeSpent = std::chrono::duration_cast<std::chrono::milliseconds>(endTime - startTime).count();
|
|
||||||
if (timeSpent > m_maxMiningTime)
|
|
||||||
BOOST_FAIL("Error in test_mineBlocks: block mining timeout!");
|
|
||||||
if (fromBigEndian<u256>(fromHex(rpcCall("eth_blockNumber").asString())) >= startBlock + _number)
|
|
||||||
break;
|
|
||||||
else
|
|
||||||
sleepTime *= 2;
|
|
||||||
}
|
|
||||||
if (tries > 1)
|
|
||||||
{
|
|
||||||
m_successfulMineRuns = 0;
|
|
||||||
m_sleepTime += 2;
|
|
||||||
}
|
|
||||||
else if (tries == 1)
|
|
||||||
{
|
|
||||||
m_successfulMineRuns++;
|
|
||||||
if (m_successfulMineRuns > 5)
|
|
||||||
{
|
|
||||||
m_successfulMineRuns = 0;
|
|
||||||
if (m_sleepTime > 2)
|
|
||||||
m_sleepTime--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RPCSession::test_modifyTimestamp(size_t _timestamp)
|
void RPCSession::test_modifyTimestamp(size_t _timestamp)
|
||||||
|
@ -136,9 +136,6 @@ private:
|
|||||||
|
|
||||||
IPCSocket m_ipcSocket;
|
IPCSocket m_ipcSocket;
|
||||||
size_t m_rpcSequence = 1;
|
size_t m_rpcSequence = 1;
|
||||||
unsigned m_maxMiningTime = 6000000; // 600 seconds
|
|
||||||
unsigned m_sleepTime = 10; // 10 milliseconds
|
|
||||||
unsigned m_successfulMineRuns = 0;
|
|
||||||
bool m_receiptHasStatusField = false;
|
bool m_receiptHasStatusField = false;
|
||||||
|
|
||||||
std::vector<std::string> m_accounts;
|
std::vector<std::string> m_accounts;
|
||||||
|
@ -62,7 +62,7 @@ public:
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void testCreationTimeGas(string const& _sourceCode)
|
void testCreationTimeGas(string const& _sourceCode, u256 const& _tolerance = u256(0))
|
||||||
{
|
{
|
||||||
compileAndRun(_sourceCode);
|
compileAndRun(_sourceCode);
|
||||||
auto state = make_shared<KnownState>();
|
auto state = make_shared<KnownState>();
|
||||||
@ -75,12 +75,13 @@ public:
|
|||||||
gas += gasForTransaction(m_compiler.object(m_compiler.lastContractName()).bytecode, true);
|
gas += gasForTransaction(m_compiler.object(m_compiler.lastContractName()).bytecode, true);
|
||||||
|
|
||||||
BOOST_REQUIRE(!gas.isInfinite);
|
BOOST_REQUIRE(!gas.isInfinite);
|
||||||
BOOST_CHECK_EQUAL(gas.value, m_gasUsed);
|
BOOST_CHECK_LE(m_gasUsed, gas.value);
|
||||||
|
BOOST_CHECK_LE(gas.value - _tolerance, m_gasUsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compares the gas computed by PathGasMeter for the given signature (but unknown arguments)
|
/// Compares the gas computed by PathGasMeter for the given signature (but unknown arguments)
|
||||||
/// against the actual gas usage computed by the VM on the given set of argument variants.
|
/// against the actual gas usage computed by the VM on the given set of argument variants.
|
||||||
void testRunTimeGas(string const& _sig, vector<bytes> _argumentVariants)
|
void testRunTimeGas(string const& _sig, vector<bytes> _argumentVariants, u256 const& _tolerance = u256(0))
|
||||||
{
|
{
|
||||||
u256 gasUsed = 0;
|
u256 gasUsed = 0;
|
||||||
GasMeter::GasConsumption gas;
|
GasMeter::GasConsumption gas;
|
||||||
@ -98,7 +99,8 @@ public:
|
|||||||
_sig
|
_sig
|
||||||
);
|
);
|
||||||
BOOST_REQUIRE(!gas.isInfinite);
|
BOOST_REQUIRE(!gas.isInfinite);
|
||||||
BOOST_CHECK_EQUAL(gas.value, m_gasUsed);
|
BOOST_CHECK_LE(m_gasUsed, gas.value);
|
||||||
|
BOOST_CHECK_LE(gas.value - _tolerance, m_gasUsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GasMeter::GasConsumption gasForTransaction(bytes const& _data, bool _isCreation)
|
static GasMeter::GasConsumption gasForTransaction(bytes const& _data, bool _isCreation)
|
||||||
@ -186,7 +188,7 @@ BOOST_AUTO_TEST_CASE(updating_store)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
testCreationTimeGas(sourceCode);
|
testCreationTimeGas(sourceCode, m_evmVersion < EVMVersion::constantinople() ? u256(0) : u256(9600));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(branches)
|
BOOST_AUTO_TEST_CASE(branches)
|
||||||
|
@ -3039,7 +3039,8 @@ BOOST_AUTO_TEST_CASE(gaslimit)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode);
|
compileAndRun(sourceCode);
|
||||||
ABI_CHECK(callContractFunction("f()"), encodeArgs(gasLimit()));
|
auto result = callContractFunction("f()");
|
||||||
|
ABI_CHECK(result, encodeArgs(gasLimit()));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(gasprice)
|
BOOST_AUTO_TEST_CASE(gasprice)
|
||||||
|
@ -60,7 +60,7 @@ DIR=$(mktemp -d)
|
|||||||
|
|
||||||
# Update version (needed for some tests)
|
# Update version (needed for some tests)
|
||||||
echo "Updating package.json to version $VERSION"
|
echo "Updating package.json to version $VERSION"
|
||||||
npm version --no-git-tag-version $VERSION
|
npm version --allow-same-version --no-git-tag-version $VERSION
|
||||||
|
|
||||||
echo "Running solc-js tests..."
|
echo "Running solc-js tests..."
|
||||||
npm run test
|
npm run test
|
||||||
|
Loading…
Reference in New Issue
Block a user