Skip to content

Commit

Permalink
Merge pull request #2183 from AntelopeIO/large_row_tests
Browse files Browse the repository at this point in the history
additional tests for state history plugin and snapshots
  • Loading branch information
spoonincode authored Feb 2, 2024
2 parents 3f8e645 + 161cb28 commit a131719
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/ship_streamer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,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 unittests/contracts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,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 @@ -653,4 +654,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 a131719

Please sign in to comment.