Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

embed contracts required for native contract unit testing in to libtester #680

Merged
merged 2 commits into from
Jul 19, 2022

Conversation

spoonincode
Copy link
Member

@spoonincode spoonincode commented Jul 15, 2022

For native contract unit testing, libtester potentially needs to setcode a few bios contracts at run time on the chain driving unit tests. Previously, when libtester needed these contracts it would load them from the absolute path of which mandel was built. But after a make dev-install of mandel it's possible the build directory has been removed. And for the mandel-dev.deb package the build directory never even existed on the target.

For these few bios contracts bundle them inside of libtester so that there is no need to read them from disk. This allows libtester to access them after being installed from mandel-dev.deb, for example. I was attempting to minimize code changes in this PR; I think maybe some items should be rearranged further as commented on.

Resolves #642. Work on #639.

Picks up eosnetworkfoundation/mandel-fc#46 where I moved incbin.h in to fc (and updated to latest version) (also we're seeing more fc changes picked up in this PR because a few things are stacked up...)

@@ -4,10 +4,13 @@ configure_file(contracts.hpp.in include/testing_contracts/contracts.hpp ESCAPE_Q
add_library(eosio_testing_contracts INTERFACE)
target_include_directories(eosio_testing_contracts INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/include/testing_contracts)

configure_file(contracts.cpp.in contracts.cpp ESCAPE_QUOTES)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a defect here. contracts.cpp depends on the various wasm/abi files it embeds and the build system is oblivious to that. Unfortunately attaching proper dependencies is going to require some reorganization due to these wasm/abi files being placed in to CMAKE_BINARY_DIR via unittests/contracts, which is currently executed after libraries/testing. I don't have a low touch fix for the reorg required to properly fix.

Base automatically changed from eosio_tester_install_fixups_31x to release/3.1.x July 19, 2022 17:00
@spoonincode spoonincode merged commit 950032f into release/3.1.x Jul 19, 2022
@spoonincode spoonincode deleted the embed_libtester_contracts_31x branch July 19, 2022 17:47
arhag added a commit that referenced this pull request Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants