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

bugfix for ricardian contracts being generated #1202

Merged
merged 1 commit into from
Sep 2, 2021
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
29 changes: 29 additions & 0 deletions tests/toolchain/abigen-pass/ricardian_contract_test.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"____comment": "This file was generated with eosio-abigen. DO NOT EDIT ",
"version": "eosio::abi/1.2",
"types": [],
"structs": [
{
"name": "test",
"base": "",
"fields": []
}
],
"actions": [
{
"name": "test",
"type": "test",
"ricardian_contract": "---\nspec-version: 0.0.2\ntitle: test\nsummary: This method does nothing on purpose.\nicon:\n---\n\nThis test checks ricardian contract was generated succesfully."
}
],
"tables": [],
"kv_tables": {},
"ricardian_clauses": [
{
"id": "Disclaimer",
"body": "This test checks ricardian contract was generated succesfully."
}
],
"variants": [],
"action_results": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<h1 class="clause">Disclaimer</h1>

This test checks ricardian contract was generated succesfully.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<h1 class="contract">test</h1>
---
spec-version: 0.0.2
title: test
summary: This method does nothing on purpose.
icon:
---

This test checks ricardian contract was generated succesfully.
12 changes: 12 additions & 0 deletions tests/toolchain/abigen-pass/ricardian_contract_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <eosio/eosio.hpp>

using namespace eosio;

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

[[eosio::action]]
void test() {
}
};
10 changes: 10 additions & 0 deletions tests/toolchain/abigen-pass/ricardian_contract_test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"tests" : [
{
"compile_flags" : ["-R={cwd}"],
"expected" : {
"abi-file" : "ricardian_contract_test.abi"
}
}
]
}
8 changes: 4 additions & 4 deletions tools/include/eosio/abigen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,8 +737,8 @@ namespace eosio { namespace cdt {

virtual bool VisitCXXMethodDecl(clang::CXXMethodDecl* decl) {
if (!has_added_clauses) {
ag.add_clauses(parse_clauses());
ag.add_contracts(parse_contracts());
ag.add_clauses(ag.parse_clauses());
ag.add_contracts(ag.parse_contracts());
has_added_clauses = true;
}

Expand All @@ -753,8 +753,8 @@ namespace eosio { namespace cdt {
}
virtual bool VisitCXXRecordDecl(clang::CXXRecordDecl* decl) {
if (!has_added_clauses) {
ag.add_clauses(parse_clauses());
ag.add_contracts(parse_contracts());
ag.add_clauses(ag.parse_clauses());
ag.add_contracts(ag.parse_contracts());
has_added_clauses = true;
}
if ((decl->isEosioAction() || decl->isEosioTable()) && ag.is_eosio_contract(decl, ag.get_contract_name())) {
Expand Down
1 change: 1 addition & 0 deletions tools/toolchain-tester/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def _run(self, eosio_cpp: str, args: List[str]):
def run(self):
cf = self.test_json.get("compile_flags")
args = cf if cf else []
args = [arg.replace("{cwd}", self.test_suite.directory) for arg in args]

eosio_cpp = os.path.join(self.test_suite.cdt_path, "eosio-cpp")
self._run(eosio_cpp, args)
Expand Down