Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.

Add back integration_test contract; fixes nodeos_under_min_avail_ram_lr_test #6902

Merged
merged 1 commit into from
Mar 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions unittests/test-contracts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ endif()

add_subdirectory( asserter )
add_subdirectory( deferred_test )
add_subdirectory( integration_test )
add_subdirectory( noop )
add_subdirectory( payloadless )
add_subdirectory( proxy )
Expand Down
6 changes: 6 additions & 0 deletions unittests/test-contracts/integration_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if( EOSIO_COMPILE_TEST_CONTRACTS )
add_contract( integration_test integration_test integration_test.cpp )
else()
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/integration_test.wasm ${CMAKE_CURRENT_BINARY_DIR}/integration_test.wasm COPYONLY )
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/integration_test.abi ${CMAKE_CURRENT_BINARY_DIR}/integration_test.abi COPYONLY )
endif()
57 changes: 57 additions & 0 deletions unittests/test-contracts/integration_test/integration_test.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"____comment": "This file was generated with eosio-abigen. DO NOT EDIT ",
"version": "eosio::abi/1.1",
"types": [],
"structs": [
{
"name": "payload",
"base": "",
"fields": [
{
"name": "key",
"type": "uint64"
},
{
"name": "data",
"type": "uint64[]"
}
]
},
{
"name": "store",
"base": "",
"fields": [
{
"name": "from",
"type": "name"
},
{
"name": "to",
"type": "name"
},
{
"name": "num",
"type": "uint64"
}
]
}
],
"actions": [
{
"name": "store",
"type": "store",
"ricardian_contract": ""
}
],
"tables": [
{
"name": "payloads",
"type": "payload",
"index_type": "i64",
"key_names": [],
"key_types": []
}
],
"ricardian_clauses": [],
"variants": []
}
29 changes: 29 additions & 0 deletions unittests/test-contracts/integration_test/integration_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* @file
* @copyright defined in eos/LICENSE
*/
#include "integration_test.hpp"

using namespace eosio;

void integration_test::store( name from, name to, uint64_t num ) {
require_auth( from );

check( is_account( to ), "to account does not exist" );
check( num < std::numeric_limits<size_t>::max(), "num to large" );

payloads_table data( get_self(), from.value );
uint64_t key = 0;
const uint64_t num_keys = 5;

while( data.find( key ) != data.end() ) {
key += num_keys;
}

for( uint64_t i = 0; i < num_keys; ++i ) {
data.emplace( from, [&]( auto& g ) {
g.key = key + i;
g.data = std::vector<uint64_t>( static_cast<size_t>(num), 5 );
} );
}
}
27 changes: 27 additions & 0 deletions unittests/test-contracts/integration_test/integration_test.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @file
* @copyright defined in eos/LICENSE
*/
#pragma once

#include <eosio/eosio.hpp>

class [[eosio::contract]] integration_test : public eosio::contract {
public:
using eosio::contract::contract;

[[eosio::action]]
void store( eosio::name from, eosio::name to, uint64_t num );

struct [[eosio::table("payloads")]] payload {
uint64_t key;
std::vector<uint64_t> data;

uint64_t primary_key()const { return key; }

EOSLIB_SERIALIZE( payload, (key)(data) )
};

using payloads_table = eosio::multi_index< "payloads"_n, payload >;

};
Binary file not shown.