Skip to content

Commit

Permalink
Merge branch 'hotstuff_integration' into GH-2172-ship-streamer-test
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner authored Feb 5, 2024
2 parents 15236d0 + ccb0793 commit 4b5f14e
Show file tree
Hide file tree
Showing 12 changed files with 100 additions and 3 deletions.
3 changes: 2 additions & 1 deletion libraries/chain/snapshot_scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ void snapshot_scheduler::create_snapshot(next_function<snapshot_information> nex
std::error_code ec;
fs::rename(temp_path, pending_path, ec);
EOS_ASSERT(!ec, snapshot_finalization_exception,
"Unable to promote temp snapshot to pending for block number ${bn}: [code: ${ec}] ${message}",
"Unable to promote temp snapshot ${t} to pending ${p} for block number ${bn}: [code: ${ec}] ${message}",
("t", temp_path.generic_string())("p", pending_path.generic_string())
("bn", head_block_num)("ec", ec.value())("message", ec.message()));
_pending_snapshot_index.emplace(head_id, next, pending_path.generic_string(), snapshot_path.generic_string());
add_pending_snapshot_info(snapshot_information{head_id, head_block_num, head_block_time, chain_snapshot_header::current_version, pending_path.generic_string()});
Expand Down
2 changes: 0 additions & 2 deletions tests/TestHarness/Cluster.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import atexit
import copy
import subprocess
import time
Expand Down Expand Up @@ -76,7 +75,6 @@ def __init__(self, localCluster=True, host="localhost", port=8888, walletHost="l
keepRunning: [True|False] If true, leave nodes running when Cluster is destroyed. Implies keepLogs.
keepLogs: [True|False] If true, retain log files after cluster shuts down.
"""
atexit.register(self.shutdown)
self.accounts=[]
self.nodes=[]
self.unstartedNodes=[]
Expand Down
2 changes: 2 additions & 0 deletions tests/TestHarness/TestHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,5 @@ def reportProductionAnalysis(thresholdMs):
cluster.testFailed = not testSuccessful
if walletMgr:
walletMgr.testFailed = not testSuccessful

cluster.shutdown()
16 changes: 16 additions & 0 deletions tests/ship_streamer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,22 @@ def getLatestSnapshot(nodeId):
Print("Shutdown unneeded bios node")
cluster.biosNode.kill(signal.SIGTERM)

Print("Create a jumbo row")
contract = "jumborow"
contractDir = "unittests/contracts/%s" % (contract)
wasmFile = "%s.wasm" % (contract)
abiFile = "%s.abi" % (contract)

nonProdNode.publishContract(accounts[0], contractDir, wasmFile, abiFile)
jumbotxn = {

"actions": [{"account": "testeraaaaaa","name": "jumbotime",
"authorization": [{"actor": "testeraaaaaa","permission": "active"}],
"data": "",
"compression": "none"}]
}
nonProdNode.pushTransaction(jumbotxn)

Print("Configure and launch txn generators")
targetTpsPerGenerator = 10
testTrxGenDurationSec=60*60
Expand Down
1 change: 1 addition & 0 deletions tests/trace_plugin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def setUpClass(self):
@classmethod
def tearDownClass(self):
TraceApiPluginTest.cluster.testFailed = not testSuccessful
TraceApiPluginTest.cluster.shutdown()

if __name__ == "__main__":
unittest.main()
1 change: 1 addition & 0 deletions unittests/contracts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ add_subdirectory(eosio.system)
add_subdirectory(eosio.token)
add_subdirectory(eosio.wrap)
add_subdirectory(eosio.mechanics)
add_subdirectory(jumborow)
2 changes: 2 additions & 0 deletions unittests/contracts/jumborow/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/jumborow.wasm ${CMAKE_CURRENT_BINARY_DIR}/jumborow.wasm COPYONLY )
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/jumborow.abi ${CMAKE_CURRENT_BINARY_DIR}/jumborow.abi COPYONLY )
23 changes: 23 additions & 0 deletions unittests/contracts/jumborow/jumborow.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"version": "eosio::abi/1.0",
"types": [],
"structs": [{
"name": "jumbo",
"base": "",
"fields": []
}
],
"actions": [{
"name": "jumbotime",
"type": "jumbo",
"ricardian_contract": ""
}
],
"tables": [],
"ricardian_clauses": [],
"error_messages": [],
"abi_extensions": [],
"variants": [],
"action_results": []
}

Binary file added unittests/contracts/jumborow/jumborow.wasm
Binary file not shown.
8 changes: 8 additions & 0 deletions unittests/contracts/jumborow/jumborow.wast
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(module
(import "env" "db_store_i64" (func $db_store_i64 (param i64 i64 i64 i64 i32 i32) (result i32)))
(memory $0 528)
(export "apply" (func $apply))
(func $apply (param $receiver i64) (param $account i64) (param $action_name i64)
(drop (call $db_store_i64 (local.get $receiver) (local.get $receiver) (local.get $receiver) (i64.const 0) (i32.const 1) (i32.const 34603007)))
)
)
11 changes: 11 additions & 0 deletions unittests/contracts/test_wasts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -990,4 +990,15 @@ static const char negative_memory_grow_trap_wast[] = R"=====(
)
)
)
)=====";

static const char set_jumbo_row_wast[] = R"=====(
(module
(import "env" "db_store_i64" (func $db_store_i64 (param i64 i64 i64 i64 i32 i32) (result i32)))
(memory $0 528)
(export "apply" (func $apply))
(func $apply (param $receiver i64) (param $account i64) (param $action_name i64)
(drop (call $db_store_i64 (get_local $receiver) (get_local $receiver) (get_local $receiver) (i64.const 0) (i32.const 1) (i32.const 34603007)))
)
)
)=====";
34 changes: 34 additions & 0 deletions unittests/snapshot_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <test_contracts.hpp>
#include <snapshots.hpp>
#include "test_wasts.hpp"

using namespace eosio;
using namespace testing;
Expand Down Expand Up @@ -656,4 +657,37 @@ BOOST_AUTO_TEST_CASE(json_snapshot_validity_test)
remove(json_snap_path);
}

BOOST_AUTO_TEST_CASE_TEMPLATE(jumbo_row, SNAPSHOT_SUITE, snapshot_suites)
{
fc::temp_directory tempdir;
auto config = tester::default_config(tempdir);
config.first.state_size = 64*1024*1024;
tester chain(config.first, config.second);
chain.execute_setup_policy(setup_policy::full);

chain.create_accounts({"jumbo"_n});
chain.set_code("jumbo"_n, set_jumbo_row_wast);
chain.produce_blocks(1);

signed_transaction trx;
action act;
act.account = "jumbo"_n;
act.name = "jumbo"_n;
act.authorization = vector<permission_level>{{"jumbo"_n,config::active_name}};
trx.actions.push_back(act);

chain.set_transaction_headers(trx);
trx.sign(tester::get_private_key("jumbo"_n, "active"), chain.control->get_chain_id());
chain.push_transaction(trx);
chain.produce_blocks(1);

chain.control->abort_block();

auto writer = SNAPSHOT_SUITE::get_writer();
chain.control->write_snapshot(writer);
auto snapshot = SNAPSHOT_SUITE::finalize(writer);

snapshotted_tester sst(chain.get_config(), SNAPSHOT_SUITE::get_reader(snapshot), 0);
}

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit 4b5f14e

Please sign in to comment.