AntelopeIO / leap

C++ implementation of the Antelope protocol
Other
116 stars 68 forks source link

Add dry-run unittests #1083

Closed heifner closed 1 year ago

heifner commented 1 year ago

We have no dry-run unittests. See https://github.com/AntelopeIO/leap/pull/1081 for an example of an issue that slipped through. Create corresponding dry-run unittests similar to read_only_trx_tests.cpp

Include this test:

BOOST_FIXTURE_TEST_CASE(dry_run_auth_test, read_only_trx_tester) { try {
      set_up_test_contract();

      // verify dry-run transaction allows authorizations, but doesn't verify
      send_db_api_transaction("insert"_n, insert_data, {{"alice"_n, config::active_name}}, transaction_metadata::trx_type::dry_run);
} FC_LOG_AND_RETHROW() }

where send_db_api_transaction has

      } else if ( type == transaction_metadata::trx_type::dry_run ) {
         // sign with some irrelevant sigs which should be allowed
         trx.sign(get_private_key("invalid"_n, "active"), control->get_chain_id());
heifner commented 1 year ago

As much as possible normal write input transaction and dry-run transactions should produce same/similar errors for similar issues. Specifically lack of authorization should generate same error if possible.