Skip to content

Commit

Permalink
Add more abi tests
Browse files Browse the repository at this point in the history
  • Loading branch information
harrywong committed Jul 5, 2018
1 parent af8b67c commit 50286a0
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 2 deletions.
13 changes: 13 additions & 0 deletions bind/libevt/test/libevt_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,23 @@ BOOST_AUTO_TEST_CASE( evtabi ) {
BOOST_TEST_REQUIRE(r7 == EVT_OK);
BOOST_TEST_CHECK(ref_block_prefix == 2253733142);

auto j3 = R"(
{
"name": "test1530718665",
"signatures": [
"SIG_K1_KXjtmeihJi1qnSs7vmqJDRJoZ1nSEPeeRjsKJRpm24g8yhFtAepkRDR4nVFbXjvoaQvT4QrzuNWCbuEhceYpGmAvsG47Fj"
]
}
)";
evt_bin_t* bin3 = nullptr;
auto r8 = evt_abi_json_to_bin(abi, "approvedelay", j3, &bin3);
BOOST_TEST_REQUIRE(r8 == EVT_OK);

evt_free(bin);
evt_free(j1restore);
evt_free(chain_id);
evt_free(digest);
evt_free(block_id);
evt_free(bin3);
evt_free_abi(abi);
}
2 changes: 1 addition & 1 deletion docs/ABI-References.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ Add new delay transaction (In-chain delay-signing transaction)
}
```

### `approve` Action
### `approvedelay` Action
Approve one delay transaction
> `signatures` are the signatures of the delayed transaction.
> And the keys used to sign transaction must be required keys while authorizing the delayed transaction.
Expand Down
3 changes: 2 additions & 1 deletion libraries/chain/contracts/evt_contract_abi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ evt_contract_abi() {

evt_abi.structs.emplace_back( struct_def {
"executedelay", "", {
{"name", "proposal_name"}
{"name", "proposal_name"},
{"executor", "user_id"}
}
});

Expand Down
49 changes: 49 additions & 0 deletions unittests/abi_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1022,3 +1022,52 @@ BOOST_AUTO_TEST_CASE(newdelay_test) {
}
FC_LOG_AND_RETHROW()
}

BOOST_AUTO_TEST_CASE(approvedelay_test) {
try {
auto abis = get_evt_abi();
BOOST_CHECK(true);
const char* test_data = R"=======(
{
"name": "test1530718665",
"signatures": [
"SIG_K1_KXjtmeihJi1qnSs7vmqJDRJoZ1nSEPeeRjsKJRpm24g8yhFtAepkRDR4nVFbXjvoaQvT4QrzuNWCbuEhceYpGmAvsG47Fj"
]
}
)=======";

auto var = fc::json::from_string(test_data);
auto adact = var.as<approvedelay>();

BOOST_TEST("test1530718665" == (std::string)adact.name);
BOOST_TEST(adact.signatures.size() == 1);
BOOST_TEST((std::string)adact.signatures[0] == "SIG_K1_KXjtmeihJi1qnSs7vmqJDRJoZ1nSEPeeRjsKJRpm24g8yhFtAepkRDR4nVFbXjvoaQvT4QrzuNWCbuEhceYpGmAvsG47Fj");

verify_byte_round_trip_conversion(abis, "approvedelay", var);
verify_type_round_trip_conversion<approvedelay>(abis, "approvedelay", var);
}
FC_LOG_AND_RETHROW()
}

BOOST_AUTO_TEST_CASE(executedelay_test) {
try {
auto abis = get_evt_abi();
BOOST_CHECK(true);
const char* test_data = R"=======(
{
"name": "test1530718626",
"executor": "EVT548LviBDF6EcknKnKUMeaPUrZN2uhfCB1XrwHsURZngakYq9Vx"
}
)=======";

auto var = fc::json::from_string(test_data);
auto edact = var.as<executedelay>();

BOOST_TEST("test1530718626" == (std::string)edact.name);
BOOST_TEST((std::string)edact.executor == "EVT548LviBDF6EcknKnKUMeaPUrZN2uhfCB1XrwHsURZngakYq9Vx");

verify_byte_round_trip_conversion(abis, "executedelay", var);
verify_type_round_trip_conversion<executedelay>(abis, "executedelay", var);
}
FC_LOG_AND_RETHROW()
}

0 comments on commit 50286a0

Please sign in to comment.